10 res.reserve(f.length());
11 for(
unsigned i = 0; i < f.length(); ++i) {
12 res.push_back(tolower(f[i]));
19 res.reserve(f.length());
20 for(
unsigned i = 0; i < f.length(); ++i) {
21 res.push_back(toupper(f[i]));
28 res.reserve(f.length());
29 for(
unsigned i = 0; i < f.length(); ++i) {
30 if(!isalpha(f[i]))
continue;
31 res.push_back(tolower(f[i]));
36 std::string
trim(
const std::string &s) {
39 for(
unsigned i = 0; i < s.length(); ++i) {
40 if(alpha && isspace(s[i]))
45 for(
int i = str.length() - 1; i >= 0; --i) {
54 return find(x.begin(), x.end(), v) != x.end();
57 bool startsWith(std::string x, std::string y,
bool caseInsensitive)
59 std::string z = x.substr(0, y.length());
65 std::vector<std::string>
split(
const std::string &s,
const std::string &sep)
67 std::vector<std::string> res;
69 int len = sep.length();
70 int remaining = s.length();
71 for(
int i = 0; i <= remaining - len; ++i) {
72 if(s_.substr(i, len) == sep) {
73 res.push_back(s_.substr(0, i));
74 s_ = s_.substr(i + sep.length());
75 remaining -= i + sep.length();
83 std::vector<std::string> &operator<<(std::vector<std::string> &x,
const char *v) {
88 std::vector<std::string>::iterator
find_ci(std::vector<std::string> &v,
const std::string &s) {
90 std::vector<std::string>::iterator it;
91 for(it = v.begin(); it != v.end(); ++it) {