mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Switched to a new coding style, which plays nicely with the Reader/Writer. This new style allows REFLECT to be used instead of REFLECT_N in most places.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@15 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+20
-3
@@ -52,7 +52,7 @@ String trim(const String& s){
|
||||
}
|
||||
}
|
||||
|
||||
String trimLeft(const String& s) {
|
||||
String trim_left(const String& s) {
|
||||
size_t start = s.find_first_not_of(_(' '));
|
||||
if (start == String::npos) {
|
||||
return String();
|
||||
@@ -63,7 +63,7 @@ String trimLeft(const String& s) {
|
||||
|
||||
// ----------------------------------------------------------------------------- : Words
|
||||
|
||||
String lastWord(const String& s) {
|
||||
String last_word(const String& s) {
|
||||
size_t endLastWord = s.find_last_not_of(_(' '));
|
||||
size_t startLastWord = s.find_last_of( _(' '), endLastWord);
|
||||
if (endLastWord == String::npos) {
|
||||
@@ -75,7 +75,7 @@ String lastWord(const String& s) {
|
||||
}
|
||||
}
|
||||
|
||||
String stripLastWord(const String& s) {
|
||||
String strip_last_word(const String& s) {
|
||||
size_t endLastWord = s.find_last_not_of(_(' '));
|
||||
size_t startLastWord = s.find_last_of(_(' '), endLastWord);
|
||||
if (endLastWord == String::npos || startLastWord == String::npos) {
|
||||
@@ -116,3 +116,20 @@ String capitalize(const String& s) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
String cannocial_name_form(const String& str) {
|
||||
String ret;
|
||||
ret.reserve(str.size());
|
||||
bool leading = true;
|
||||
FOR_EACH_CONST(c, str) {
|
||||
if ((c == _('_') || c == _(' ')) && !leading) {
|
||||
ret += _('_');
|
||||
} else if (isAlnum(c)) {
|
||||
ret += toLower(c);
|
||||
leading = false;
|
||||
} else {
|
||||
// ignore non alpha numeric
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user