mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 16:03:24 +00:00
COMMON: Change recently added string methods to be camelcase
This commit is contained in:
parent
fda0c1a756
commit
f972d68ae2
@ -732,12 +732,12 @@ size_t String::rfind(char c, size_t pos) const {
|
|||||||
return npos;
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t String::find_first_of(char c, size_t pos) const {
|
size_t String::findFirstOf(char c, size_t pos) const {
|
||||||
const char *strP = (pos >= _size) ? 0 : strchr(_str + pos, c);
|
const char *strP = (pos >= _size) ? 0 : strchr(_str + pos, c);
|
||||||
return strP ? strP - _str : npos;
|
return strP ? strP - _str : npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t String::find_first_of(const char *chars, size_t pos) const {
|
size_t String::findFirstOf(const char *chars, size_t pos) const {
|
||||||
for (uint idx = pos; idx < _size; ++idx) {
|
for (uint idx = pos; idx < _size; ++idx) {
|
||||||
if (strchr(chars, (*this)[idx]))
|
if (strchr(chars, (*this)[idx]))
|
||||||
return idx;
|
return idx;
|
||||||
@ -746,7 +746,7 @@ size_t String::find_first_of(const char *chars, size_t pos) const {
|
|||||||
return npos;
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t String::find_first_not_of(char c, size_t pos) const {
|
size_t String::findFirstNotOf(char c, size_t pos) const {
|
||||||
for (uint idx = pos; idx < _size; ++idx) {
|
for (uint idx = pos; idx < _size; ++idx) {
|
||||||
if ((*this)[idx] != c)
|
if ((*this)[idx] != c)
|
||||||
return idx;
|
return idx;
|
||||||
@ -755,7 +755,7 @@ size_t String::find_first_not_of(char c, size_t pos) const {
|
|||||||
return npos;
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t String::find_first_not_of(const char *chars, size_t pos) const {
|
size_t String::findFirstNotOf(const char *chars, size_t pos) const {
|
||||||
for (uint idx = pos; idx < _size; ++idx) {
|
for (uint idx = pos; idx < _size; ++idx) {
|
||||||
if (!strchr(chars, (*this)[idx]))
|
if (!strchr(chars, (*this)[idx]))
|
||||||
return idx;
|
return idx;
|
||||||
@ -764,7 +764,7 @@ size_t String::find_first_not_of(const char *chars, size_t pos) const {
|
|||||||
return npos;
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t String::find_last_not_of(char c) const {
|
size_t String::findLastNotOf(char c) const {
|
||||||
for (int idx = (int)_size - 1; idx >= 0; --idx) {
|
for (int idx = (int)_size - 1; idx >= 0; --idx) {
|
||||||
if ((*this)[idx] != c)
|
if ((*this)[idx] != c)
|
||||||
return c;
|
return c;
|
||||||
@ -773,7 +773,7 @@ size_t String::find_last_not_of(char c) const {
|
|||||||
return npos;
|
return npos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t String::find_last_not_of(const char *chars) const {
|
size_t String::findLastNotOf(const char *chars) const {
|
||||||
for (int idx = (int)_size - 1; idx >= 0; --idx) {
|
for (int idx = (int)_size - 1; idx >= 0; --idx) {
|
||||||
if (!strchr(chars, (*this)[idx]))
|
if (!strchr(chars, (*this)[idx]))
|
||||||
return idx;
|
return idx;
|
||||||
|
24
common/str.h
24
common/str.h
@ -324,30 +324,30 @@ public:
|
|||||||
size_t rfind(char c, size_t pos = npos) const;
|
size_t rfind(char c, size_t pos = npos) const;
|
||||||
|
|
||||||
/** Find first character in the string matching the passed character */
|
/** Find first character in the string matching the passed character */
|
||||||
size_t find_first_of(char c, size_t pos = 0) const;
|
size_t findFirstOf(char c, size_t pos = 0) const;
|
||||||
|
|
||||||
/** Find first character in the string that's any character of the passed string */
|
/** Find first character in the string that's any character of the passed string */
|
||||||
size_t find_first_of(const char *chars, size_t pos = 0) const;
|
size_t findFirstOf(const char *chars, size_t pos = 0) const;
|
||||||
size_t find_first_of(const String &chars, size_t pos = 0) const {
|
size_t findFirstOf(const String &chars, size_t pos = 0) const {
|
||||||
return find_first_of(chars.c_str(), pos);
|
return findFirstOf(chars.c_str(), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Find first character in the string that's not the specified character */
|
/** Find first character in the string that's not the specified character */
|
||||||
size_t find_first_not_of(char c, size_t pos = 0) const;
|
size_t findFirstNotOf(char c, size_t pos = 0) const;
|
||||||
|
|
||||||
/** Find first character in the string that's not any character of the passed string */
|
/** Find first character in the string that's not any character of the passed string */
|
||||||
size_t find_first_not_of(const char *chars, size_t pos = 0) const;
|
size_t findFirstNotOf(const char *chars, size_t pos = 0) const;
|
||||||
size_t find_first_not_of(const String &chars, size_t pos = 0) const {
|
size_t findFirstNotOf(const String &chars, size_t pos = 0) const {
|
||||||
return find_first_not_of(chars.c_str(), pos);
|
return findFirstNotOf(chars.c_str(), pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Find the last character in the string that's not the specified character */
|
/** Find the last character in the string that's not the specified character */
|
||||||
size_t find_last_not_of(char c) const;
|
size_t findLastNotOf(char c) const;
|
||||||
|
|
||||||
/** Find the last character in the string that's not in any of the passed characters */
|
/** Find the last character in the string that's not in any of the passed characters */
|
||||||
size_t find_last_not_of(const char *chars) const;
|
size_t findLastNotOf(const char *chars) const;
|
||||||
size_t find_last_not_of(const String &chars) const {
|
size_t findLastNotOf(const String &chars) const {
|
||||||
return find_last_not_of(chars.c_str());
|
return findLastNotOf(chars.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return a substring of this string */
|
/** Return a substring of this string */
|
||||||
|
@ -205,7 +205,7 @@ static string encode_entity(const string &s) {
|
|||||||
|
|
||||||
static string decode_entity(const string &s, size_t &pos) {
|
static string decode_entity(const string &s, size_t &pos) {
|
||||||
size_t old_pos = pos;
|
size_t old_pos = pos;
|
||||||
string::size_type entity_name_len = s.find_first_of("; \t\r\n", pos) - pos - 1;
|
string::size_type entity_name_len = s.findFirstOf("; \t\r\n", pos) - pos - 1;
|
||||||
|
|
||||||
/* Call me paranoid... but I don't think having an end-of-line or similar
|
/* Call me paranoid... but I don't think having an end-of-line or similar
|
||||||
inside a &...; expression is 'good', valid though it may be. */
|
inside a &...; expression is 'good', valid though it may be. */
|
||||||
|
@ -362,7 +362,7 @@ Std::string ConverseGump::strip_whitespace_after_break(Std::string s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ConverseGump::parse_token(MsgText *token) {
|
bool ConverseGump::parse_token(MsgText *token) {
|
||||||
int at_idx = token->s.find_first_of('@', 0);
|
int at_idx = token->s.findFirstOf('@', 0);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int len = (int)token->s.length();
|
int len = (int)token->s.length();
|
||||||
while (at_idx != -1 && i < len) {
|
while (at_idx != -1 && i < len) {
|
||||||
@ -376,7 +376,7 @@ bool ConverseGump::parse_token(MsgText *token) {
|
|||||||
if (!Common::isAlpha(c) || i == len - 1) {
|
if (!Common::isAlpha(c) || i == len - 1) {
|
||||||
token->s.erase(at_idx, 1);
|
token->s.erase(at_idx, 1);
|
||||||
i--;
|
i--;
|
||||||
at_idx = token->s.find_first_of('@', i);
|
at_idx = token->s.findFirstOf('@', i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -391,7 +391,7 @@ bool ConverseGump::parse_token(MsgText *token) {
|
|||||||
// Add FM-Towns keywords which take the form. +actor_numKeyword+ eg. +5runes+
|
// Add FM-Towns keywords which take the form. +actor_numKeyword+ eg. +5runes+
|
||||||
// Only add keyword if the player has met the actor given by the actor_num
|
// Only add keyword if the player has met the actor given by the actor_num
|
||||||
void ConverseGump::parse_fm_towns_token(MsgText *token) {
|
void ConverseGump::parse_fm_towns_token(MsgText *token) {
|
||||||
int at_idx = token->s.find_first_of('+', 0);
|
int at_idx = token->s.findFirstOf('+', 0);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int len = (int)token->s.length();
|
int len = (int)token->s.length();
|
||||||
bool has_met = false;
|
bool has_met = false;
|
||||||
@ -422,7 +422,7 @@ void ConverseGump::parse_fm_towns_token(MsgText *token) {
|
|||||||
if (!Common::isAlpha(ch) || i == len - 1) {
|
if (!Common::isAlpha(ch) || i == len - 1) {
|
||||||
token->s.erase(at_idx, (i - at_idx) + 1);
|
token->s.erase(at_idx, (i - at_idx) + 1);
|
||||||
i -= i - at_idx;
|
i -= i - at_idx;
|
||||||
at_idx = token->s.find_first_of('+', i);
|
at_idx = token->s.findFirstOf('+', i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -420,7 +420,7 @@ MsgText *MsgScroll::holding_buffer_get_token() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
i = input->s.find_first_of(" \t\n*<>`", 0);
|
i = input->s.findFirstOf(" \t\n*<>`", 0);
|
||||||
if (i == 0) i++;
|
if (i == 0) i++;
|
||||||
|
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
|
@ -484,7 +484,7 @@ void KeyBinder::ParseText(char *text, int len) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void skipspace(string &s) {
|
static void skipspace(string &s) {
|
||||||
size_t i = s.find_first_not_of(chardata.whitespace);
|
size_t i = s.findFirstNotOf(chardata.whitespace);
|
||||||
if (i && i != string::npos)
|
if (i && i != string::npos)
|
||||||
s.erase(0, i);
|
s.erase(0, i);
|
||||||
}
|
}
|
||||||
@ -525,7 +525,7 @@ void KeyBinder::ParseLine(char *line) {
|
|||||||
s.erase(0, 6);
|
s.erase(0, 6);
|
||||||
u.erase(0, 6);
|
u.erase(0, 6);
|
||||||
} else {
|
} else {
|
||||||
i = s.find_first_of(chardata.whitespace);
|
i = s.findFirstOf(chardata.whitespace);
|
||||||
|
|
||||||
keycode = s.substr(0, i);
|
keycode = s.substr(0, i);
|
||||||
s.erase(0, i);
|
s.erase(0, i);
|
||||||
@ -563,7 +563,7 @@ void KeyBinder::ParseLine(char *line) {
|
|||||||
// get function
|
// get function
|
||||||
skipspace(s);
|
skipspace(s);
|
||||||
|
|
||||||
i = s.find_first_of(chardata.whitespace);
|
i = s.findFirstOf(chardata.whitespace);
|
||||||
string t = s.substr(0, i);
|
string t = s.substr(0, i);
|
||||||
s.erase(0, i);
|
s.erase(0, i);
|
||||||
t = to_uppercase(t);
|
t = to_uppercase(t);
|
||||||
@ -581,7 +581,7 @@ void KeyBinder::ParseLine(char *line) {
|
|||||||
|
|
||||||
int np = 0;
|
int np = 0;
|
||||||
while (!s.empty() && s[0] != '#' && np < c_maxparams) {
|
while (!s.empty() && s[0] != '#' && np < c_maxparams) {
|
||||||
i = s.find_first_of(chardata.whitespace);
|
i = s.findFirstOf(chardata.whitespace);
|
||||||
string tmp = s.substr(0, i);
|
string tmp = s.substr(0, i);
|
||||||
s.erase(0, i);
|
s.erase(0, i);
|
||||||
skipspace(s);
|
skipspace(s);
|
||||||
|
@ -41,15 +41,15 @@ void Tokenise(const Std::string &str, Std::vector<Std::string> &tokens, char del
|
|||||||
Std::string delimiters(delimiter);
|
Std::string delimiters(delimiter);
|
||||||
|
|
||||||
// Skip delimiters at beginning.
|
// Skip delimiters at beginning.
|
||||||
string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
string::size_type lastPos = str.findFirstNotOf(delimiters, 0);
|
||||||
|
|
||||||
for (string::size_type pos = str.find_first_of(delimiters, lastPos) ;
|
for (string::size_type pos = str.findFirstOf(delimiters, lastPos) ;
|
||||||
string::npos != pos || string::npos != lastPos ;
|
string::npos != pos || string::npos != lastPos ;
|
||||||
pos = str.find_first_of(delimiters, lastPos)) {
|
pos = str.findFirstOf(delimiters, lastPos)) {
|
||||||
// Found a token, add it to the vector.
|
// Found a token, add it to the vector.
|
||||||
tokens.push_back(str.substr(lastPos, pos - lastPos));
|
tokens.push_back(str.substr(lastPos, pos - lastPos));
|
||||||
// Skip delimiters. Note the "not_of"
|
// Skip delimiters. Note the "not_of"
|
||||||
lastPos = str.find_first_not_of(delimiters, pos);
|
lastPos = str.findFirstNotOf(delimiters, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1382,7 +1382,7 @@ void ScriptCutscene::print_text(CSImage *image, const char *s, uint16 *x, uint16
|
|||||||
int space_width = font->getStringWidth(" ");
|
int space_width = font->getStringWidth(" ");
|
||||||
//uint16 x1 = startx;
|
//uint16 x1 = startx;
|
||||||
|
|
||||||
found = str.find_first_of(" ", start);
|
found = str.findFirstOf(" ", start);
|
||||||
while (found != string::npos) {
|
while (found != string::npos) {
|
||||||
Std::string token = str.substr(start, found - start);
|
Std::string token = str.substr(start, found - start);
|
||||||
|
|
||||||
@ -1410,7 +1410,7 @@ void ScriptCutscene::print_text(CSImage *image, const char *s, uint16 *x, uint16
|
|||||||
}
|
}
|
||||||
|
|
||||||
start = found + 1;
|
start = found + 1;
|
||||||
found = str.find_first_of(" ", start);
|
found = str.findFirstOf(" ", start);
|
||||||
}
|
}
|
||||||
|
|
||||||
list<Std::string>::iterator it;
|
list<Std::string>::iterator it;
|
||||||
@ -1613,14 +1613,14 @@ void ScriptCutscene::display_wrapped_text(CSSprite *s) {
|
|||||||
|
|
||||||
Std::string line = "";
|
Std::string line = "";
|
||||||
|
|
||||||
found = str.find_first_of("^", start);
|
found = str.findFirstOf("^", start);
|
||||||
while (found != string::npos) {
|
while (found != string::npos) {
|
||||||
Std::string token = str.substr(start, found - start);
|
Std::string token = str.substr(start, found - start);
|
||||||
|
|
||||||
y = display_wrapped_text_line(token, text_color, s->x, y, s->text_align);
|
y = display_wrapped_text_line(token, text_color, s->x, y, s->text_align);
|
||||||
|
|
||||||
start = found + 1;
|
start = found + 1;
|
||||||
found = str.find_first_of("^", start);
|
found = str.findFirstOf("^", start);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1640,7 +1640,7 @@ int ScriptCutscene::display_wrapped_text_line(Std::string str, uint8 text_color,
|
|||||||
|
|
||||||
Std::string line = "";
|
Std::string line = "";
|
||||||
|
|
||||||
found = str.find_first_of(" ", start);
|
found = str.findFirstOf(" ", start);
|
||||||
while (found != string::npos) {
|
while (found != string::npos) {
|
||||||
Std::string token = str.substr(start, found - start);
|
Std::string token = str.substr(start, found - start);
|
||||||
|
|
||||||
@ -1660,7 +1660,7 @@ int ScriptCutscene::display_wrapped_text_line(Std::string str, uint8 text_color,
|
|||||||
line = line + token + " ";
|
line = line + token + " ";
|
||||||
|
|
||||||
start = found + 1;
|
start = found + 1;
|
||||||
found = str.find_first_of(" ", start);
|
found = str.findFirstOf(" ", start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
|
@ -101,23 +101,23 @@ void MusicFlex::loadSongInfo() {
|
|||||||
Std::string::size_type begIdx, endIdx;
|
Std::string::size_type begIdx, endIdx;
|
||||||
|
|
||||||
// Find the first not space, which will get us the name
|
// Find the first not space, which will get us the name
|
||||||
begIdx = line.find_first_not_of(' ');
|
begIdx = line.findFirstNotOf(' ');
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
Std::string name = line.substr(begIdx, endIdx - begIdx);
|
Std::string name = line.substr(begIdx, endIdx - begIdx);
|
||||||
|
|
||||||
// Now find the first not space after the name, which will get us the num
|
// Now find the first not space after the name, which will get us the num
|
||||||
begIdx = line.find_first_not_of(' ', endIdx);
|
begIdx = line.findFirstNotOf(' ', endIdx);
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
int num = line.at(begIdx);
|
int num = line.at(begIdx);
|
||||||
|
|
||||||
// Now number of measures
|
// Now number of measures
|
||||||
begIdx = line.find_first_not_of(' ', endIdx);
|
begIdx = line.findFirstNotOf(' ', endIdx);
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
int measures = Std::atoi(line.substr(begIdx, endIdx - begIdx).c_str());
|
int measures = Std::atoi(line.substr(begIdx, endIdx - begIdx).c_str());
|
||||||
|
|
||||||
// Now finally loop_jump
|
// Now finally loop_jump
|
||||||
begIdx = line.find_first_not_of(' ', endIdx);
|
begIdx = line.findFirstNotOf(' ', endIdx);
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
int loop_jump = Std::atoi(line.substr(begIdx, endIdx - begIdx).c_str());
|
int loop_jump = Std::atoi(line.substr(begIdx, endIdx - begIdx).c_str());
|
||||||
|
|
||||||
// Uh oh
|
// Uh oh
|
||||||
@ -161,13 +161,13 @@ void MusicFlex::loadSongInfo() {
|
|||||||
Std::string::size_type begIdx, endIdx;
|
Std::string::size_type begIdx, endIdx;
|
||||||
|
|
||||||
// Get 'from' name
|
// Get 'from' name
|
||||||
begIdx = line.find_first_not_of(' ');
|
begIdx = line.findFirstNotOf(' ');
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
Std::string from = line.substr(begIdx, endIdx - begIdx);
|
Std::string from = line.substr(begIdx, endIdx - begIdx);
|
||||||
|
|
||||||
// Get 'to' name
|
// Get 'to' name
|
||||||
begIdx = line.find_first_not_of(' ', endIdx);
|
begIdx = line.findFirstNotOf(' ', endIdx);
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
Std::string to = line.substr(begIdx, endIdx - begIdx);
|
Std::string to = line.substr(begIdx, endIdx - begIdx);
|
||||||
|
|
||||||
// Find index of from name
|
// Find index of from name
|
||||||
@ -194,8 +194,8 @@ void MusicFlex::loadSongInfo() {
|
|||||||
// Now attempt to read the trans info for the
|
// Now attempt to read the trans info for the
|
||||||
for (int m = 0; m < info[fi]->num_measures; m++) {
|
for (int m = 0; m < info[fi]->num_measures; m++) {
|
||||||
// Get trans info name
|
// Get trans info name
|
||||||
begIdx = line.find_first_not_of(' ', endIdx);
|
begIdx = line.findFirstNotOf(' ', endIdx);
|
||||||
endIdx = line.find_first_of(' ', begIdx);
|
endIdx = line.findFirstOf(' ', begIdx);
|
||||||
|
|
||||||
if (begIdx == Std::string::npos)
|
if (begIdx == Std::string::npos)
|
||||||
error("Invalid Section 4 song info data. Unable to read transitions for all measures");
|
error("Invalid Section 4 song info data. Unable to read transitions for all measures");
|
||||||
|
@ -63,10 +63,10 @@ int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
|
|||||||
Std::string text = phrase.substr(start);
|
Std::string text = phrase.substr(start);
|
||||||
Pentagram::TabsToSpaces(text, 1);
|
Pentagram::TabsToSpaces(text, 1);
|
||||||
|
|
||||||
Std::string::size_type pos1 = text.find_first_not_of(' ');
|
Std::string::size_type pos1 = text.findFirstNotOf(' ');
|
||||||
if (pos1 == Std::string::npos) return 0;
|
if (pos1 == Std::string::npos) return 0;
|
||||||
|
|
||||||
Std::string::size_type pos2 = text.find_last_not_of(' ');
|
Std::string::size_type pos2 = text.findLastNotOf(' ');
|
||||||
text = text.substr(pos1, pos2 - pos1 + 1);
|
text = text.substr(pos1, pos2 - pos1 + 1);
|
||||||
|
|
||||||
// pout << "Looking for string: \"" << text << "\"" << Std::endl;
|
// pout << "Looking for string: \"" << text << "\"" << Std::endl;
|
||||||
|
@ -98,7 +98,7 @@ bool INIFile::readConfigFile(string fname) {
|
|||||||
string sbuf, line;
|
string sbuf, line;
|
||||||
while (!f->eof()) {
|
while (!f->eof()) {
|
||||||
f->readline(line);
|
f->readline(line);
|
||||||
string::size_type pos = line.find_first_of("\n\r");
|
string::size_type pos = line.findFirstOf("\n\r");
|
||||||
if (pos != string::npos) {
|
if (pos != string::npos) {
|
||||||
sbuf += line.substr(0, pos) + "\n";
|
sbuf += line.substr(0, pos) + "\n";
|
||||||
} else {
|
} else {
|
||||||
@ -118,7 +118,7 @@ bool INIFile::readConfigFile(string fname) {
|
|||||||
|
|
||||||
|
|
||||||
static void rtrim(string &s) {
|
static void rtrim(string &s) {
|
||||||
string::size_type pos = s.find_last_not_of(" \t");
|
string::size_type pos = s.findLastNotOf(" \t");
|
||||||
if (pos != string::npos) {
|
if (pos != string::npos) {
|
||||||
if (pos + 1 < s.size())
|
if (pos + 1 < s.size())
|
||||||
s.erase(pos + 1);
|
s.erase(pos + 1);
|
||||||
@ -128,7 +128,7 @@ static void rtrim(string &s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void ltrim(string &s) {
|
static void ltrim(string &s) {
|
||||||
string::size_type pos = s.find_first_not_of(" \t");
|
string::size_type pos = s.findFirstNotOf(" \t");
|
||||||
if (pos != string::npos) {
|
if (pos != string::npos) {
|
||||||
if (pos > 0)
|
if (pos > 0)
|
||||||
s.erase(0, pos - 1);
|
s.erase(0, pos - 1);
|
||||||
|
@ -139,13 +139,13 @@ template void ArgvToString<Pentagram::istring>(const Std::vector<Pentagram::istr
|
|||||||
template<class T> void TrimSpaces(T &str) {
|
template<class T> void TrimSpaces(T &str) {
|
||||||
if (str.empty()) return;
|
if (str.empty()) return;
|
||||||
|
|
||||||
typename T::size_type pos1 = str.find_first_not_of(' ');
|
typename T::size_type pos1 = str.findFirstNotOf(' ');
|
||||||
if (pos1 == T::npos) {
|
if (pos1 == T::npos) {
|
||||||
str = "";
|
str = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename T::size_type pos2 = str.find_last_not_of(' ');
|
typename T::size_type pos2 = str.findLastNotOf(' ');
|
||||||
str = str.substr(pos1, pos2 - pos1 + 1);
|
str = str.substr(pos1, pos2 - pos1 + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user