mirror of
https://github.com/eosswedenorg/antelope-keygen
synced 2026-07-04 12:03:41 +02:00
string: adding strjoin() function
This commit is contained in:
parent
4f4444a62a
commit
5bc3335d54
2 changed files with 17 additions and 0 deletions
|
|
@ -46,6 +46,21 @@ strlist_t strsplit(const std::string& str, const std::string& delim) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string strjoin(const strlist_t& list, const std::string& delim) {
|
||||||
|
|
||||||
|
std::string out;
|
||||||
|
|
||||||
|
for(const std::string& item : list) {
|
||||||
|
out += item + delim;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (out.length() > 0) {
|
||||||
|
out.erase(out.end() - delim.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
std::string& strtolower(std::string& str) {
|
std::string& strtolower(std::string& str) {
|
||||||
std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){ return std::tolower(c); });
|
std::transform(str.begin(), str.end(), str.begin(), [](unsigned char c){ return std::tolower(c); });
|
||||||
return str;
|
return str;
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,8 @@ strlist_t strsplitwords(const std::string& str, const std::string& delim = ",");
|
||||||
|
|
||||||
strlist_t strsplit(const std::string& str, const std::string& delim);
|
strlist_t strsplit(const std::string& str, const std::string& delim);
|
||||||
|
|
||||||
|
std::string strjoin(const strlist_t& list, const std::string& delim);
|
||||||
|
|
||||||
std::string& strtolower(std::string& str);
|
std::string& strtolower(std::string& str);
|
||||||
|
|
||||||
std::string& rtrim(std::string& str);
|
std::string& rtrim(std::string& str);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue