00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MICROFEEDJSON_H
00020 #define MICROFEEDJSON_H
00021
00022 #include <sys/types.h>
00023
00034 typedef struct _MicrofeedJson MicrofeedJson;
00035
00036 typedef enum {
00037 MICROFEED_JSON_TYPE_NULL = 0,
00038 MICROFEED_JSON_TYPE_OBJECT,
00039 MICROFEED_JSON_TYPE_ARRAY,
00040 MICROFEED_JSON_TYPE_INTEGER,
00041 MICROFEED_JSON_TYPE_DECIMAL,
00042 MICROFEED_JSON_TYPE_STRING,
00043 MICROFEED_JSON_TYPE_BOOLEAN
00044 } MicrofeedJsonType;
00045
00046 typedef int (*MicrofeedJsonCompareMembersFunction)(MicrofeedJson* json, unsigned int index1, unsigned int index2, void* user_data);
00047
00048 MicrofeedJson* microfeed_json_new_object(void);
00049 MicrofeedJson* microfeed_json_new_array(void);
00050 MicrofeedJson* microfeed_json_new_from_data(const char* data, size_t length);
00051 void microfeed_json_free(MicrofeedJson* json);
00052
00053 int microfeed_json_is_array(MicrofeedJson* json);
00054 MicrofeedJson* microfeed_json_get_parent(MicrofeedJson* json);
00055 unsigned int microfeed_json_get_size(MicrofeedJson* json);
00056 MicrofeedJsonType microfeed_json_get_type(MicrofeedJson* json, const char* name);
00057 MicrofeedJsonType microfeed_json_get_type_by_index(MicrofeedJson* json, unsigned int index);
00058 MicrofeedJsonType microfeed_json_get_type_by_path(MicrofeedJson* json, const char* name, ...);
00059 const char* microfeed_json_get_name_by_index(MicrofeedJson* json, unsigned int index);
00060 int microfeed_json_is_null(MicrofeedJson* json, const char* name);
00061 int microfeed_json_is_null_by_index(MicrofeedJson* json, unsigned int index);
00062 int microfeed_json_is_null_by_path(MicrofeedJson* json,const char* name1, ...);
00063 MicrofeedJson* microfeed_json_get_object(MicrofeedJson* json, const char* name);
00064 MicrofeedJson* microfeed_json_get_object_by_index(MicrofeedJson* json, unsigned int index);
00065 MicrofeedJson* microfeed_json_get_object_by_path(MicrofeedJson* json, const char* name, ...);
00066 MicrofeedJson* microfeed_json_get_array(MicrofeedJson* json, const char* name);
00067 MicrofeedJson* microfeed_json_get_array_by_index(MicrofeedJson* json, unsigned int index);
00068 MicrofeedJson* microfeed_json_get_array_by_path(MicrofeedJson* json, const char* name, ...);
00069 long long int microfeed_json_get_integer(MicrofeedJson* json, const char* name);
00070 long long int microfeed_json_get_integer_by_index(MicrofeedJson* json, unsigned int index);
00071 long long int microfeed_json_get_integer_by_path(MicrofeedJson* json, const char* name, ...);
00072 double microfeed_json_get_decimal(MicrofeedJson* json, const char* name);
00073 double microfeed_json_get_decimal_by_index(MicrofeedJson* json, unsigned int index);
00074 double microfeed_json_get_decimal_by_path(MicrofeedJson* json, const char* name, ...);
00075 const char* microfeed_json_get_string(MicrofeedJson* json, const char* name);
00076 const char* microfeed_json_get_string_by_index(MicrofeedJson* json, unsigned int index);
00077 const char* microfeed_json_get_string_by_path(MicrofeedJson* json, const char* name, ...);
00078 int microfeed_json_get_boolean(MicrofeedJson* json, const char* name);
00079 int microfeed_json_get_boolean_by_index(MicrofeedJson* json, unsigned int index);
00080 int microfeed_json_get_boolean_by_path(MicrofeedJson* json, const char* name, ...);
00081 const char* microfeed_json_get_as_string(MicrofeedJson* json, const char* name);
00082 const char* microfeed_json_get_as_string_by_index(MicrofeedJson* json, unsigned int index);
00083 const char* microfeed_json_get_as_string_by_path(MicrofeedJson* json, const char* name, ...);
00084 char* microfeed_json_to_string(MicrofeedJson* json, const char* name);
00085 char* microfeed_json_to_string_by_index(MicrofeedJson* json, unsigned int index);
00086 char* microfeed_json_to_string_by_path(MicrofeedJson* json, const char* name, ...);
00087 void microfeed_json_set_null(MicrofeedJson* json, const char* name);
00088 void microfeed_json_append_null(MicrofeedJson* json, MicrofeedJson* object);
00089 void microfeed_json_set_object(MicrofeedJson* json, const char* name, MicrofeedJson* object);
00090 void microfeed_json_append_object(MicrofeedJson* json, MicrofeedJson* object);
00091 void microfeed_json_set_integer(MicrofeedJson* json, const char* name, long long int integer);
00092 void microfeed_json_append_integer(MicrofeedJson* json, long long int integer);
00093 void microfeed_json_set_decimal(MicrofeedJson* json, const char* name, double decimal);
00094 void microfeed_json_append_decimal(MicrofeedJson* json, double decimal);
00095 void microfeed_json_set_string(MicrofeedJson* json, const char* name, const char* string);
00096 void microfeed_json_append_string(MicrofeedJson* json, const char* string);
00097 void microfeed_json_set_boolean(MicrofeedJson* json, const char* name, int boolean);
00098 void microfeed_json_append_boolean(MicrofeedJson* json, int boolean);
00099 void microfeed_json_sort_array(MicrofeedJson* json, MicrofeedJsonCompareMembersFunction compare_members, void* user_data);
00100 int microfeed_json_compare_members(MicrofeedJson* json, unsigned int index1, unsigned int index2);
00101
00107 #endif