COMMON: Change recently added string methods to be camelcase

This commit is contained in:
Paul Gilbert 2020-01-29 18:03:27 -08:00 committed by Paul Gilbert
parent fda0c1a756
commit f972d68ae2
12 changed files with 59 additions and 59 deletions

View File

@ -732,12 +732,12 @@ size_t String::rfind(char c, size_t pos) const {
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);
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) {
if (strchr(chars, (*this)[idx]))
return idx;
@ -746,7 +746,7 @@ size_t String::find_first_of(const char *chars, size_t pos) const {
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) {
if ((*this)[idx] != c)
return idx;
@ -755,7 +755,7 @@ size_t String::find_first_not_of(char c, size_t pos) const {
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) {
if (!strchr(chars, (*this)[idx]))
return idx;
@ -764,7 +764,7 @@ size_t String::find_first_not_of(const char *chars, size_t pos) const {
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) {
if ((*this)[idx] != c)
return c;
@ -773,7 +773,7 @@ size_t String::find_last_not_of(char c) const {
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) {
if (!strchr(chars, (*this)[idx]))
return idx;

View File

@ -324,30 +324,30 @@ public:
size_t rfind(char c, size_t pos = npos) const;
/** 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 */
size_t find_first_of(const char *chars, size_t pos = 0) const;
size_t find_first_of(const String &chars, size_t pos = 0) const {
return find_first_of(chars.c_str(), pos);
size_t findFirstOf(const char *chars, size_t pos = 0) const;
size_t findFirstOf(const String &chars, size_t pos = 0) const {
return findFirstOf(chars.c_str(), pos);
}
/** 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 */
size_t find_first_not_of(const char *chars, size_t pos = 0) const;
size_t find_first_not_of(const String &chars, size_t pos = 0) const {
return find_first_not_of(chars.c_str(), pos);
size_t findFirstNotOf(const char *chars, size_t pos = 0) const;
size_t findFirstNotOf(const String &chars, size_t pos = 0) const {
return findFirstNotOf(chars.c_str(), pos);
}
/** 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 */
size_t find_last_not_of(const char *chars) const;
size_t find_last_not_of(const String &chars) const {
return find_last_not_of(chars.c_str());
size_t findLastNotOf(const char *chars) const;
size_t findLastNotOf(const String &chars) const {
return findLastNotOf(chars.c_str());
}
/** Return a substring of this string */

View File

@ -205,7 +205,7 @@ static string encode_entity(const string &s) {
static string decode_entity(const string &s, size_t &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
inside a &...; expression is 'good', valid though it may be. */

View File

@ -362,7 +362,7 @@ Std::string ConverseGump::strip_whitespace_after_break(Std::string s) {
}
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 len = (int)token->s.length();
while (at_idx != -1 && i < len) {
@ -376,7 +376,7 @@ bool ConverseGump::parse_token(MsgText *token) {
if (!Common::isAlpha(c) || i == len - 1) {
token->s.erase(at_idx, 1);
i--;
at_idx = token->s.find_first_of('@', i);
at_idx = token->s.findFirstOf('@', i);
break;
}
}
@ -391,7 +391,7 @@ bool ConverseGump::parse_token(MsgText *token) {
// 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
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 len = (int)token->s.length();
bool has_met = false;
@ -422,7 +422,7 @@ void ConverseGump::parse_fm_towns_token(MsgText *token) {
if (!Common::isAlpha(ch) || i == len - 1) {
token->s.erase(at_idx, (i - at_idx) + 1);
i -= i - at_idx;
at_idx = token->s.find_first_of('+', i);
at_idx = token->s.findFirstOf('+', i);
break;
}
}

View File

@ -420,7 +420,7 @@ MsgText *MsgScroll::holding_buffer_get_token() {
return NULL;
}
i = input->s.find_first_of(" \t\n*<>`", 0);
i = input->s.findFirstOf(" \t\n*<>`", 0);
if (i == 0) i++;
if (i == -1)

View File

@ -484,7 +484,7 @@ void KeyBinder::ParseText(char *text, int len) {
}
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)
s.erase(0, i);
}
@ -525,7 +525,7 @@ void KeyBinder::ParseLine(char *line) {
s.erase(0, 6);
u.erase(0, 6);
} else {
i = s.find_first_of(chardata.whitespace);
i = s.findFirstOf(chardata.whitespace);
keycode = s.substr(0, i);
s.erase(0, i);
@ -563,7 +563,7 @@ void KeyBinder::ParseLine(char *line) {
// get function
skipspace(s);
i = s.find_first_of(chardata.whitespace);
i = s.findFirstOf(chardata.whitespace);
string t = s.substr(0, i);
s.erase(0, i);
t = to_uppercase(t);
@ -581,7 +581,7 @@ void KeyBinder::ParseLine(char *line) {
int np = 0;
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);
s.erase(0, i);
skipspace(s);

View File

@ -41,15 +41,15 @@ void Tokenise(const Std::string &str, Std::vector<Std::string> &tokens, char del
Std::string delimiters(delimiter);
// 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 ;
pos = str.find_first_of(delimiters, lastPos)) {
pos = str.findFirstOf(delimiters, lastPos)) {
// Found a token, add it to the vector.
tokens.push_back(str.substr(lastPos, pos - lastPos));
// Skip delimiters. Note the "not_of"
lastPos = str.find_first_not_of(delimiters, pos);
lastPos = str.findFirstNotOf(delimiters, pos);
}
}

View File

@ -1382,7 +1382,7 @@ void ScriptCutscene::print_text(CSImage *image, const char *s, uint16 *x, uint16
int space_width = font->getStringWidth(" ");
//uint16 x1 = startx;
found = str.find_first_of(" ", start);
found = str.findFirstOf(" ", start);
while (found != string::npos) {
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;
found = str.find_first_of(" ", start);
found = str.findFirstOf(" ", start);
}
list<Std::string>::iterator it;
@ -1613,14 +1613,14 @@ void ScriptCutscene::display_wrapped_text(CSSprite *s) {
Std::string line = "";
found = str.find_first_of("^", start);
found = str.findFirstOf("^", start);
while (found != string::npos) {
Std::string token = str.substr(start, found - start);
y = display_wrapped_text_line(token, text_color, s->x, y, s->text_align);
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 = "";
found = str.find_first_of(" ", start);
found = str.findFirstOf(" ", start);
while (found != string::npos) {
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 + " ";
start = found + 1;
found = str.find_first_of(" ", start);
found = str.findFirstOf(" ", start);
}
if (len > 0) {

View File

@ -101,23 +101,23 @@ void MusicFlex::loadSongInfo() {
Std::string::size_type begIdx, endIdx;
// Find the first not space, which will get us the name
begIdx = line.find_first_not_of(' ');
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ');
endIdx = line.findFirstOf(' ', begIdx);
Std::string name = line.substr(begIdx, endIdx - begIdx);
// Now find the first not space after the name, which will get us the num
begIdx = line.find_first_not_of(' ', endIdx);
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ', endIdx);
endIdx = line.findFirstOf(' ', begIdx);
int num = line.at(begIdx);
// Now number of measures
begIdx = line.find_first_not_of(' ', endIdx);
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ', endIdx);
endIdx = line.findFirstOf(' ', begIdx);
int measures = Std::atoi(line.substr(begIdx, endIdx - begIdx).c_str());
// Now finally loop_jump
begIdx = line.find_first_not_of(' ', endIdx);
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ', endIdx);
endIdx = line.findFirstOf(' ', begIdx);
int loop_jump = Std::atoi(line.substr(begIdx, endIdx - begIdx).c_str());
// Uh oh
@ -161,13 +161,13 @@ void MusicFlex::loadSongInfo() {
Std::string::size_type begIdx, endIdx;
// Get 'from' name
begIdx = line.find_first_not_of(' ');
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ');
endIdx = line.findFirstOf(' ', begIdx);
Std::string from = line.substr(begIdx, endIdx - begIdx);
// Get 'to' name
begIdx = line.find_first_not_of(' ', endIdx);
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ', endIdx);
endIdx = line.findFirstOf(' ', begIdx);
Std::string to = line.substr(begIdx, endIdx - begIdx);
// Find index of from name
@ -194,8 +194,8 @@ void MusicFlex::loadSongInfo() {
// Now attempt to read the trans info for the
for (int m = 0; m < info[fi]->num_measures; m++) {
// Get trans info name
begIdx = line.find_first_not_of(' ', endIdx);
endIdx = line.find_first_of(' ', begIdx);
begIdx = line.findFirstNotOf(' ', endIdx);
endIdx = line.findFirstOf(' ', begIdx);
if (begIdx == Std::string::npos)
error("Invalid Section 4 song info data. Unable to read transitions for all measures");

View File

@ -63,10 +63,10 @@ int SpeechFlex::getIndexForPhrase(const Std::string &phrase,
Std::string text = phrase.substr(start);
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;
Std::string::size_type pos2 = text.find_last_not_of(' ');
Std::string::size_type pos2 = text.findLastNotOf(' ');
text = text.substr(pos1, pos2 - pos1 + 1);
// pout << "Looking for string: \"" << text << "\"" << Std::endl;

View File

@ -98,7 +98,7 @@ bool INIFile::readConfigFile(string fname) {
string sbuf, line;
while (!f->eof()) {
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) {
sbuf += line.substr(0, pos) + "\n";
} else {
@ -118,7 +118,7 @@ bool INIFile::readConfigFile(string fname) {
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 + 1 < s.size())
s.erase(pos + 1);
@ -128,7 +128,7 @@ static void rtrim(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 > 0)
s.erase(0, pos - 1);

View File

@ -139,13 +139,13 @@ template void ArgvToString<Pentagram::istring>(const Std::vector<Pentagram::istr
template<class T> void TrimSpaces(T &str) {
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) {
str = "";
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);
}