-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,31 +22,21 @@ | |
namespace snowcrash { | ||
|
||
// Check a character not to be an space of any kind | ||
inline bool isSpace(char i){ | ||
inline bool isSpace(const char i){ | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
zdne
|
||
if(i == ' ' || i == '\t' || i == '\n' || i == '\v' || i == '\f' || i == '\r') | ||
return true; | ||
return false; | ||
} | ||
|
||
// Trim string from start | ||
inline std::string& TrimStringStart(std::string &s) { | ||
std::string::iterator it; | ||
for (it = s.begin() ; it < s.end() ; ++it){ | ||
if(!isSpace(*it)) | ||
break; | ||
} | ||
s.erase(s.begin(), it); | ||
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun(isSpace)))); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
return s; | ||
} | ||
|
||
// Trim string from end | ||
inline std::string& TrimStringEnd(std::string &s) { | ||
std::string::iterator it; | ||
for (it = s.end()-1 ; it > s.begin() ; --it){ | ||
if(!isSpace(*it)) | ||
break; | ||
} | ||
s.erase(it+1 , s.end()); | ||
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun(isSpace))).base(), s.end()); | ||
return s; | ||
} | ||
|
||
|
the reason of creating
isSpace(const char i)
rather than usingstd::isstring
is due to a problem of software crashes on the debug mode, ofter parsing none ASCII code.cc. @zdne