WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
json.h
Go to the documentation of this file.
1
/*
2
* MIT License
3
*
4
* Copyright (c) 2010 Serge Zaitsev
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
/*
25
These utilities adapted from jsmn https://github.com/zserge/jsmn/blob/master/jsmn.h
26
for ATTX.
27
28
NOTE: Code coverage exception 9/1/2025:
29
There are two logical branches in this set of code which are unreachable under normal conditions
30
and the code cannot operate without (and therefore the branch cannot be excluded from coverage).
31
Therefore this code receives an exception from 100% mc/dc code coverage, as to generate 100% code
32
coverage would require modifying an external library, a more unsafe option than the exception.
33
Dev: Alex Reynolds
34
Tech Authority: Alex Reynolds
35
Reviewer: Ryan Hughes
36
*/
37
#ifndef UTILS_JSON_H
38
#define UTILS_JSON_H
39
40
#include <stddef.h>
41
42
#ifdef __cplusplus
43
extern
"C"
{
44
#endif
45
46
#ifdef JSMN_STATIC
47
#define JSMN_API static
48
#else
49
#define JSMN_API extern
50
#endif
51
59
typedef
enum
{
60
JSMN_UNDEFINED
= 0,
61
JSMN_OBJECT
= 1 << 0,
62
JSMN_ARRAY
= 1 << 1,
63
JSMN_STRING
= 1 << 2,
64
JSMN_PRIMITIVE
= 1 << 3
65
}
jsmntype_t
;
66
67
enum
jsmnerr
{
68
/* Not enough tokens were provided */
69
JSMN_ERROR_NOMEM
= -1,
70
/* Invalid character inside JSON string */
71
JSMN_ERROR_INVAL
= -2,
72
/* The string is not a full JSON packet, more bytes expected */
73
JSMN_ERROR_PART
= -3
74
};
75
82
typedef
struct
jsmntok
{
83
jsmntype_t
type
;
84
int
start
;
85
int
end
;
86
int
size
;
87
#ifdef JSMN_PARENT_LINKS
88
int
parent;
89
#endif
90
}
jsmntok_t
;
91
96
typedef
struct
jsmn_parser
{
97
unsigned
int
pos
;
/* offset in the JSON string */
98
unsigned
int
toknext
;
/* next token to allocate */
99
int
toksuper
;
/* superior token node, e.g. parent object or array */
100
}
jsmn_parser
;
101
105
JSMN_API
void
jsmn_init
(
jsmn_parser
*parser);
106
112
JSMN_API
int
jsmn_parse
(
jsmn_parser
*parser,
const
char
*js,
const
size_t
len,
113
jsmntok_t
*tokens,
const
unsigned
int
num_tokens);
114
115
116
#ifdef __cplusplus
117
}
118
#endif
119
120
#endif
/* JSMN_H */
jsmntype_t
jsmntype_t
Definition
json.h:59
JSMN_PRIMITIVE
@ JSMN_PRIMITIVE
Definition
json.h:64
JSMN_OBJECT
@ JSMN_OBJECT
Definition
json.h:61
JSMN_UNDEFINED
@ JSMN_UNDEFINED
Definition
json.h:60
JSMN_ARRAY
@ JSMN_ARRAY
Definition
json.h:62
JSMN_STRING
@ JSMN_STRING
Definition
json.h:63
jsmn_init
void jsmn_init(jsmn_parser *parser)
Definition
json.cpp:393
jsmntok_t
struct jsmntok jsmntok_t
JSMN_API
#define JSMN_API
Definition
json.h:49
jsmn_parse
int jsmn_parse(jsmn_parser *parser, const char *js, const size_t len, jsmntok_t *tokens, const unsigned int num_tokens)
Definition
json.cpp:202
jsmnerr
jsmnerr
Definition
json.h:67
JSMN_ERROR_INVAL
@ JSMN_ERROR_INVAL
Definition
json.h:71
JSMN_ERROR_PART
@ JSMN_ERROR_PART
Definition
json.h:73
JSMN_ERROR_NOMEM
@ JSMN_ERROR_NOMEM
Definition
json.h:69
jsmn_parser
Definition
json.h:96
jsmn_parser::pos
unsigned int pos
Definition
json.h:97
jsmn_parser::toksuper
int toksuper
Definition
json.h:99
jsmn_parser::toknext
unsigned int toknext
Definition
json.h:98
jsmntok
Definition
json.h:82
jsmntok::end
int end
Definition
json.h:85
jsmntok::size
int size
Definition
json.h:86
jsmntok::start
int start
Definition
json.h:84
jsmntok::type
jsmntype_t type
Definition
json.h:83
warpos
clockwerk
src
utils
json.h
Generated by
1.16.1