Lexer: Migrated trim(), trimLeft() and trimRight() from text to Lexer

This commit is contained in:
Paul Beckingham
2015-10-30 11:17:23 -04:00
parent 51def4b12b
commit 182b5427cd
13 changed files with 75 additions and 72 deletions

View File

@@ -506,6 +506,27 @@ std::string Lexer::ucFirst (const std::string& input)
return output;
}
////////////////////////////////////////////////////////////////////////////////
std::string Lexer::trimLeft (const std::string& in, const std::string& t /*= " "*/)
{
std::string out = in;
return out.erase (0, in.find_first_not_of (t));
}
////////////////////////////////////////////////////////////////////////////////
std::string Lexer::trimRight (const std::string& in, const std::string& t /*= " "*/)
{
std::string out = in;
return out.erase (out.find_last_not_of (t) + 1);
}
////////////////////////////////////////////////////////////////////////////////
std::string Lexer::trim (const std::string& in, const std::string& t /*= " "*/)
{
std::string out = in;
return trimLeft (trimRight (out, t), t);
}
////////////////////////////////////////////////////////////////////////////////
// Lexer::Type::string
// '|"