On 03/09/2018 02:59 AM, Peter Xu wrote:
A quick way to fetch string from qobject when it's a QString.
Reviewed-by: Fam Zheng <f...@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com>
Signed-off-by: Peter Xu <pet...@redhat.com>
---
include/qapi/qmp/qstring.h | 1 +
qobject/qstring.c | 11 +++++++++++
2 files changed, 12 insertions(+)
+++ b/qobject/qstring.c
@@ -137,6 +137,17 @@ const char *qstring_get_try_str(const QString *qstring)
return qstring ? qstring_get_str(qstring) : NULL;
}
+/**
+ * qobject_get_try_str(): Return a pointer to the corresponding string
+ *
+ * NOTE: the string will only be returned if the object is valid, and
+ * its type is QString, otherwise NULL is returned.
+ */
+const char *qobject_get_try_str(const QObject *qstring)
+{
+ return qstring_get_try_str(qobject_to_qstring(qstring));
Conflicts with Max's refactoring to a qobject_to() macro.
https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg06230.html
Whoever lands first gets to watch the other (or the maintainer) rebase ;)
Reviewed-by: Eric Blake <ebl...@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org