[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v4 3/5] qobject: introduce qobject_get_str()
From: |
Amos Kong |
Subject: |
[Qemu-devel] [PATCH v4 3/5] qobject: introduce qobject_get_str() |
Date: |
Thu, 23 Jan 2014 22:46:34 +0800 |
Signed-off-by: Amos Kong <address@hidden>
---
include/qapi/qmp/qstring.h | 1 +
qobject/qstring.c | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/qapi/qmp/qstring.h b/include/qapi/qmp/qstring.h
index 1bc3666..56b17cb 100644
--- a/include/qapi/qmp/qstring.h
+++ b/include/qapi/qmp/qstring.h
@@ -28,6 +28,7 @@ QString *qstring_from_str(const char *str);
QString *qstring_from_substr(const char *str, int start, int end);
size_t qstring_get_length(const QString *qstring);
const char *qstring_get_str(const QString *qstring);
+const char *qobject_get_str(const QObject *obj);
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);
diff --git a/qobject/qstring.c b/qobject/qstring.c
index 607b7a1..c470a86 100644
--- a/qobject/qstring.c
+++ b/qobject/qstring.c
@@ -135,6 +135,25 @@ const char *qstring_get_str(const QString *qstring)
}
/**
+ * qobject_to_str(): Convert a QObject to QString and return
+ * a pointer to the stored string
+ */
+const char *qobject_get_str(const QObject *data)
+{
+ QString *qstr;
+
+ if (!data) {
+ return NULL;
+ }
+ qstr = qobject_to_qstring(data);
+ if (qstr) {
+ return qstring_get_str(qstr);
+ } else {
+ return NULL;
+ }
+}
+
+/**
* qstring_destroy_obj(): Free all memory allocated by a QString
* object
*/
--
1.8.4.2
[Qemu-devel] [PATCH v4 3/5] qobject: introduce qobject_get_str(),
Amos Kong <=
[Qemu-devel] [PATCH v4 5/5] update docs/qmp-full-introspection.txt, Amos Kong, 2014/01/23
Re: [Qemu-devel] [PATCH v4 0/5] QMP full introspection, Amos Kong, 2014/01/24