mirror of https://github.com/kiwix/libkiwix.git
Add a string tool to join a list of strings together.
This commit is contained in:
parent
bd91e89785
commit
157c1c939c
|
@ -47,6 +47,7 @@ std::vector<std::string> split(const std::string&, const std::string&);
|
||||||
std::vector<std::string> split(const char*, const char*);
|
std::vector<std::string> split(const char*, const char*);
|
||||||
std::vector<std::string> split(const std::string&, const char*);
|
std::vector<std::string> split(const std::string&, const char*);
|
||||||
std::vector<std::string> split(const char*, const std::string&);
|
std::vector<std::string> split(const char*, const std::string&);
|
||||||
|
std::string join(const std::vector<std::string>& list, const std::string& sep);
|
||||||
|
|
||||||
std::string ucAll(const std::string& word);
|
std::string ucAll(const std::string& word);
|
||||||
std::string lcAll(const std::string& word);
|
std::string lcAll(const std::string& word);
|
||||||
|
|
|
@ -298,6 +298,21 @@ std::vector<std::string> kiwix::split(const std::string& lhs, const char* rhs)
|
||||||
return split(lhs.c_str(), rhs);
|
return split(lhs.c_str(), rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string kiwix::join(const std::vector<std::string>& list, const std::string& sep)
|
||||||
|
{
|
||||||
|
std::stringstream ss;
|
||||||
|
bool first = true;
|
||||||
|
for (auto& s:list) {
|
||||||
|
if (first) {
|
||||||
|
ss << sep;
|
||||||
|
first = false;
|
||||||
|
}
|
||||||
|
ss << s;
|
||||||
|
}
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string kiwix::ucFirst(const std::string& word)
|
std::string kiwix::ucFirst(const std::string& word)
|
||||||
{
|
{
|
||||||
if (word.empty()) {
|
if (word.empty()) {
|
||||||
|
|
Loading…
Reference in New Issue