2011-10-02 10:05:45 +00:00
|
|
|
#ifdef NALL_STRING_INTERNAL_HPP
|
2010-08-09 13:28:56 +00:00
|
|
|
|
|
|
|
namespace nall {
|
|
|
|
|
|
|
|
char chrlower(char c) {
|
|
|
|
return (c >= 'A' && c <= 'Z') ? c + ('a' - 'A') : c;
|
|
|
|
}
|
|
|
|
|
|
|
|
char chrupper(char c) {
|
|
|
|
return (c >= 'a' && c <= 'z') ? c - ('a' - 'A') : c;
|
|
|
|
}
|
|
|
|
|
2011-08-06 14:03:52 +00:00
|
|
|
int istrcmp(const char *str1, const char *str2) {
|
2010-10-14 10:07:38 +00:00
|
|
|
while(*str1) {
|
|
|
|
if(chrlower(*str1) != chrlower(*str2)) break;
|
|
|
|
str1++, str2++;
|
2010-08-09 13:28:56 +00:00
|
|
|
}
|
2010-10-14 10:07:38 +00:00
|
|
|
return (int)chrlower(*str1) - (int)chrlower(*str2);
|
Update to v070r14 release.
(there was no r13 release posted to the WIP thread)
byuu says:
- nall/string: trim and split functions now take the limit as a template
parameter for clarity, trim_once variants are removed
- quotable.trim<1>("\""); //remove quotes from string
- cheatcode.split<3>(","); //split up to three times, third one is
a description that may have commas
- foobar.trim(" "); //remove any and all spaces
- nall/string: added wildcard() and iwildcard() functions for pattern
matching
- nall/directory: accepts an optional pattern parameter to perform
wildcard matching
- lstring cartridges = directory::contents(path, "*.sfc");
- some people may prefer directory::contents("/path/to/files/*.sfc"),
but I like not having to build a string when you have the path
separated already
- nall/qt: removed entirely, now resides in bsnes/ui-qt/template; I do
intend to replace the check/radio actions with native Qt versions
later
- bsnes/data: new folder, share the parts that both UIs use; bsnes.ico,
bsnes.png, bsnes.Desktop, cheats.xml; simplify Makefile install target
- Makefile: install target now creates .bsnes folder and copies
cheats.xml there for you
- Makefile: gconftool hack removed, not needed for phoenix, will work
around with Qt later
- will probably make bsnes/Qt read the cheats.xml file externally as
well, as that file makes each profile 1MB bigger when embedded
- as such, will probably make bsnes also look in the binary directory
for that file, so Windows users don't have to copy it to their
userdata folder
2010-10-11 10:39:14 +00:00
|
|
|
}
|
|
|
|
|
2010-08-09 13:28:56 +00:00
|
|
|
bool strbegin(const char *str, const char *key) {
|
|
|
|
int i, ssl = strlen(str), ksl = strlen(key);
|
|
|
|
|
|
|
|
if(ksl > ssl) return false;
|
|
|
|
return (!memcmp(str, key, ksl));
|
|
|
|
}
|
|
|
|
|
2011-08-06 14:03:52 +00:00
|
|
|
bool istrbegin(const char *str, const char *key) {
|
2010-08-09 13:28:56 +00:00
|
|
|
int ssl = strlen(str), ksl = strlen(key);
|
|
|
|
|
|
|
|
if(ksl > ssl) return false;
|
|
|
|
for(int i = 0; i < ksl; i++) {
|
|
|
|
if(str[i] >= 'A' && str[i] <= 'Z') {
|
|
|
|
if(str[i] != key[i] && str[i]+0x20 != key[i])return false;
|
|
|
|
} else if(str[i] >= 'a' && str[i] <= 'z') {
|
|
|
|
if(str[i] != key[i] && str[i]-0x20 != key[i])return false;
|
|
|
|
} else {
|
|
|
|
if(str[i] != key[i])return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool strend(const char *str, const char *key) {
|
|
|
|
int ssl = strlen(str), ksl = strlen(key);
|
|
|
|
|
|
|
|
if(ksl > ssl) return false;
|
|
|
|
return (!memcmp(str + ssl - ksl, key, ksl));
|
|
|
|
}
|
|
|
|
|
2011-08-06 14:03:52 +00:00
|
|
|
bool istrend(const char *str, const char *key) {
|
2010-08-09 13:28:56 +00:00
|
|
|
int ssl = strlen(str), ksl = strlen(key);
|
|
|
|
|
|
|
|
if(ksl > ssl) return false;
|
|
|
|
for(int i = ssl - ksl, z = 0; i < ssl; i++, z++) {
|
|
|
|
if(str[i] >= 'A' && str[i] <= 'Z') {
|
|
|
|
if(str[i] != key[z] && str[i]+0x20 != key[z])return false;
|
|
|
|
} else if(str[i] >= 'a' && str[i] <= 'z') {
|
|
|
|
if(str[i] != key[z] && str[i]-0x20 != key[z])return false;
|
|
|
|
} else {
|
|
|
|
if(str[i] != key[z])return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|