MHEG  17.9.0
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Pages
mh5json.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2010 Ocean Blue Software Ltd
4  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
25 #ifndef _MH5JSON_H
26 #define _MH5JSON_H
27 
28 /*---includes for this file--------------------------------------------------*/
29 #include "techtype.h"
30 #include "dtvstring.h"
31 
32 /*---Constant and macro definitions for public use---------------------------*/
33 /* values given to callback when JST_CBF_ARRAY_OBJ */
34 #define JSON_VALUE_FINISH 0x80000000
35 #define JSON_VALUE_ERROR 0xffffffff
36 #define NULL_TOKEN ""
37 
38 /* helpful macro's for creating const token elements of S_JSON_MEMBERS */
39 #define DECLARE_MEMBER( token_str, type, ptr, child_object ) \
40  { sizeof(token_str) - 1, token_str, type, {ptr}, child_object }
41 #define DECLARE_OBJECT( cb_func ) \
42  { 0, NULL_TOKEN, JST_CBF_OBJECT, {cb_func}, NULL }
43 #define DECLARE_OBJEND() \
44  { 0, NULL_TOKEN, JST_NOTHING, {NULL}, NULL }
45 
46 /*---Enumerations for public use---------------------------------------------*/
47 
48 /*---Global type defs for public use-----------------------------------------*/
49 
50 typedef enum
51 {
52  JST_NOTHING,
53  JST_PTR_INTEGER,
54  JST_PTR_STRING,
55  JST_PTR_ASTRING,
56  JST_CBF_OBJECT,
57  JST_CBF_INTEGER,
58  JST_CBF_STRING,
59  JST_CBF_ASTRING,
60  JST_CBF_ARRAY_OBJ,
61  /*below are not yet supported*/
62  JST_CBF_ARRAY_INT,
63  JST_CBF_ARRAY_STR
64 } E_JSON_TYPE;
65 
66 typedef enum
67 {
68  JSON_ERROR,
69  JSON_OKAY,
70  JSON_MAIN,
71  JSON_NEXT,
72 } E_JSON_STATE;
73 
74 
101 typedef void * (*JsonCallback)( unsigned int val, void *array, void *usr );
102 
103 
104 typedef struct s_json_members
105 {
106  unsigned int tk_len;
107  const char *tk_str;
108  E_JSON_TYPE type;
109  union
110  {
111  void *ptr;
112  JsonCallback cb_func;
113  U32BIT *p_uint;
114  S_STRING *p_str;
115  } u;
116  const struct s_json_members *pChildren;
118 
119 
120 /*---Global variable declarations for public use-----------------------------*/
121 
122 /*---Global Function prototypes for public use-------------------------------*/
123 
132 E_JSON_STATE JSON_Parse( U8BIT *data, U32BIT size,
133  const S_JSON_MEMBERS *members, void *usr );
134 
139 void JSON_FreeAstring( S_STRING *p_str );
140 
145 void JSON_FreeUintArray( U32BIT *p_uint );
146 
153 void JSON_FreeStrArray( S_STRING **pp_str );
154 
155 #endif /*_MH5JSON_H*/
E_JSON_STATE JSON_Parse(U8BIT *data, U32BIT size, const S_JSON_MEMBERS *members, void *usr)
Definition: mh5json.c:78
Define MHEG5 String type.
Definition: dtvstring.h:28
void JSON_FreeUintArray(U32BIT *p_uint)
Definition: mh5json.c:100
void JSON_FreeStrArray(S_STRING **pp_str)
Definition: mh5json.c:110
System Wide Global Technical Data Type Definitions.
Definition: mh5json.h:104
void *(* JsonCallback)(unsigned int val, void *array, void *usr)
Definition: mh5json.h:101
void JSON_FreeAstring(S_STRING *p_str)
Definition: mh5json.c:90