Engine 0.0.4
Game engine in lua
Loading...
Searching...
No Matches
rodrigodornelles.lua
Go to the documentation of this file.
1local function decode(in_str, out_table)
2 local index1 = 1
3 local headers = {}
4 local pattern = '[^,]+'
5 local next_line = in_str:gmatch('([^\r\n]*)\r?\n?')
6 local line = next_line()
7 local next_header = line:gmatch(pattern)
8
9 repeat
10 local header = next_header()
11 headers[index1] = header
12 index1 = index1 + 1
13 until not header
14
15 local index2 = 1
16 repeat
17 line = next_line()
18 if line then
19 local next_value = line:gmatch(pattern)
20 index1 = 1
21 repeat
22 local value = next_value()
23 local header = headers[index1]
24 if header and value and not out_table[index2] then
25 out_table[index2] = {}
26 end
27 if header and value then
28 out_table[index2][header] = value
29 end
30 index1 = index1 + 1
31 until not value
32 end
33 index2 = index2 + 1
34 until not line
35end
36
37local P = {
39 encode=function() error('not implemented!') end
40}
41
42return P
local function decode(in_str, out_table)
local function header(self, name, value)
local function error(self, handler_func)
local function line(x1, y1, x2, y2)