Commit 934be047 authored by Kirill Smelkov's avatar Kirill Smelkov

X move strings -> pygolang (there was a bug an implementation needed tests)

parent df371d3f
...@@ -163,57 +163,6 @@ error map_into(void *addr, size_t size, int prot, int flags, const os::File f, o ...@@ -163,57 +163,6 @@ error map_into(void *addr, size_t size, int prot, int flags, const os::File f, o
} // mm:: } // mm::
// strings::
namespace strings {
bool has_prefix(const string &s, const string &prefix) {
return s.compare(0, prefix.size(), prefix) == 0; // XXX -> pygolang + tests
}
bool has_prefix(const string &s, char prefix) {
return (s.size() >= 1 && s[0] == prefix);
}
bool has_suffix(const string &s, const string &suffix) {
return (s.size() >= suffix.size() &&
s.compare(s.size() - suffix.size(), suffix.size(), suffix));
}
bool has_suffix(const string &s, char suffix) {
return (s.size() >= 1 && s[s.size()-1] == suffix);
}
// XXX trim_prefix
string trim_suffix(const string &s, const string &suffix) {
if (!has_suffix(s, suffix))
return s;
return s.substr(0, s.size()-suffix.size());
}
string trim_suffix(const string &s, char suffix) {
if (!has_suffix(s, suffix))
return s;
return s.substr(0, s.size()-1);
}
vector<string> split(const string &s, char sep) {
vector<string> r;
int psep_prev=-1;
size_t psep;
while (1) {
psep = s.find(sep, psep_prev+1);
if (psep == string::npos)
return r;
r.push_back(s.substr(psep_prev+1, sep-(psep_prev+1)));
psep_prev = sep;
}
}
} // strings::
// xstrconv:: (strconv-like) // xstrconv:: (strconv-like)
namespace xstrconv { namespace xstrconv {
......
...@@ -127,23 +127,6 @@ namespace mm { ...@@ -127,23 +127,6 @@ namespace mm {
} // mm:: } // mm::
// strings::
namespace strings {
bool has_prefix(const string &s, const string &prefix);
bool has_prefix(const string &s, char prefix);
bool has_suffix(const string &s, const string &suffix);
bool has_suffix(const string &s, char suffix);
string trim_prefix(const string &s, const string &prefix);
string trim_prefix(const string &s, char prefix);
string trim_suffix(const string &s, const string &suffix);
string trim_suffix(const string &s, char suffix);
vector<string> split(const string &s, char sep);
} // strings::
// ---- misc ---- // ---- misc ----
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment