Files
blitzkit/docs/technical/cdon.md
T

99 lines
2.0 KiB
Markdown
Raw Normal View History

2024-02-07 10:02:00 -06:00
# Cedilla Object Notation
2024-02-04 11:06:26 -06:00
2024-02-07 10:02:00 -06:00
1. JSON compressed as CDON, written directly to disk (a direct 50% reduction).
2. CDON further compressed with LZ4 (a clean 90% reduction).
2024-02-04 21:40:40 -06:00
3. The raw JSON file as fetched from a random data source.
2024-02-07 10:02:00 -06:00
4. CDON decompressed once again to JSON. Note that this file is a little larger than the original JSON file as it contains a lot more decimal places due to float precision (this shouldn't affect the size in memory).
2024-02-04 21:40:40 -06:00
2024-02-04 21:47:11 -06:00
![an image of file sizes](https://i.imgur.com/AHJiFpq.png)
2024-02-04 21:40:40 -06:00
2024-02-13 19:46:34 -06:00
FS stands for "Fast String".
2024-02-04 11:06:26 -06:00
```cpp
2024-02-13 19:46:34 -06:00
primary CedillaObjectNotation {
utf8"CDON" magic;
2024-02-04 11:06:26 -06:00
Header header;
2024-02-13 19:46:34 -06:00
primary Body<header.fsFormat> body;
2024-02-04 11:06:26 -06:00
}
2024-02-13 19:46:34 -06:00
Header {
2024-03-18 18:06:45 -05:00
uint16 version; // always 1
2024-02-13 19:46:34 -06:00
FSFormat fsFormat;
StringTable<fsFormat> stringTable;
2024-02-04 11:06:26 -06:00
}
2024-02-13 19:46:34 -06:00
FSFormat enum<uint8> {
2024-02-05 13:33:23 -06:00
Format8,
Format16,
Format32,
}
2024-02-13 19:46:34 -06:00
FSPrimitive<FSFormat fsFormat> match(fsFormat) {
Format8: uint8;
Format16: uint16;
Format32: uint32;
}
StringTable<FSFormat fsFormat> {
FSPrimitive<fsFormat> count;
2024-02-04 11:06:26 -06:00
String[count] strings;
}
2024-02-13 19:46:34 -06:00
Body<FSFormat fsFormat> {
primary Value<fsFormat> object;
2024-02-04 11:06:26 -06:00
}
2024-02-13 19:46:34 -06:00
ValueType enum<uint8> {
2024-02-04 11:06:26 -06:00
Null,
Boolean,
Uint8,
Uint16,
Uint32,
Uint64,
Int8,
Int16,
Int32,
Int64,
Float32,
Float64,
String,
2024-02-13 19:46:34 -06:00
FS,
2024-02-04 11:06:26 -06:00
Array,
Object,
}
2024-02-13 19:46:34 -06:00
String {
uint32 length;
primary utf8<length> value;
2024-02-04 11:06:26 -06:00
}
2024-02-13 19:46:34 -06:00
StringValue Value & { (ValueType.String | ValueType.FS) type }
2024-02-04 11:06:26 -06:00
2024-02-13 19:46:34 -06:00
Value<FSFormat fsFormat> {
ValueType type;
match<type> {
Boolean: { uint8 value; }
Uint8: { uint8 value; }
Uint16: { uint16 value; }
Uint32: { uint32 value; }
Uint64: { uint64 value; }
Int8: { int8 value; }
Int16: { int16 value; }
Int32: { int32 value; }
Int64: { int64 value; }
Float32: { float32 value; }
Float64: { float64 value; }
String: { String value; }
FS: { FSPrimitive<fsFormat> index; }
Array: {
uint32 count;
Value[count] values;
}
Object: {
uint32 count;
StringValue[count] keys;
Value[count] values;
}
}
2024-02-04 11:06:26 -06:00
}
```