LibT2FS 0.1
C API for accessing TEngine data in memory.
Loading...
Searching...
No Matches
Schema

Schema files

Writing schema files

The json structure is simple, it starts with a list that defines the root nodes. Each node is defined as an object with at least the following keys:

{
"name": "",
"type": ""
}

Set the name to something useful and on that node level unique, so we can find the node by name, which is handy in some occasions. For the type there are the following options:

  • data
  • fixed
  • repeated
  • variable
  • mixed
  • anything else is unused / marked as not implemented.

For branching there are four options:

  • fixed - the child nodes are fixed and thus predefined.
  • repeated - the child nodes are fixed and thus predefined, but that structure may repeat.
  • variable - the amount child nodes are variable.
  • mixed - these nodes start with one or more fixed child nodes, after that follow variable child nodes.

The json node object uses the next and pre keys to recurse.

Define fixed branch nodes

Set the next key to a list containing fixed amount of node objects. The index in that list should correspond the node id.

{
"name": "something",
"type": "fixed",
"next": [
{
"name": "something_0",
"type": "data"
},
{
"name": "something_1",
"type": "data"
}
]
}

Define repeated branch nodes

To define a node with repeated child nodes, see how to define fixed child nodes, it's the same except the type is set to repeated.

Define variable branch nodes

Set the next key to the child node object. The next node object is the struct used for all the child nodes.

{
"name": "something",
"type": "variable",
"next": {
"name": "something_data",
"type": "data"
}
}

Define mixed branch nodes

Set the pre key to a list with fixed child node objects and set the next key to the variable child node object.

{
"name": "something",
"type": "mixed",
"pre": [
{
"name": "something_0",
"type": "data"
}
],
"next": {
"name": "something_x",
"type": "data"
}
}

Define data leaf nodes

When the node is defined as data there are a few things we can set to describe and constrain the data, we do this inside another object defined by the key data.

For having nice docs

  • comment - leave useful comment
  • valueType - the s_* name defined inside a .h file for reference.
{
"name": "something_0",
"type": "data",
"data": {
"valueType": "s_someStruct",
"comment": "some useful comment :-)"
}
}

Fixed size data

For fixed size data there is the fixedSize option to set the expected fixed data size. The type is optional for when there is a data struct defined.

Like so:

{
"name": "something_0",
"type": "data",
"data": {
"fixedSize": 16,
"type": "s_*"
}
}

Arrays

For arrays we want to define at least valueSize and the type key which has to be set to array.

  • type - should be set to array.
  • valueSize - should be set to the array value size.
  • interleaved - must be set to true when the array is interleaved to automaticaly deinterleave so we can make sense of it.
{
"name": "something_0",
"type": "data",
"data": {
"type": "array",
"valueSize": 16,
"valueType": "s_someStruct",
"interleaved": false
}
}