summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-24 09:33:49 +0100
committerspag <spag@golwen.net>2013-02-24 09:33:49 +0100
commitab22563c3206fc3d986495214a57f29f26761b36 (patch)
treefcdbcd8f4188c9257345d62a801160b0cf7be967 /misc
parentc77dc2aaa3c5299b17c9b6d022d1e316c9d61a59 (diff)
table functions
Diffstat (limited to 'misc')
-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