\r
require "erlparse";\r
-require "serialize";\r
\r
package.path = package.path ..";../?.lua";\r
+local serialize = require "util.serialization".serialize;
local st = require "util.stanza";\r
package.loaded["util.logger"] = {init = function() return function() end; end}\r
local dm = require "util.datamanager"\r
elseif tuple[1] == "xmlcdata" then\r
stanza:text(tuple[2]);\r
else\r
- error("unknown element type: "..serialize.serialize(tuple));\r
+ error("unknown element type: "..serialize(tuple));\r
end\r
end\r
function build_time(tuple)\r
count = count + 1;\r
local name = item[1];\r
t[name] = (t[name] or 0) + 1;\r
- --print(count, serialize.serialize(item));\r
+ --print(count, serialize(item));\r
if filters[name] then filters[name](item); end\r
end\r
---print(serialize.serialize(t));\r
+--print(serialize(t));\r
+++ /dev/null
--- Prosody IM v0.1
--- Copyright (C) 2008 Matthew Wild
--- Copyright (C) 2008 Waqas Hussain
---
--- This program is free software; you can redistribute it and/or
--- modify it under the terms of the GNU General Public License
--- as published by the Free Software Foundation; either version 2
--- of the License, or (at your option) any later version.
---
--- This program is distributed in the hope that it will be useful,
--- but WITHOUT ANY WARRANTY; without even the implied warranty of
--- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--- GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License
--- along with this program; if not, write to the Free Software
--- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
---
-
-
-\r
-local indent = function(i)\r
- return string.rep("\t", i);\r
-end\r
-local function basicSerialize (o)\r
- if type(o) == "number" or type(o) == "boolean" then\r
- return tostring(o);\r
- else -- assume it is a string -- FIXME make sure it's a string. throw an error otherwise.\r
- return (string.format("%q", tostring(o)):gsub("\\\n", "\\n"));\r
- end\r
-end\r
-local function _simplesave (o, ind, t)\r
- if type(o) == "number" then\r
- table.insert(t, tostring(o));\r
- elseif type(o) == "string" then\r
- table.insert(t, (string.format("%q", o):gsub("\\\n", "\\n")));\r
- elseif type(o) == "table" then\r
- table.insert(t, "{\n");\r
- for k,v in pairs(o) do\r
- table.insert(t, indent(ind));\r
- table.insert(t, "[");\r
- table.insert(t, basicSerialize(k));\r
- table.insert(t, "] = ");\r
- _simplesave(v, ind+1, t);\r
- table.insert(t, ",\n");\r
- end\r
- table.insert(t, indent(ind-1));\r
- table.insert(t, "}");\r
- elseif type(o) == "boolean" then\r
- table.insert(t, (o and "true" or "false"));\r
- else\r
- error("cannot serialize a " .. type(o))\r
- end\r
-end\r
-local t_concat = table.concat;\r
-\r
-module "serialize"\r
-\r
-function serialize(o)\r
- local t = {};\r
- _simplesave(o, 1, t);\r
- return t_concat(t);\r
-end\r
-\r
-return _M;\r