diff --git a/src/zm_utils.cpp b/src/zm_utils.cpp index 51beb377d..e0c65ca61 100644 --- a/src/zm_utils.cpp +++ b/src/zm_utils.cpp @@ -126,6 +126,17 @@ StringVector split( const std::string &string, const std::string chars, int limi return( stringVector ); } +const std::string join(const StringVector v, const char * delim ) { + std::stringstream ss; + + for(size_t i = 0; i < v.size(); ++i) { + if(i != 0) + ss << ","; + ss << v[i]; + } + return ss.str(); +} + const std::string base64Encode( const std::string &inString ) { static char base64_table[64] = { '\0' }; diff --git a/src/zm_utils.h b/src/zm_utils.h index 6536024a9..063c74b7d 100644 --- a/src/zm_utils.h +++ b/src/zm_utils.h @@ -23,6 +23,7 @@ #include #include #include +#include #include typedef std::vector StringVector; @@ -36,6 +37,7 @@ const std::string stringtf( const std::string &format, ... ); bool startsWith( const std::string &haystack, const std::string &needle ); StringVector split( const std::string &string, const std::string chars, int limit=0 ); +const std::string join( const StringVector, const char * ); const std::string base64Encode( const std::string &inString );