1 /*
2 * Copyright 2013 Daniel Warner <contact@danrw.com>
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <keplerian_toolbox/third_party/libsgp4/Util.h>
18
19 #include <algorithm>
20 #include <functional>
21 #include <locale>
22
23 namespace Util
24 {
25 namespace
26 {
27 struct IsDigit : std::unary_function<char, bool> {
operator ()Util::__anonb2977a780111::IsDigit28 bool operator()(char c) const
29 {
30 return std::isdigit(c, std::locale::classic()) == 0;
31 }
32 };
33 }
34
TrimLeft(std::string & s)35 void TrimLeft(std::string &s)
36 {
37 s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(IsDigit())));
38 }
39
TrimRight(std::string & s)40 void TrimRight(std::string &s)
41 {
42 s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(IsDigit())).base(), s.end());
43 }
44
Trim(std::string & s)45 void Trim(std::string &s)
46 {
47 TrimLeft(s);
48 TrimRight(s);
49 }
50 }
51