File: lm_props.lua

package info (click to toggle)
crawl 2%3A0.34.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,204 kB
  • sloc: cpp: 363,900; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (31 lines) | stat: -rw-r--r-- 789 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
------------------------------------------------------------------------------
-- lm_props.lua:
-- Property markers.
------------------------------------------------------------------------------

util.defclass("PropertiesDescriptor")

function PropertiesDescriptor:new(properties)
  local pd = { }
  setmetatable(pd, self)
  pd.props = properties
  return pd
end

function PropertiesDescriptor:write(marker, th)
  lmark.marshall_table(th, self.props)
end

function PropertiesDescriptor:read(marker, th)
  self.props = lmark.unmarshall_table(th)
  setmetatable(self, PropertiesDescriptor)
  return self
end

function PropertiesDescriptor:property(marker, pname)
  return self.props and self.props[pname] or ''
end

function props_marker(props)
  return PropertiesDescriptor:new(props)
end