update trim
parent
1a57bb43f9
commit
46e6bf17db
|
@ -23,26 +23,15 @@
|
||||||
|
|
||||||
namespace libsgp4::Util
|
namespace libsgp4::Util
|
||||||
{
|
{
|
||||||
namespace
|
|
||||||
{
|
|
||||||
struct IsDigit: std::unary_function<char, bool>
|
|
||||||
{
|
|
||||||
bool operator()(char c) const
|
|
||||||
{
|
|
||||||
return std::isdigit(c, std::locale::classic()) == 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrimLeft(std::string& s)
|
void TrimLeft(std::string& s)
|
||||||
{
|
{
|
||||||
s.erase(s.begin(),
|
s.erase(s.begin(),
|
||||||
std::find_if(s.begin(), s.end(), std::not1(IsDigit())));
|
std::find_if(s.begin(), s.end(), [](unsigned char c){ return std::isgraph(c) != 0; }));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrimRight(std::string& s)
|
void TrimRight(std::string& s)
|
||||||
{
|
{
|
||||||
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(IsDigit())).base(),
|
s.erase(std::find_if(s.rbegin(), s.rend(), [](unsigned char c){ return std::isgraph(c) != 0; }).base(),
|
||||||
s.end());
|
s.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue