Added new String method trimSpaces.
git-svn-id: http://voip.null.ro/svn/yate@2403 acf43c95-373e-0410-b603-e72c3f656dc1
This commit is contained in:
parent
df32d4593a
commit
678a2cac87
|
@ -118,7 +118,7 @@ using namespace TelEngine;
|
|||
|
||||
static bool isWordBreak(char c, bool nullOk = false)
|
||||
{
|
||||
return (c == ' ' || c == '\t' || c == '\n' || (nullOk && !c));
|
||||
return (c == ' ' || c == '\t' || c == '\r' || c == '\n' || (nullOk && !c));
|
||||
}
|
||||
|
||||
// Decode a single nibble, return -1 on error
|
||||
|
@ -520,6 +520,21 @@ String& String::trimBlanks()
|
|||
return *this;
|
||||
}
|
||||
|
||||
String& String::trimSpaces()
|
||||
{
|
||||
if (m_string) {
|
||||
const char *s = m_string;
|
||||
while (*s == ' ' || *s == '\t' || *s == '\v' || *s == '\f' || *s == '\r' || *s == '\n')
|
||||
s++;
|
||||
const char *e = s;
|
||||
for (const char *p = e; *p; p++)
|
||||
if (*p != ' ' && *p != '\t' || *p == '\v' || *p == '\f' || *p == '\r' || *p == '\n')
|
||||
e = p+1;
|
||||
assign(s,e-s);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
String& String::operator=(const char* value)
|
||||
{
|
||||
if (value && !*value)
|
||||
|
|
|
@ -1404,6 +1404,12 @@ public:
|
|||
*/
|
||||
String& trimBlanks();
|
||||
|
||||
/**
|
||||
* Strip off leading and trailing whitespace characters
|
||||
* (blank, tabs, form-feed, newlines)
|
||||
*/
|
||||
String& trimSpaces();
|
||||
|
||||
/**
|
||||
* Override GenObject's method to return this String
|
||||
* @return A reference to this String
|
||||
|
|
Loading…
Reference in New Issue