yajl - JSON library working with the compiler. URL: http://lloyd.github.com/yajl/

Dependencies:   mbed

Committer:
rolf
Date:
Wed Nov 18 17:56:51 2009 +0000
Revision:
0:34f4a53d4ca3

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rolf 0:34f4a53d4ca3 1 /*
rolf 0:34f4a53d4ca3 2 * Copyright 2007-2009, Lloyd Hilaiel.
rolf 0:34f4a53d4ca3 3 *
rolf 0:34f4a53d4ca3 4 * Redistribution and use in source and binary forms, with or without
rolf 0:34f4a53d4ca3 5 * modification, are permitted provided that the following conditions are
rolf 0:34f4a53d4ca3 6 * met:
rolf 0:34f4a53d4ca3 7 *
rolf 0:34f4a53d4ca3 8 * 1. Redistributions of source code must retain the above copyright
rolf 0:34f4a53d4ca3 9 * notice, this list of conditions and the following disclaimer.
rolf 0:34f4a53d4ca3 10 *
rolf 0:34f4a53d4ca3 11 * 2. Redistributions in binary form must reproduce the above copyright
rolf 0:34f4a53d4ca3 12 * notice, this list of conditions and the following disclaimer in
rolf 0:34f4a53d4ca3 13 * the documentation and/or other materials provided with the
rolf 0:34f4a53d4ca3 14 * distribution.
rolf 0:34f4a53d4ca3 15 *
rolf 0:34f4a53d4ca3 16 * 3. Neither the name of Lloyd Hilaiel nor the names of its
rolf 0:34f4a53d4ca3 17 * contributors may be used to endorse or promote products derived
rolf 0:34f4a53d4ca3 18 * from this software without specific prior written permission.
rolf 0:34f4a53d4ca3 19 *
rolf 0:34f4a53d4ca3 20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
rolf 0:34f4a53d4ca3 21 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
rolf 0:34f4a53d4ca3 22 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
rolf 0:34f4a53d4ca3 23 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
rolf 0:34f4a53d4ca3 24 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
rolf 0:34f4a53d4ca3 25 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
rolf 0:34f4a53d4ca3 26 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
rolf 0:34f4a53d4ca3 27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
rolf 0:34f4a53d4ca3 28 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
rolf 0:34f4a53d4ca3 29 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
rolf 0:34f4a53d4ca3 30 * POSSIBILITY OF SUCH DAMAGE.
rolf 0:34f4a53d4ca3 31 */
rolf 0:34f4a53d4ca3 32
rolf 0:34f4a53d4ca3 33 #ifndef __YAJL_PARSER_H__
rolf 0:34f4a53d4ca3 34 #define __YAJL_PARSER_H__
rolf 0:34f4a53d4ca3 35
rolf 0:34f4a53d4ca3 36 #ifdef __cplusplus
rolf 0:34f4a53d4ca3 37 extern "C" {
rolf 0:34f4a53d4ca3 38 #endif
rolf 0:34f4a53d4ca3 39
rolf 0:34f4a53d4ca3 40
rolf 0:34f4a53d4ca3 41 #include "yajl/yajl_parse.h"
rolf 0:34f4a53d4ca3 42 #include "yajl_buf.h"
rolf 0:34f4a53d4ca3 43
rolf 0:34f4a53d4ca3 44 typedef enum {
rolf 0:34f4a53d4ca3 45 yajl_state_start = 0,
rolf 0:34f4a53d4ca3 46 yajl_state_parse_complete,
rolf 0:34f4a53d4ca3 47 yajl_state_parse_error,
rolf 0:34f4a53d4ca3 48 yajl_state_lexical_error,
rolf 0:34f4a53d4ca3 49 yajl_state_map_start,
rolf 0:34f4a53d4ca3 50 yajl_state_map_sep,
rolf 0:34f4a53d4ca3 51 yajl_state_map_need_val,
rolf 0:34f4a53d4ca3 52 yajl_state_map_got_val,
rolf 0:34f4a53d4ca3 53 yajl_state_map_need_key,
rolf 0:34f4a53d4ca3 54 yajl_state_array_start,
rolf 0:34f4a53d4ca3 55 yajl_state_array_got_val,
rolf 0:34f4a53d4ca3 56 yajl_state_array_need_val
rolf 0:34f4a53d4ca3 57 } yajl_state;
rolf 0:34f4a53d4ca3 58
rolf 0:34f4a53d4ca3 59 struct yajl_handle_t {
rolf 0:34f4a53d4ca3 60 const yajl_callbacks * callbacks;
rolf 0:34f4a53d4ca3 61 void * ctx;
rolf 0:34f4a53d4ca3 62 yajl_lexer lexer;
rolf 0:34f4a53d4ca3 63 const char * parseError;
rolf 0:34f4a53d4ca3 64 unsigned int errorOffset;
rolf 0:34f4a53d4ca3 65 /* temporary storage for decoded strings */
rolf 0:34f4a53d4ca3 66 yajl_buf decodeBuf;
rolf 0:34f4a53d4ca3 67 /* a stack of states. access with yajl_state_XXX routines */
rolf 0:34f4a53d4ca3 68 yajl_buf stateBuf;
rolf 0:34f4a53d4ca3 69 /* memory allocation routines */
rolf 0:34f4a53d4ca3 70 yajl_alloc_funcs alloc;
rolf 0:34f4a53d4ca3 71 };
rolf 0:34f4a53d4ca3 72
rolf 0:34f4a53d4ca3 73 yajl_status
rolf 0:34f4a53d4ca3 74 yajl_do_parse(yajl_handle handle, unsigned int * offset,
rolf 0:34f4a53d4ca3 75 const unsigned char * jsonText, unsigned int jsonTextLen);
rolf 0:34f4a53d4ca3 76
rolf 0:34f4a53d4ca3 77 unsigned char *
rolf 0:34f4a53d4ca3 78 yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
rolf 0:34f4a53d4ca3 79 unsigned int jsonTextLen, int verbose);
rolf 0:34f4a53d4ca3 80
rolf 0:34f4a53d4ca3 81 yajl_state yajl_state_current(yajl_handle handle);
rolf 0:34f4a53d4ca3 82
rolf 0:34f4a53d4ca3 83 void yajl_state_push(yajl_handle handle, yajl_state state);
rolf 0:34f4a53d4ca3 84
rolf 0:34f4a53d4ca3 85 yajl_state yajl_state_pop(yajl_handle handle);
rolf 0:34f4a53d4ca3 86
rolf 0:34f4a53d4ca3 87 unsigned int yajl_parse_depth(yajl_handle handle);
rolf 0:34f4a53d4ca3 88
rolf 0:34f4a53d4ca3 89 void yajl_state_set(yajl_handle handle, yajl_state state);
rolf 0:34f4a53d4ca3 90
rolf 0:34f4a53d4ca3 91 #ifdef __cplusplus
rolf 0:34f4a53d4ca3 92 }
rolf 0:34f4a53d4ca3 93 #endif
rolf 0:34f4a53d4ca3 94
rolf 0:34f4a53d4ca3 95 #endif