Implement CTF 2 JSON requirements
This patch implements all the CTF 2 JSON requirements.
The internal "public" API is the `Ctf2JsonAnyFragmentValReq` PImpl class
which validates a single CTF 2 fragment. That's all the CTF 2 metadata
stream parser will need.
Here's an example:
Code:
Ctf2JsonAnyFragValReq {}.validate(*bt2c::parseJson(jsonText));
JSON text:
{
"type": "data-stream-class",
"namespace": "lol",
"name": "salut",
"packet-context-field-class": {
"type": "structure",
"member-classes": [
{
"name": "meow",
"field-class": {
"type": "null-terminated-string"
}
},
{
"name": "lel",
"field-class": "uint16"
},
{
"name": "meow",
"field-class": {
"type": "dynamic-length-array",
"length-field-location": {"path": ["lel"]},
"element-field-class": {
"type": "fixed-length-signed-integer",
"length": 23,
"byte-order": "little-endian",
"alignment": 24,
"attributes": {}
}
}
}
]
}
}
Exception message:
[1:1] Invalid data stream class fragment:
[5:33] In object property `packet-context-field-class`:
[5:33] Invalid scope field class:
[5:33] Invalid structure field class:
[7:23] In object property `member-classes`:
[18:7] In array element #3:
[18:7] Invalid structure field member class:
[20:24] In object property `field-class`:
[20:24] Invalid dynamic-length array field class:
[23:34] In object property `element-field-class`:
[23:34] Invalid fixed-length signed integer field class:
[27:26] In object property `alignment`:
[27:26] Invalid alignment: 24 is not a power of two.
I'd say that Ctf2JsonAnyFragValReq::validate() can validate 95 % of a
CTF 2 metadata stream. See its class comment to learn what it can't do.
There are a few clang-format off/on comments because I hate what it does
with nested brace-enclosed lists.
Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ic622a099a1e0aa5daa896cdfa910d24b817a9a5f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12717
This page took 0.024892 seconds and 4 git commands to generate.