>
technical stuff
>
the file formats
>
properties
some data in veadotube files is stored in a key-value dictionary, where keys are strings and values can be of multiple types. these dictionaries are called properties.
when serializing a dictionary, we take advantage of the sub-key structure of string segments separated by a /
and keep track of the current stack of segments.
each entry is serialized like so:
length | description |
---|---|
1 | value type, cannot be zero |
? | number of segments to pop from the stack, variable-length integer, only present if stack is not currently empty |
1+ | new segments to be pushed to the stack, separated by / , variable-length string |
1+ | length of value = n , variable-length integer |
n |
entry value |
then the current segments in the stack are joined with a /
, and the resulting string is the key for the expressed value.
for example, let’s say we’re serializing the following keys:
key |
---|
transform/position |
transform/rotation |
effects/opacity |
effects/tint |
the stack operations would be expressed as so:
pop | push |
---|---|
(none) | transform/position |
1 | rotation |
2 | effects/opacity |
1 | tint |
again, the pop count is not serialized when the stack is already empty, which always applies to the first entry, and ideally only the first entry.
the possible value types are as follows:
byte | type |
---|---|
1 |
string |
2 |
variable-length integer, positive |
3 |
variable-length integer, negative |
4 |
double-precision floating point number |
when serializing strings, you don’t need to prefix them with their length, as we already know the value length at this point.
variable-length integers, both positive and negative, are serialized the same. the difference is that in the second one you should flip the sign after reading it. booleans are also stored as integers, 1 for true and 0 for false.
for double-precision floating point numbers, the value length may be multiples of 8. this means that there’s more than one number expressed in this value, which is the case for vectors (stored as 2 numbers for X and Y) and colours (stored as 4 numbers, ranging from 0 to 1).
when reading an entry and the value type is zero, this indicates the dictionary is over, and we can stop reading from there.