From a88ce8071653ff4a20545eeb86059035f28d7443 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 5 Nov 2014 14:01:48 -0500 Subject: [PATCH] Add a stringVector join function for future use --- src/zm_utils.cpp | 11 +++++++++++ src/zm_utils.h | 2 ++ 2 files changed, 13 insertions(+) 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 );