|
| 1 | +/* |
| 2 | + * Copyright (C) 2010 Florian Forster <ff at octo.it> |
| 3 | + * |
| 4 | + * Redistribution and use in source and binary forms, with or without |
| 5 | + * modification, are permitted provided that the following conditions are |
| 6 | + * met: |
| 7 | + * |
| 8 | + * 1. Redistributions of source code must retain the above copyright |
| 9 | + * notice, this list of conditions and the following disclaimer. |
| 10 | + * |
| 11 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 12 | + * notice, this list of conditions and the following disclaimer in |
| 13 | + * the documentation and/or other materials provided with the |
| 14 | + * distribution. |
| 15 | + * |
| 16 | + * 3. Neither the name of Lloyd Hilaiel nor the names of its |
| 17 | + * contributors may be used to endorse or promote products derived |
| 18 | + * from this software without specific prior written permission. |
| 19 | + * |
| 20 | + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 21 | + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 | + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 23 | + * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, |
| 24 | + * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 25 | + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 26 | + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 27 | + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 28 | + * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 29 | + * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 30 | + * POSSIBILITY OF SUCH DAMAGE. |
| 31 | + */ |
| 32 | + |
| 33 | +#ifndef YAJL_TREE_H |
| 34 | +#define YAJL_TREE_H 1 |
| 35 | + |
| 36 | +#include <stdint.h> |
| 37 | +#include <inttypes.h> |
| 38 | + |
| 39 | +#include <yajl/yajl_common.h> |
| 40 | + |
| 41 | +struct yajl_value_s; |
| 42 | +typedef struct yajl_value_s yajl_value_t; |
| 43 | + |
| 44 | +struct yajl_value_string_s |
| 45 | +{ |
| 46 | + char *value; |
| 47 | +}; |
| 48 | +typedef struct yajl_value_string_s yajl_value_string_t; |
| 49 | + |
| 50 | +struct yajl_value_number_s |
| 51 | +{ |
| 52 | + char *value; |
| 53 | +}; |
| 54 | +typedef struct yajl_value_number_s yajl_value_number_t; |
| 55 | + |
| 56 | +struct yajl_value_object_s |
| 57 | +{ |
| 58 | + yajl_value_t **keys; |
| 59 | + yajl_value_t **values; |
| 60 | + size_t children_num; |
| 61 | +}; |
| 62 | +typedef struct yajl_value_object_s yajl_value_object_t; |
| 63 | + |
| 64 | +struct yajl_value_array_s |
| 65 | +{ |
| 66 | + yajl_value_t **children; |
| 67 | + size_t children_num; |
| 68 | +}; |
| 69 | +typedef struct yajl_value_array_s yajl_value_array_t; |
| 70 | + |
| 71 | +#define VALUE_TYPE_STRING 1 |
| 72 | +#define VALUE_TYPE_NUMBER 2 |
| 73 | +#define VALUE_TYPE_OBJECT 3 |
| 74 | +#define VALUE_TYPE_ARRAY 4 |
| 75 | +#define VALUE_TYPE_TRUE 5 |
| 76 | +#define VALUE_TYPE_FALSE 6 |
| 77 | +#define VALUE_TYPE_NULL 7 |
| 78 | + |
| 79 | +struct yajl_value_s |
| 80 | +{ |
| 81 | + uint8_t type; |
| 82 | + union |
| 83 | + { |
| 84 | + yajl_value_string_t string; |
| 85 | + yajl_value_number_t number; |
| 86 | + yajl_value_object_t object; |
| 87 | + yajl_value_array_t array; |
| 88 | + } data; |
| 89 | +}; |
| 90 | + |
| 91 | +YAJL_API yajl_value_t *yajl_tree_parse (const char *input); |
| 92 | + |
| 93 | +#endif /* YAJL_TREE_H */ |
| 94 | +/* vim: set sw=2 sts=2 et : */ |
0 commit comments