Add cmSystemTools::TrimWhitespace function
This commit is contained in:
parent
e858440185
commit
2cd36550b0
|
@ -196,6 +196,20 @@ std::string cmSystemTools::EscapeQuotes(const char* str)
|
|||
return result;
|
||||
}
|
||||
|
||||
std::string cmSystemTools::TrimWhitespace(const std::string& s)
|
||||
{
|
||||
std::string::const_iterator start = s.begin();
|
||||
while(start != s.end() && *start == ' ')
|
||||
++start;
|
||||
if (start == s.end())
|
||||
return "";
|
||||
|
||||
std::string::const_iterator stop = s.end()-1;
|
||||
while(*stop == ' ')
|
||||
--stop;
|
||||
return std::string(start, stop+1);
|
||||
}
|
||||
|
||||
void cmSystemTools::Error(const char* m1, const char* m2,
|
||||
const char* m3, const char* m4)
|
||||
{
|
||||
|
|
|
@ -49,6 +49,11 @@ public:
|
|||
///! Escape quotes in a string.
|
||||
static std::string EscapeQuotes(const char* str);
|
||||
|
||||
/**
|
||||
* Returns a string that has whitespace removed from the start and the end.
|
||||
*/
|
||||
static std::string TrimWhitespace(const std::string& s);
|
||||
|
||||
typedef void (*ErrorCallback)(const char*, const char*, bool&, void*);
|
||||
/**
|
||||
* Set the function used by GUI's to display error messages
|
||||
|
|
Loading…
Reference in New Issue