feat: add implode
This commit is contained in:
parent
7b6ce8fd67
commit
8b37af4632
@ -118,4 +118,18 @@ std::vector<std::string> split(const std::string &str, char delimiter)
|
|||||||
}
|
}
|
||||||
return parts;
|
return parts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string implode(const std::vector<std::string> &elements, const std::string &delimiter)
|
||||||
|
{
|
||||||
|
std::ostringstream stream;
|
||||||
|
for (size_t i = 0; i < elements.size(); ++i)
|
||||||
|
{
|
||||||
|
stream << elements[i];
|
||||||
|
if (i < elements.size() - 1)
|
||||||
|
{
|
||||||
|
stream << delimiter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
@ -12,5 +12,7 @@ std::string trim(const std::string &str);
|
|||||||
size_t findCorrespondingClosingBrace(const std::string &str, size_t openPos);
|
size_t findCorrespondingClosingBrace(const std::string &str, size_t openPos);
|
||||||
void removeEmptyLines(std::string &str);
|
void removeEmptyLines(std::string &str);
|
||||||
void removeComments(std::string &str);
|
void removeComments(std::string &str);
|
||||||
|
|
||||||
std::vector<std::string> split(const std::string &str, char delimiter);
|
std::vector<std::string> split(const std::string &str, char delimiter);
|
||||||
|
std::string implode(const std::vector<std::string> &elements, const std::string &delimiter);
|
||||||
} // namespace utils
|
} // namespace utils
|
||||||
Loading…
Reference in New Issue
Block a user