00001 #ifndef MICROFEEDJSON_H
00002 #define MICROFEEDJSON_H
00003
00004 #include <sys/types.h>
00005
00016 typedef struct _MicrofeedJson MicrofeedJson;
00017
00018 typedef enum {
00019 MICROFEED_JSON_TYPE_NULL = 0,
00020 MICROFEED_JSON_TYPE_OBJECT,
00021 MICROFEED_JSON_TYPE_ARRAY,
00022 MICROFEED_JSON_TYPE_INTEGER,
00023 MICROFEED_JSON_TYPE_DECIMAL,
00024 MICROFEED_JSON_TYPE_STRING,
00025 MICROFEED_JSON_TYPE_BOOLEAN
00026 } MicrofeedJsonType;
00027
00028 typedef int (*MicrofeedJsonCompareMembersFunction)(MicrofeedJson* json, unsigned int index1, unsigned int index2, void* user_data);
00029
00030 MicrofeedJson* microfeed_json_new_object(void);
00031 MicrofeedJson* microfeed_json_new_array(void);
00032 MicrofeedJson* microfeed_json_new_from_data(const char* data, size_t length);
00033 void microfeed_json_free(MicrofeedJson* json);
00034
00035 int microfeed_json_is_array(MicrofeedJson* json);
00036 MicrofeedJson* microfeed_json_get_parent(MicrofeedJson* json);
00037 unsigned int microfeed_json_get_size(MicrofeedJson* json);
00038 MicrofeedJsonType microfeed_json_get_type(MicrofeedJson* json, const char* name);
00039 MicrofeedJsonType microfeed_json_get_type_by_index(MicrofeedJson* json, unsigned int index);
00040 MicrofeedJsonType microfeed_json_get_type_by_path(MicrofeedJson* json, const char* name, ...);
00041 const char* microfeed_json_get_name_by_index(MicrofeedJson* json, unsigned int index);
00042 int microfeed_json_is_null(MicrofeedJson* json, const char* name);
00043 int microfeed_json_is_null_by_index(MicrofeedJson* json, unsigned int index);
00044 int microfeed_json_is_null_by_path(MicrofeedJson* json,const char* name1, ...);
00045 MicrofeedJson* microfeed_json_get_object(MicrofeedJson* json, const char* name);
00046 MicrofeedJson* microfeed_json_get_object_by_index(MicrofeedJson* json, unsigned int index);
00047 MicrofeedJson* microfeed_json_get_object_by_path(MicrofeedJson* json, const char* name, ...);
00048 MicrofeedJson* microfeed_json_get_array(MicrofeedJson* json, const char* name);
00049 MicrofeedJson* microfeed_json_get_array_by_index(MicrofeedJson* json, unsigned int index);
00050 MicrofeedJson* microfeed_json_get_array_by_path(MicrofeedJson* json, const char* name, ...);
00051 const char* microfeed_json_get_string(MicrofeedJson* json, const char* name);
00052 const char* microfeed_json_get_string_by_index(MicrofeedJson* json, unsigned int index);
00053 const char* microfeed_json_get_string_by_path(MicrofeedJson* json, const char* name, ...);
00054 int microfeed_json_get_boolean(MicrofeedJson* json, const char* name);
00055 int microfeed_json_get_boolean_by_index(MicrofeedJson* json, unsigned int index);
00056 int microfeed_json_get_boolean_by_path(MicrofeedJson* json, const char* name, ...);
00057 const char* microfeed_json_get_as_string(MicrofeedJson* json, const char* name);
00058 const char* microfeed_json_get_as_string_by_index(MicrofeedJson* json, unsigned int index);
00059 const char* microfeed_json_get_as_string_by_path(MicrofeedJson* json, const char* name, ...);
00060 char* microfeed_json_to_string(MicrofeedJson* json, const char* name);
00061 char* microfeed_json_to_string_by_index(MicrofeedJson* json, unsigned int index);
00062 char* microfeed_json_to_string_by_path(MicrofeedJson* json, const char* name, ...);
00063 void microfeed_json_set_null(MicrofeedJson* json, const char* name);
00064 void microfeed_json_append_null(MicrofeedJson* json, MicrofeedJson* object);
00065 void microfeed_json_set_object(MicrofeedJson* json, const char* name, MicrofeedJson* object);
00066 void microfeed_json_append_object(MicrofeedJson* json, MicrofeedJson* object);
00067 void microfeed_json_set_string(MicrofeedJson* json, const char* name, const char* string);
00068 void microfeed_json_append_string(MicrofeedJson* json, const char* string);
00069 void microfeed_json_set_boolean(MicrofeedJson* json, const char* name, int boolean);
00070 void microfeed_json_append_boolean(MicrofeedJson* json, int boolean);
00071 void microfeed_json_sort_array(MicrofeedJson* json, MicrofeedJsonCompareMembersFunction compare_members, void* user_data);
00072 int microfeed_json_compare_members(MicrofeedJson* json, unsigned int index1, unsigned int index2);
00073
00079 #endif