提交 56b7d94f 编写于 作者: P Peter Krempa

util: json: Privatize struct _virJSONValue and sub-structs

Enforce usage of accessors by hiding the implementation in the code.
Signed-off-by: NPeter Krempa <pkrempa@redhat.com>
上级 167028e3
...@@ -51,6 +51,45 @@ ...@@ -51,6 +51,45 @@
VIR_LOG_INIT("util.json"); VIR_LOG_INIT("util.json");
typedef struct _virJSONObject virJSONObject;
typedef virJSONObject *virJSONObjectPtr;
typedef struct _virJSONObjectPair virJSONObjectPair;
typedef virJSONObjectPair *virJSONObjectPairPtr;
typedef struct _virJSONArray virJSONArray;
typedef virJSONArray *virJSONArrayPtr;
struct _virJSONObjectPair {
char *key;
virJSONValuePtr value;
};
struct _virJSONObject {
size_t npairs;
virJSONObjectPairPtr pairs;
};
struct _virJSONArray {
size_t nvalues;
virJSONValuePtr *values;
};
struct _virJSONValue {
int type; /* enum virJSONType */
bool protect; /* prevents deletion when embedded in another object */
union {
virJSONObject object;
virJSONArray array;
char *string;
char *number; /* int/float/etc format is context defined so we can't parse it here :-( */
int boolean;
} data;
};
typedef struct _virJSONParserState virJSONParserState; typedef struct _virJSONParserState virJSONParserState;
typedef virJSONParserState *virJSONParserStatePtr; typedef virJSONParserState *virJSONParserStatePtr;
struct _virJSONParserState { struct _virJSONParserState {
......
...@@ -42,44 +42,6 @@ typedef enum { ...@@ -42,44 +42,6 @@ typedef enum {
typedef struct _virJSONValue virJSONValue; typedef struct _virJSONValue virJSONValue;
typedef virJSONValue *virJSONValuePtr; typedef virJSONValue *virJSONValuePtr;
typedef struct _virJSONObject virJSONObject;
typedef virJSONObject *virJSONObjectPtr;
typedef struct _virJSONObjectPair virJSONObjectPair;
typedef virJSONObjectPair *virJSONObjectPairPtr;
typedef struct _virJSONArray virJSONArray;
typedef virJSONArray *virJSONArrayPtr;
struct _virJSONObjectPair {
char *key;
virJSONValuePtr value;
};
struct _virJSONObject {
size_t npairs;
virJSONObjectPairPtr pairs;
};
struct _virJSONArray {
size_t nvalues;
virJSONValuePtr *values;
};
struct _virJSONValue {
int type; /* enum virJSONType */
bool protect; /* prevents deletion when embedded in another object */
union {
virJSONObject object;
virJSONArray array;
char *string;
char *number; /* int/float/etc format is context defined so we can't parse it here :-( */
int boolean;
} data;
};
void virJSONValueFree(virJSONValuePtr value); void virJSONValueFree(virJSONValuePtr value);
void virJSONValueHashFree(void *opaque, const void *name); void virJSONValueHashFree(void *opaque, const void *name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册