Module jls.util.Struct
Provide Struct class.
Class Struct
Struct:new (structDef[, byteOrder]) | Creates a new Struct. |
struct:getSize () | Returns the size of this Struct that is the total size of its fields. |
struct:fromString (s) | Decodes the specifed byte array as a string. |
struct:toString (t[, strict]) | Encodes the specifed values provided as a table. |
Class Struct
The Struct class.
The Struct provides a way to represents C like structure.
- Struct:new (structDef[, byteOrder])
-
Creates a new Struct.
Parameters:
- structDef table the fields structure definition with name and type, convertion option
- byteOrder string '<', '>' or '=' for little, big or native endian (optional)
Returns:
-
a new Struct
- struct:getSize ()
-
Returns the size of this Struct that is the total size of its fields.
Returns:
-
number
the size of this Struct.
- struct:fromString (s)
-
Decodes the specifed byte array as a string.
Parameters:
- s string the value to decode as a string
Returns:
-
table
the decoded values.
- struct:toString (t[, strict])
-
Encodes the specifed values provided as a table.
Parameters:
- t string the values to encode as a table
- strict boolean true to indicate that all the value are expected (optional)
Returns:
-
string
the encoded values as a string.