diff --git a/Globals.cpp b/Globals.cpp old mode 100644 new mode 100755 index 7da6d90..47140b7 --- a/Globals.cpp +++ b/Globals.cpp @@ -1,2 +1,36 @@ #include "Globals.h" +void TrimLeft(std::string& str) { + + std::string whitespaces(" \t\f\n\r"); + + if (!str.empty()) { + std::string::size_type pos = str.find_first_not_of(whitespaces); + + if (pos != std::string::npos) + str.erase(0, pos); + else + str.clear(); + } +} + +void TrimRight(std::string& str) { + + std::string whitespaces(" \t\f\n\r"); + + if (!str.empty()) { + std::string::size_type pos = str.find_last_not_of(whitespaces); + + if (pos != std::string::npos) + str.erase(pos + 1); + else + str.clear(); + } +} + +void Trim(std::string& str) { + + TrimLeft(str); + TrimRight(str); +} + diff --git a/Globals.h b/Globals.h old mode 100644 new mode 100755 index 3d27c78..74e9e24 --- a/Globals.h +++ b/Globals.h @@ -2,6 +2,7 @@ #define GLOBALS_H_ #include +#include const double kAE = 1.0; const double kQ0 = 120.0; @@ -97,6 +98,9 @@ inline double AcTan(const double sinx, const double cosx) { } } +void TrimLeft(std::string& str); +void TrimRight(std::string& str); +void Trim(std::string& str); #endif diff --git a/RunTest.cpp b/RunTest.cpp old mode 100644 new mode 100755 index 2e7d7fb..3dae99b --- a/RunTest.cpp +++ b/RunTest.cpp @@ -128,8 +128,8 @@ void RunTest(const char* infile) { /* * trim spaces */ - Tle::TrimLeft(line); - Tle::TrimRight(line); + TrimLeft(line); + TrimRight(line); /* * skip blank lines or lines starting with # diff --git a/Tle.cpp b/Tle.cpp index 04ce064..057e807 100755 --- a/Tle.cpp +++ b/Tle.cpp @@ -294,38 +294,3 @@ int Tle::CheckSum(const std::string& str) { return (xsum % 10); } - -/* - * trim left of string - */ -void Tle::TrimLeft(std::string& str) { - - std::string whitespaces(" \t\f\n\r"); - - if (!str.empty()) { - std::string::size_type pos = str.find_first_not_of(whitespaces); - - if (pos != std::string::npos) - str.erase(0, pos); - else - str.clear(); - } -} - -/* - * trim right of string - */ -void Tle::TrimRight(std::string& str) { - - std::string whitespaces(" \t\f\n\r"); - - if (!str.empty()) { - std::string::size_type pos = str.find_last_not_of(whitespaces); - - if (pos != std::string::npos) - str.erase(pos + 1); - else - str.clear(); - } -} - diff --git a/Tle.h b/Tle.h index 9604677..59feb30 100755 --- a/Tle.h +++ b/Tle.h @@ -100,8 +100,6 @@ public: */ static bool IsValidPair(const std::string& line1, const std::string& line2); static bool IsValidLine(const std::string& str, unsigned char line_number); - static void TrimLeft(std::string& str); - static void TrimRight(std::string& str); private: /*