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_BRANCH_REPEATED 4 // repeat fixed branch
27#define NODE_TYPE_DATA 5
28
30
31typedef struct s_T2FSSchemaNode {
32 char *name;
33
34 // fixedCount equals childCount on any childType except for NODE_TYPE_BRANCH_MIXED
35 uint32_t fixedCount;
36
37 // total child node count
38 uint32_t childCount;
39
40 // child schema nodes, when fixedCount is set, then the first fixedCount
41 // child nodes are fixed, following are dynamic (variable).
43
44 uint8_t childType;
45
46 // stuff for constraining data (only when childType is NODE_TYPE_DATA)
47 uint8_t isArray;
48 // when isArray this is the array value size, else it's fixed size.
49 // to ignore the size check set dataSize to 0.
50 uint32_t dataSize;
51 // when the data is an interleaved array
52 uint8_t interleaved;
54
55
56void
58
59void
61
62int
63t2fs_schema_parse_from_json(const char *jsonPath, T2FSSchemaNode *root);
64
65void
67
68#endif
void t2fs_schema_print(T2FSSchemaNode *schema)
void t2fs_schema_node_free_childeren(T2FSSchemaNode *schemaNode)
void t2fs_schema_node_init(T2FSSchemaNode *schemaNode)
int t2fs_schema_parse_from_json(const char *jsonPath, T2FSSchemaNode *root)
struct s_T2FSSchemaNode T2FSSchemaNode
Definition schema.h:29
Definition schema.h:31
uint32_t dataSize
Definition schema.h:50
uint32_t childCount
Definition schema.h:38
uint8_t interleaved
Definition schema.h:52
T2FSSchemaNode * childNodes
Definition schema.h:42
char * name
Definition schema.h:32
uint32_t fixedCount
Definition schema.h:35
uint8_t isArray
Definition schema.h:47
uint8_t childType
Definition schema.h:44