]> git.tdb.fi Git - libs/core.git/blobdiff - source/strings/utils.cpp
Add some utility functions for joining strings
[libs/core.git] / source / strings / utils.cpp
index 416188ec3d574e71caaecf2fa4353eaff8f67564..80e59f07a6cb5802eb741aa870a0498e2308fea0 100644 (file)
@@ -130,6 +130,20 @@ string strip(const string &s)
        return result;
 }
 
+string &append(string &str, const string &sep, const string &other)
+{
+       if(!str.empty() && !other.empty())
+               str += sep;
+       str += other;
+       return str;
+}
+
+string join(const string &str1, const string &sep, const string &str2)
+{
+       string result = str1;
+       return append(result, sep, str2);
+}
+
 string c_unescape(const std::string &str)
 {
        bool escape = false;