Commit 386c0c06 authored by Rogerborg's avatar Rogerborg

"Bug" #2237876; provide an optional parameter to string::trim() to allow the...

"Bug" #2237876; provide an optional parameter to string::trim() to allow the user to specify characters other than common Latin-1 whitespace.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@1726 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 18ff52c0
......@@ -821,18 +821,16 @@ public:
//! trims the string.
/** Removes whitespace from begin and end of the string. */
string<T>& trim()
/** Removes the specified characters (by default, Latin-1 whitespace)
from the begining and the end of the string. */
string<T>& trim(const string<T> & whitespace = " \t\n\r")
{
const c8 whitespace[] = " \t\n\r";
const u32 whitespacecount = 4;
// find start and end of real string without whitespace
const s32 begin = findFirstCharNotInList(whitespace, whitespacecount);
// find start and end of the substring without the specified characters
const s32 begin = findFirstCharNotInList(whitespace.c_str(), whitespace.used);
if (begin == -1)
return (*this="");
const s32 end = findLastCharNotInList(whitespace, whitespacecount);
const s32 end = findLastCharNotInList(whitespace.c_str(), whitespace.used);
return (*this = subString(begin, (end +1) - begin));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment