add char** overloads for join_string
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Fri, 9 Feb 2018 13:19:36 +0000 (14:19 +0100)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Thu, 2 Aug 2018 12:31:20 +0000 (14:31 +0200)
Add overloads to joing NULL-terminated arrays with
join_string().

src/stringfunc.cpp
src/stringfunc.hxx

index 3c8ce1a..72de728 100644 (file)
@@ -479,6 +479,30 @@ std::string join_string(
    return result;
 } // eo join_string(const std::vector< std::string >&,const std::string&)
 
+std::string join_string (
+   const char *const parts[], /* assumed NULL-terminated */
+   const std::string& delimiter
+)
+{
+   std::string result;
+
+   if (parts != NULL)
+   {
+       const char *const *cur = parts;
+
+       if (*cur != NULL) {
+           result = std::string (*cur);
+
+           while (*++cur != NULL) {
+               result += delimiter;
+               result += std::string (*cur);
+           }
+       }
+   }
+
+   return result;
+}
+
 
 
 /*
index 01d2882..6acfa32 100644 (file)
@@ -140,6 +140,11 @@ std::string join_string(
    const std::string& delimiter = "\n"
 );
 
+std::string join_string(
+   const char *const parts [],
+   const std::string& delimiter = "\n"
+);
+
 
 /*
 ** conversions: