summaryrefslogtreecommitdiff
path: root/src/KM_util.h
diff options
context:
space:
mode:
authorjhurst <jhurst@cinecert.com>2016-12-07 18:11:32 +0000
committerjhurst <>2016-12-07 18:11:32 +0000
commitdec4ef68baee633aac30f4b3e0aab6553c22f967 (patch)
treedc4f1bbdc6023604ec380393eebd1aebaae3236d /src/KM_util.h
parent74e6b1105dffe52c6f347d723507ab346eabbb5a (diff)
o Improved IMSC-1 profile detection. May not yet be perfect, experimentation
encouraged! o Refactored XML element & attribute visitation to KM_xml.h o Added km_join() template to KM_util.h
Diffstat (limited to 'src/KM_util.h')
-rwxr-xr-xsrc/KM_util.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/KM_util.h b/src/KM_util.h
index 4834891..e8004c1 100755
--- a/src/KM_util.h
+++ b/src/KM_util.h
@@ -543,6 +543,27 @@ namespace Kumu
// adjacent instances of the separator. E.g., "/foo//bar/" will return ["", "foo", "", "bar", ""].
std::list<std::string> km_token_split(const std::string& str, const std::string& separator);
+ // Join the tokens in the given list using delimiter. If prefix is defined then each token
+ // will be concatenated with the prefix before being added to the composite string.
+ template <class T>
+ std::string
+ km_join(const T& list, const std::string& delimiter, const std::string& prefix = "")
+ {
+ std::string result;
+
+ for ( typename T::const_iterator i = list.begin(); i != list.end(); ++i )
+ {
+ if ( i != list.begin() )
+ {
+ result += delimiter;
+ }
+
+ result += prefix + *i;
+ }
+
+ return result;
+ }
+
} // namespace Kumu