mirror of
https://github.com/OpenVPN/openvpn3.git
synced 2024-09-20 12:12:15 +02:00
Add the getJoinedString() function
Useful in unit tests for which the input vector should be properly sorted by the code under test. This function is very similar to getSortedJoinedString(), but it avoids sorting. Because of the similarity, the getSortedJoinedString() function is refactored to use the new getJoinedString() function. Signed-off-by: Mark Deric <jmark@openvpn.net>
This commit is contained in:
parent
98f5b59a07
commit
3cd0652d1e
@ -188,6 +188,20 @@ inline std::string getTempDirPath(const std::string& fn)
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Returns a string joined with the delimiter
|
||||
* @param r the array to join
|
||||
* @param delim the delimiter to use
|
||||
* @return A string joined by delim from the vector r
|
||||
*/
|
||||
template<class T>
|
||||
inline std::string getJoinedString(const std::vector<T>& r, const std::string& delim = "|")
|
||||
{
|
||||
std::stringstream s;
|
||||
std::copy(r.begin(), r.end(), std::ostream_iterator<std::string>(s, delim.c_str()));
|
||||
return s.str();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a sorted string join with the delimiter
|
||||
* This function modifes the input
|
||||
@ -199,9 +213,7 @@ template<class T>
|
||||
inline std::string getSortedJoinedString(std::vector<T>& r, const std::string& delim = "|")
|
||||
{
|
||||
std::sort(r.begin(), r.end());
|
||||
std::stringstream s;
|
||||
std::copy(r.begin(), r.end(), std::ostream_iterator<std::string>(s, delim.c_str()));
|
||||
return s.str();
|
||||
return getJoinedString(r, delim);
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
Loading…
Reference in New Issue
Block a user