@@ -76,9 +76,7 @@ JSONB_API void jsonb_init(jsonb *builder);
7676 * @param bufsize the JSON buffer size
7777 * @return @ref jsonbcode value
7878 */
79- JSONB_API jsonbcode jsonb_push_object (jsonb * builder ,
80- char buf [],
81- size_t bufsize );
79+ JSONB_API jsonbcode jsonb_object (jsonb * builder , char buf [], size_t bufsize );
8280
8381/**
8482 * @brief Pop an object from the builder
@@ -88,7 +86,7 @@ JSONB_API jsonbcode jsonb_push_object(jsonb *builder,
8886 * @param bufsize the JSON buffer size
8987 * @return @ref jsonbcode value
9088 */
91- JSONB_API jsonbcode jsonb_pop_object (jsonb * builder ,
89+ JSONB_API jsonbcode jsonb_object_pop (jsonb * builder ,
9290 char buf [],
9391 size_t bufsize );
9492
@@ -102,7 +100,7 @@ JSONB_API jsonbcode jsonb_pop_object(jsonb *builder,
102100 * @param len the key length
103101 * @return @ref jsonbcode value
104102 */
105- JSONB_API jsonbcode jsonb_push_key (
103+ JSONB_API jsonbcode jsonb_key (
106104 jsonb * builder , char buf [], size_t bufsize , const char key [], size_t len );
107105
108106/**
@@ -113,9 +111,7 @@ JSONB_API jsonbcode jsonb_push_key(
113111 * @param bufsize the JSON buffer size
114112 * @return @ref jsonbcode value
115113 */
116- JSONB_API jsonbcode jsonb_push_array (jsonb * builder ,
117- char buf [],
118- size_t bufsize );
114+ JSONB_API jsonbcode jsonb_array (jsonb * builder , char buf [], size_t bufsize );
119115
120116/**
121117 * @brief Pop an array from the builder
@@ -125,7 +121,7 @@ JSONB_API jsonbcode jsonb_push_array(jsonb *builder,
125121 * @param bufsize the JSON buffer size
126122 * @return @ref jsonbcode value
127123 */
128- JSONB_API jsonbcode jsonb_pop_array (jsonb * builder ,
124+ JSONB_API jsonbcode jsonb_array_pop (jsonb * builder ,
129125 char buf [],
130126 size_t bufsize );
131127
@@ -139,11 +135,11 @@ JSONB_API jsonbcode jsonb_pop_array(jsonb *builder,
139135 * @param len the token length
140136 * @return @ref jsonbcode value
141137 */
142- JSONB_API jsonbcode jsonb_push_token (jsonb * builder ,
143- char buf [],
144- size_t bufsize ,
145- const char token [],
146- size_t len );
138+ JSONB_API jsonbcode jsonb_token (jsonb * builder ,
139+ char buf [],
140+ size_t bufsize ,
141+ const char token [],
142+ size_t len );
147143
148144/**
149145 * @brief Push a boolean token to the builder
@@ -154,10 +150,10 @@ JSONB_API jsonbcode jsonb_push_token(jsonb *builder,
154150 * @param boolean the boolean to be inserted
155151 * @return @ref jsonbcode value
156152 */
157- JSONB_API jsonbcode jsonb_push_bool (jsonb * builder ,
158- char buf [],
159- size_t bufsize ,
160- int boolean );
153+ JSONB_API jsonbcode jsonb_bool (jsonb * builder ,
154+ char buf [],
155+ size_t bufsize ,
156+ int boolean );
161157
162158/**
163159 * @brief Push a null token to the builder
@@ -167,9 +163,7 @@ JSONB_API jsonbcode jsonb_push_bool(jsonb *builder,
167163 * @param bufsize the JSON buffer size
168164 * @return @ref jsonbcode value
169165 */
170- JSONB_API jsonbcode jsonb_push_null (jsonb * builder ,
171- char buf [],
172- size_t bufsize );
166+ JSONB_API jsonbcode jsonb_null (jsonb * builder , char buf [], size_t bufsize );
173167
174168/**
175169 * @brief Push a string token to the builder
@@ -181,7 +175,7 @@ JSONB_API jsonbcode jsonb_push_null(jsonb *builder,
181175 * @param len the string length
182176 * @return @ref jsonbcode value
183177 */
184- JSONB_API jsonbcode jsonb_push_string (
178+ JSONB_API jsonbcode jsonb_string (
185179 jsonb * builder , char buf [], size_t bufsize , const char str [], size_t len );
186180
187181/**
@@ -193,10 +187,10 @@ JSONB_API jsonbcode jsonb_push_string(
193187 * @param number the number to be inserted
194188 * @return @ref jsonbcode value
195189 */
196- JSONB_API jsonbcode jsonb_push_number (jsonb * builder ,
197- char buf [],
198- size_t bufsize ,
199- double number );
190+ JSONB_API jsonbcode jsonb_number (jsonb * builder ,
191+ char buf [],
192+ size_t bufsize ,
193+ double number );
200194
201195#ifndef JSONB_HEADER
202196#include <stdio.h>
@@ -208,24 +202,15 @@ static const char *
208202_jsonb_eval_state (enum jsonbstate state )
209203{
210204 switch (state ) {
211- case JSONB_ARRAY_OR_OBJECT_OR_VALUE :
212- return "array or object or value" ;
213- case JSONB_OBJECT_KEY_OR_CLOSE :
214- return "object key or close" ;
215- case JSONB_OBJECT_NEXT_KEY_OR_CLOSE :
216- return "object next key or close" ;
217- case JSONB_OBJECT_VALUE :
218- return "object value" ;
219- case JSONB_ARRAY_VALUE_OR_CLOSE :
220- return "array value or close" ;
221- case JSONB_ARRAY_NEXT_VALUE_OR_CLOSE :
222- return "array next value or close" ;
223- case JSONB_ERROR :
224- return "error" ;
225- case JSONB_DONE :
226- return "done" ;
227- default :
228- return "unknown" ;
205+ case JSONB_ARRAY_OR_OBJECT_OR_VALUE : return "array or object or value" ;
206+ case JSONB_OBJECT_KEY_OR_CLOSE : return "object key or close" ;
207+ case JSONB_OBJECT_NEXT_KEY_OR_CLOSE : return "object next key or close" ;
208+ case JSONB_OBJECT_VALUE : return "object value" ;
209+ case JSONB_ARRAY_VALUE_OR_CLOSE : return "array value or close" ;
210+ case JSONB_ARRAY_NEXT_VALUE_OR_CLOSE : return "array next value or close" ;
211+ case JSONB_ERROR : return "error" ;
212+ case JSONB_DONE : return "done" ;
213+ default : return "unknown" ;
229214 }
230215}
231216#define TRACE (prev , next ) \
@@ -270,7 +255,7 @@ jsonb_init(jsonb *b)
270255}
271256
272257jsonbcode
273- jsonb_push_object (jsonb * b , char buf [], size_t bufsize )
258+ jsonb_object (jsonb * b , char buf [], size_t bufsize )
274259{
275260 enum jsonbstate new_state ;
276261 size_t pos = 0 ;
@@ -303,7 +288,7 @@ jsonb_push_object(jsonb *b, char buf[], size_t bufsize)
303288}
304289
305290jsonbcode
306- jsonb_pop_object (jsonb * b , char buf [], size_t bufsize )
291+ jsonb_object_pop (jsonb * b , char buf [], size_t bufsize )
307292{
308293 enum jsonbcode code ;
309294 size_t pos = 0 ;
@@ -388,8 +373,7 @@ _jsonb_escape(
388373}
389374
390375jsonbcode
391- jsonb_push_key (
392- jsonb * b , char buf [], size_t bufsize , const char key [], size_t len )
376+ jsonb_key (jsonb * b , char buf [], size_t bufsize , const char key [], size_t len )
393377{
394378 size_t pos = 0 ;
395379 switch (* b -> top ) {
@@ -415,7 +399,7 @@ jsonb_push_key(
415399}
416400
417401jsonbcode
418- jsonb_push_array (jsonb * b , char buf [], size_t bufsize )
402+ jsonb_array (jsonb * b , char buf [], size_t bufsize )
419403{
420404 enum jsonbstate new_state ;
421405 size_t pos = 0 ;
@@ -448,7 +432,7 @@ jsonb_push_array(jsonb *b, char buf[], size_t bufsize)
448432}
449433
450434jsonbcode
451- jsonb_pop_array (jsonb * b , char buf [], size_t bufsize )
435+ jsonb_array_pop (jsonb * b , char buf [], size_t bufsize )
452436{
453437 enum jsonbcode code ;
454438 size_t pos = 0 ;
@@ -471,7 +455,7 @@ jsonb_pop_array(jsonb *b, char buf[], size_t bufsize)
471455}
472456
473457jsonbcode
474- jsonb_push_token (
458+ jsonb_token (
475459 jsonb * b , char buf [], size_t bufsize , const char token [], size_t len )
476460{
477461 enum jsonbstate next_state ;
@@ -507,20 +491,20 @@ jsonb_push_token(
507491}
508492
509493jsonbcode
510- jsonb_push_bool (jsonb * b , char buf [], size_t bufsize , int boolean )
494+ jsonb_bool (jsonb * b , char buf [], size_t bufsize , int boolean )
511495{
512- if (boolean ) return jsonb_push_token (b , buf , bufsize , "true" , 4 );
513- return jsonb_push_token (b , buf , bufsize , "false" , 5 );
496+ if (boolean ) return jsonb_token (b , buf , bufsize , "true" , 4 );
497+ return jsonb_token (b , buf , bufsize , "false" , 5 );
514498}
515499
516500jsonbcode
517- jsonb_push_null (jsonb * b , char buf [], size_t bufsize )
501+ jsonb_null (jsonb * b , char buf [], size_t bufsize )
518502{
519- return jsonb_push_token (b , buf , bufsize , "null" , 4 );
503+ return jsonb_token (b , buf , bufsize , "null" , 4 );
520504}
521505
522506jsonbcode
523- jsonb_push_string (
507+ jsonb_string (
524508 jsonb * b , char buf [], size_t bufsize , const char str [], size_t len )
525509{
526510 enum jsonbstate next_state ;
@@ -559,12 +543,12 @@ jsonb_push_string(
559543}
560544
561545jsonbcode
562- jsonb_push_number (jsonb * b , char buf [], size_t bufsize , double number )
546+ jsonb_number (jsonb * b , char buf [], size_t bufsize , double number )
563547{
564548 char token [32 ];
565549 long len = sprintf (token , "%.17G" , number );
566550 if (len < 0 ) return JSONB_ERROR_INPUT ;
567- return jsonb_push_token (b , buf , bufsize , token , len );
551+ return jsonb_token (b , buf , bufsize , token , len );
568552}
569553#endif /* JSONB_HEADER */
570554
0 commit comments