From f4f642a4d52e05e63417e6bfb019066ba0b8d44a Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 13 Apr 2018 11:35:42 +0200 Subject: [PATCH] Add utility method to join a vector of strings into a single string. --- include/linphone/utils/utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/include/linphone/utils/utils.h b/include/linphone/utils/utils.h index e13c89889..0714e9a06 100644 --- a/include/linphone/utils/utils.h +++ b/include/linphone/utils/utils.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -107,6 +108,15 @@ namespace Utils { return str ? str : ""; } + template + LINPHONE_PUBLIC std::string join (const std::vector& elems, const S& delim) { + std::stringstream ss; + auto e = elems.begin(); + ss << *e++; + for (; e != elems.end(); ++e) + ss << delim << *e; + return ss.str(); + } LINPHONE_PUBLIC std::string trim (const std::string &str); template