YAJL 1.0.12
|
00001 /* 00002 * Copyright 2010, Lloyd Hilaiel. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions are 00006 * met: 00007 * 00008 * 1. Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in 00013 * the documentation and/or other materials provided with the 00014 * distribution. 00015 * 00016 * 3. Neither the name of Lloyd Hilaiel nor the names of its 00017 * contributors may be used to endorse or promote products derived 00018 * from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00021 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00022 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00023 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 00024 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00025 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00026 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00027 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 00028 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 00030 * POSSIBILITY OF SUCH DAMAGE. 00031 */ 00032 00038 #include <yajl/yajl_common.h> 00039 00040 #ifndef __YAJL_GEN_H__ 00041 #define __YAJL_GEN_H__ 00042 00043 #ifdef __cplusplus 00044 extern "C" { 00045 #endif 00046 00047 typedef enum { 00049 yajl_gen_status_ok = 0, 00052 yajl_gen_keys_must_be_strings, 00055 yajl_max_depth_exceeded, 00058 yajl_gen_in_error_state, 00060 yajl_gen_generation_complete, 00063 yajl_gen_invalid_number, 00066 yajl_gen_no_buf 00067 } yajl_gen_status; 00068 00070 typedef struct yajl_gen_t * yajl_gen; 00071 00073 typedef void (*yajl_print_t)(void * ctx, 00074 const char * str, 00075 unsigned int len); 00076 00078 typedef struct { 00080 unsigned int beautify; 00084 const char * indentString; 00085 } yajl_gen_config; 00086 00097 YAJL_API yajl_gen yajl_gen_alloc(const yajl_gen_config * config, 00098 const yajl_alloc_funcs * allocFuncs); 00099 00117 YAJL_API yajl_gen yajl_gen_alloc2(const yajl_print_t callback, 00118 const yajl_gen_config * config, 00119 const yajl_alloc_funcs * allocFuncs, 00120 void * ctx); 00121 00123 YAJL_API void yajl_gen_free(yajl_gen handle); 00124 00125 YAJL_API yajl_gen_status yajl_gen_integer(yajl_gen hand, long int number); 00129 YAJL_API yajl_gen_status yajl_gen_double(yajl_gen hand, double number); 00130 YAJL_API yajl_gen_status yajl_gen_number(yajl_gen hand, 00131 const char * num, 00132 unsigned int len); 00133 YAJL_API yajl_gen_status yajl_gen_string(yajl_gen hand, 00134 const unsigned char * str, 00135 unsigned int len); 00136 YAJL_API yajl_gen_status yajl_gen_null(yajl_gen hand); 00137 YAJL_API yajl_gen_status yajl_gen_bool(yajl_gen hand, int boolean); 00138 YAJL_API yajl_gen_status yajl_gen_map_open(yajl_gen hand); 00139 YAJL_API yajl_gen_status yajl_gen_map_close(yajl_gen hand); 00140 YAJL_API yajl_gen_status yajl_gen_array_open(yajl_gen hand); 00141 YAJL_API yajl_gen_status yajl_gen_array_close(yajl_gen hand); 00142 00146 YAJL_API yajl_gen_status yajl_gen_get_buf(yajl_gen hand, 00147 const unsigned char ** buf, 00148 unsigned int * len); 00149 00153 YAJL_API void yajl_gen_clear(yajl_gen hand); 00154 00155 #ifdef __cplusplus 00156 } 00157 #endif 00158 00159 #endif