LibT2FS 0.1
C API for accessing TEngine data in memory.
Loading...
Searching...
No Matches
schema.h
Go to the documentation of this file.
1/* This file is part of LibT2FS.
2 *
3 * LibT2FS is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * LibT2FS is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <https://www.gnu.org/licenses/>.
15 */
16
17#ifndef H_T2FS_SCHEMA
18#define H_T2FS_SCHEMA
19
20#include <stdint.h>
21
22#define NODE_TYPE_UNDEFINED 0
23#define NODE_TYPE_BRANCH_DYNAMIC 1
24#define NODE_TYPE_BRANCH_FIXED 2
25#define NODE_TYPE_BRANCH_MIXED 3 // first one or more fixed child nodes, others dynamic
26#define NODE_TYPE_DATA 4
27
29
30typedef struct s_t2fsSchemaNode {
31 char *name;
32
33 // fixedCount equals childCount on any childType except for NODE_TYPE_BRANCH_MIXED
34 uint32_t fixedCount;
35
36 // total child node count
37 uint32_t childCount;
38
39 // child schema nodes, when fixedCount is set, then the first fixedCount
40 // child nodes are fixed, following are dynamic (variable).
42
43 uint8_t childType;
44
45 // stuff for constraining data (only when childType is NODE_TYPE_DATA)
46 uint8_t isArray;
47 // when isArray this is the array value size, else it's fixed size.
48 // to ignore the size check set dataSize to 0.
49 uint32_t dataSize;
50 // when the data is an interleaved array
51 uint8_t interleaved;
53
54
55void
57
58void
60
61int
62t2fs_schema_parse_from_json(const char *jsonPath, t2fsSchemaNode *root);
63
64void
66
67#endif
struct s_t2fsSchemaNode t2fsSchemaNode
Definition schema.h:28
void t2fs_schema_node_free_childeren(t2fsSchemaNode *schemaNode)
int t2fs_schema_parse_from_json(const char *jsonPath, t2fsSchemaNode *root)
void t2fs_schema_node_init(t2fsSchemaNode *schemaNode)
void t2fs_schema_print(t2fsSchemaNode *schema)
Definition schema.h:30
uint32_t fixedCount
Definition schema.h:34
uint8_t childType
Definition schema.h:43
uint8_t isArray
Definition schema.h:46
t2fsSchemaNode * childNodes
Definition schema.h:41
uint32_t childCount
Definition schema.h:37
uint8_t interleaved
Definition schema.h:51
uint32_t dataSize
Definition schema.h:49
char * name
Definition schema.h:31