diff options
Diffstat (limited to 'include/qapi')
-rw-r--r-- | include/qapi/qmp/json-writer.h | 35 | ||||
-rw-r--r-- | include/qapi/qmp/qbool.h | 2 | ||||
-rw-r--r-- | include/qapi/qmp/qdict.h | 2 | ||||
-rw-r--r-- | include/qapi/qmp/qjson.h | 4 | ||||
-rw-r--r-- | include/qapi/qmp/qlist.h | 2 | ||||
-rw-r--r-- | include/qapi/qmp/qnull.h | 2 | ||||
-rw-r--r-- | include/qapi/qmp/qnum.h | 3 | ||||
-rw-r--r-- | include/qapi/qmp/qobject.h | 9 | ||||
-rw-r--r-- | include/qapi/qmp/qstring.h | 14 |
9 files changed, 40 insertions, 33 deletions
diff --git a/include/qapi/qmp/json-writer.h b/include/qapi/qmp/json-writer.h new file mode 100644 index 0000000000..b70ba64077 --- /dev/null +++ b/include/qapi/qmp/json-writer.h @@ -0,0 +1,35 @@ +/* + * JSON Writer + * + * Copyright (c) 2020 Red Hat Inc. + * + * Authors: + * Markus Armbruster <armbru@redhat.com> + * + * This work is licensed under the terms of the GNU LGPL, version 2.1 or later. + * See the COPYING.LIB file in the top-level directory. + * + */ + +#ifndef JSON_WRITER_H +#define JSON_WRITER_H + +JSONWriter *json_writer_new(bool pretty); +const char *json_writer_get(JSONWriter *); +GString *json_writer_get_and_free(JSONWriter *); +void json_writer_free(JSONWriter *); + +G_DEFINE_AUTOPTR_CLEANUP_FUNC(JSONWriter, json_writer_free) + +void json_writer_start_object(JSONWriter *, const char *name); +void json_writer_end_object(JSONWriter *); +void json_writer_start_array(JSONWriter *, const char *name); +void json_writer_end_array(JSONWriter *); +void json_writer_bool(JSONWriter *, const char *name, bool val); +void json_writer_null(JSONWriter *, const char *name); +void json_writer_int64(JSONWriter *, const char *name, int64_t val); +void json_writer_uint64(JSONWriter *, const char *name, uint64_t val); +void json_writer_double(JSONWriter *, const char *name, double val); +void json_writer_str(JSONWriter *, const char *name, const char *str); + +#endif diff --git a/include/qapi/qmp/qbool.h b/include/qapi/qmp/qbool.h index 5f61e38e64..2f888d1057 100644 --- a/include/qapi/qmp/qbool.h +++ b/include/qapi/qmp/qbool.h @@ -23,7 +23,5 @@ struct QBool { QBool *qbool_from_bool(bool value); bool qbool_get_bool(const QBool *qb); -bool qbool_is_equal(const QObject *x, const QObject *y); -void qbool_destroy_obj(QObject *obj); #endif /* QBOOL_H */ diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index da942347a7..9934539c1b 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -39,10 +39,8 @@ void qdict_put_obj(QDict *qdict, const char *key, QObject *value); void qdict_del(QDict *qdict, const char *key); int qdict_haskey(const QDict *qdict, const char *key); QObject *qdict_get(const QDict *qdict, const char *key); -bool qdict_is_equal(const QObject *x, const QObject *y); const QDictEntry *qdict_first(const QDict *qdict); const QDictEntry *qdict_next(const QDict *qdict, const QDictEntry *entry); -void qdict_destroy_obj(QObject *obj); /* Helper to qdict_put_obj(), accepts any object */ #define qdict_put(qdict, key, obj) \ diff --git a/include/qapi/qmp/qjson.h b/include/qapi/qmp/qjson.h index 5ebbe5a118..593b40b4e0 100644 --- a/include/qapi/qmp/qjson.h +++ b/include/qapi/qmp/qjson.h @@ -25,7 +25,7 @@ QDict *qdict_from_vjsonf_nofail(const char *string, va_list ap) QDict *qdict_from_jsonf_nofail(const char *string, ...) GCC_FMT_ATTR(1, 2); -QString *qobject_to_json(const QObject *obj); -QString *qobject_to_json_pretty(const QObject *obj); +GString *qobject_to_json(const QObject *obj); +GString *qobject_to_json_pretty(const QObject *obj, bool pretty); #endif /* QJSON_H */ diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index 595b7943e1..06e98ad5f4 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -51,8 +51,6 @@ QObject *qlist_pop(QList *qlist); QObject *qlist_peek(QList *qlist); int qlist_empty(const QList *qlist); size_t qlist_size(const QList *qlist); -bool qlist_is_equal(const QObject *x, const QObject *y); -void qlist_destroy_obj(QObject *obj); static inline const QListEntry *qlist_first(const QList *qlist) { diff --git a/include/qapi/qmp/qnull.h b/include/qapi/qmp/qnull.h index c1426882c5..e84ecceedb 100644 --- a/include/qapi/qmp/qnull.h +++ b/include/qapi/qmp/qnull.h @@ -26,6 +26,4 @@ static inline QNull *qnull(void) return qobject_ref(&qnull_); } -bool qnull_is_equal(const QObject *x, const QObject *y); - #endif /* QNULL_H */ diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h index bbae0a5ec8..7f84e20bfb 100644 --- a/include/qapi/qmp/qnum.h +++ b/include/qapi/qmp/qnum.h @@ -68,7 +68,4 @@ double qnum_get_double(QNum *qn); char *qnum_to_string(QNum *qn); -bool qnum_is_equal(const QObject *x, const QObject *y); -void qnum_destroy_obj(QObject *obj); - #endif /* QNUM_H */ diff --git a/include/qapi/qmp/qobject.h b/include/qapi/qmp/qobject.h index fcfd549220..9003b71fd3 100644 --- a/include/qapi/qmp/qobject.h +++ b/include/qapi/qmp/qobject.h @@ -64,14 +64,6 @@ QEMU_BUILD_BUG_MSG(QTYPE__MAX != 7, #define qobject_to(type, obj) \ ((type *)qobject_check_type(obj, glue(QTYPE_CAST_TO_, type))) -/* Initialize an object to default values */ -static inline void qobject_init(QObject *obj, QType type) -{ - assert(QTYPE_NONE < type && type < QTYPE__MAX); - obj->base.refcnt = 1; - obj->base.type = type; -} - static inline void qobject_ref_impl(QObject *obj) { if (obj) { @@ -90,6 +82,7 @@ bool qobject_is_equal(const QObject *x, const QObject *y); /** * qobject_destroy(): Free resources used by the object + * For use via qobject_unref() only! */ void qobject_destroy(QObject *obj); diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h index e2e356e5e7..1d8ba46936 100644 --- a/include/qapi/qmp/qstring.h +++ b/include/qapi/qmp/qstring.h @@ -17,23 +17,13 @@ struct QString { struct QObjectBase_ base; - char *string; - size_t length; - size_t capacity; + const char *string; }; QString *qstring_new(void); QString *qstring_from_str(const char *str); QString *qstring_from_substr(const char *str, size_t start, size_t end); -size_t qstring_get_length(const QString *qstring); +QString *qstring_from_gstring(GString *gstr); const char *qstring_get_str(const QString *qstring); -const char *qstring_get_try_str(const QString *qstring); -const char *qobject_get_try_str(const QObject *qstring); -void qstring_append_int(QString *qstring, int64_t value); -void qstring_append(QString *qstring, const char *str); -void qstring_append_chr(QString *qstring, int c); -bool qstring_is_equal(const QObject *x, const QObject *y); -char *qstring_free(QString *qstring, bool return_str); -void qstring_destroy_obj(QObject *obj); #endif /* QSTRING_H */ |