summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/common/str.lua
diff options
context:
space:
mode:
authorStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-27 12:22:29 +0100
committerStefan Wintermeyer <stefan.wintermeyer@amooma.de>2013-02-27 12:22:29 +0100
commit67c1a0a951403a546250ea860a3e3d199cae2fce (patch)
treef86ec6cedf081a1a57005eca1661e9bead34e4de /misc/freeswitch/scripts/common/str.lua
parent5d8ce5f4775ac8bc5f523964e6e36f63ff3c4683 (diff)
parent211f558a86ae30cdd5b392ab1376e1393f97e22c (diff)
Merge branch 'develop'5.1-beta6
Diffstat (limited to 'misc/freeswitch/scripts/common/str.lua')
-rw-r--r--misc/freeswitch/scripts/common/str.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/common/str.lua b/misc/freeswitch/scripts/common/str.lua
index 72ff388..541199f 100644
--- a/misc/freeswitch/scripts/common/str.lua
+++ b/misc/freeswitch/scripts/common/str.lua
@@ -146,3 +146,37 @@ end
function blank(value)
return (value == nil or to_s(value) == '');
end
+
+-- concatenate string to buffer
+function append(buffer, value, separator, prefix, suffix)
+ separator = separator or '';
+ prefix = prefix or '';
+ suffix = suffix or '';
+ if buffer ~= '' then
+ buffer = buffer .. separator .. prefix .. value .. suffix;
+ else
+ buffer = prefix .. value .. suffix;
+ end
+
+ return buffer;
+end
+
+-- concatenate array values to string
+function concat(array, separator, prefix, suffix)
+ local buffer = '';
+ for key, value in pairs(array) do
+ buffer = append(buffer, value, separator, prefix, suffix);
+ end
+
+ return buffer;
+end
+
+-- concatenate array keys to string
+function concat_keys(array, separator, prefix, suffix)
+ local buffer = '';
+ for key, value in pairs(array) do
+ buffer = append(buffer, key, separator, prefix, suffix);
+ end
+
+ return buffer;
+end