Module cDocument

Create lightweight classes with import/export features .

#

For the cDocument to work, you need to define a static DOC_PROPS property. You can define integers, floating point values, strings and booleans

MyClass.DOC_PROPS = { { name = "my_integer", -- class/property name title = "IntegerValue", -- display name value_min = 1, -- only for numbers value_max = 12, -- -//- value_quantum = 1, -- -//- value_default = 4, -- always define this!! }, { name = "my_float", title = "A floating point value between 0-1", value_min = 0, value_max = 1, value_default = 0.0, }, }

FIXME * Re-implement as ipairs (changed implementation)

Functions

import (str) import serialized values that match one of our DOC_PROPS
export ()
serialize (obj, props) collect properties from object
deserialize (str, props) deserialize string
get_property (props, key) find property descriptor by key
apply_value (obj, prop, val) apply value to object * will clamp/cast value when outside range / wrong type


Functions

import (str)
import serialized values that match one of our DOC_PROPS

Parameters:

  • str (string) serialized values

Returns:

    string, serialized values
export ()

Returns:

    string, serialized values
serialize (obj, props)
collect properties from object

Parameters:

  • obj (class instance)
  • props (table) DOC_PROPS

Returns:

    table
deserialize (str, props)
deserialize string

Parameters:

  • str (str) serialized string
  • props (table) DOC_PROPS

Returns:

    table or nil
get_property (props, key)
find property descriptor by key

Parameters:

  • props
  • key

Returns:

    table or nil
apply_value (obj, prop, val)
apply value to object * will clamp/cast value when outside range / wrong type

Parameters:

  • obj
  • prop
  • val

Returns:

    value (boolean,string,number)
generated by LDoc 1.4.2