qobject: introduce qobject_get_try_str()

A quick way to fetch string from qobject when it's a QString.

Backports commit b26ae1cb8eb0756524e322169138830b9b542311 from qemu
This commit is contained in:
Peter Xu 2018-03-20 11:09:43 -04:00 committed by Lioncash
parent 6446b66dc7
commit a6ee6f1a87
No known key found for this signature in database
GPG Key ID: 4E3C3CC1031BA9C7
16 changed files with 26 additions and 0 deletions

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_aarch64
#define qlit_equal_qobject qlit_equal_qobject_aarch64
#define qobject_from_qlit qobject_from_qlit_aarch64
#define qobject_get_try_str qobject_get_try_str_aarch64
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_aarch64
#define qobject_input_end_list qobject_input_end_list_aarch64
#define qobject_input_end_struct qobject_input_end_struct_aarch64

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_aarch64eb
#define qlit_equal_qobject qlit_equal_qobject_aarch64eb
#define qobject_from_qlit qobject_from_qlit_aarch64eb
#define qobject_get_try_str qobject_get_try_str_aarch64eb
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_aarch64eb
#define qobject_input_end_list qobject_input_end_list_aarch64eb
#define qobject_input_end_struct qobject_input_end_struct_aarch64eb

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_arm
#define qlit_equal_qobject qlit_equal_qobject_arm
#define qobject_from_qlit qobject_from_qlit_arm
#define qobject_get_try_str qobject_get_try_str_arm
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_arm
#define qobject_input_end_list qobject_input_end_list_arm
#define qobject_input_end_struct qobject_input_end_struct_arm

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_armeb
#define qlit_equal_qobject qlit_equal_qobject_armeb
#define qobject_from_qlit qobject_from_qlit_armeb
#define qobject_get_try_str qobject_get_try_str_armeb
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_armeb
#define qobject_input_end_list qobject_input_end_list_armeb
#define qobject_input_end_struct qobject_input_end_struct_armeb

View File

@ -2210,6 +2210,7 @@ symbols = (
'qlist_type',
'qlit_equal_qobject',
'qobject_from_qlit',
'qobject_get_try_str',
'qobject_input_end_implicit_struct',
'qobject_input_end_list',
'qobject_input_end_struct',

View File

@ -29,6 +29,7 @@ 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 *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);

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_m68k
#define qlit_equal_qobject qlit_equal_qobject_m68k
#define qobject_from_qlit qobject_from_qlit_m68k
#define qobject_get_try_str qobject_get_try_str_m68k
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_m68k
#define qobject_input_end_list qobject_input_end_list_m68k
#define qobject_input_end_struct qobject_input_end_struct_m68k

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_mips
#define qlit_equal_qobject qlit_equal_qobject_mips
#define qobject_from_qlit qobject_from_qlit_mips
#define qobject_get_try_str qobject_get_try_str_mips
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mips
#define qobject_input_end_list qobject_input_end_list_mips
#define qobject_input_end_struct qobject_input_end_struct_mips

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_mips64
#define qlit_equal_qobject qlit_equal_qobject_mips64
#define qobject_from_qlit qobject_from_qlit_mips64
#define qobject_get_try_str qobject_get_try_str_mips64
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mips64
#define qobject_input_end_list qobject_input_end_list_mips64
#define qobject_input_end_struct qobject_input_end_struct_mips64

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_mips64el
#define qlit_equal_qobject qlit_equal_qobject_mips64el
#define qobject_from_qlit qobject_from_qlit_mips64el
#define qobject_get_try_str qobject_get_try_str_mips64el
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mips64el
#define qobject_input_end_list qobject_input_end_list_mips64el
#define qobject_input_end_struct qobject_input_end_struct_mips64el

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_mipsel
#define qlit_equal_qobject qlit_equal_qobject_mipsel
#define qobject_from_qlit qobject_from_qlit_mipsel
#define qobject_get_try_str qobject_get_try_str_mipsel
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_mipsel
#define qobject_input_end_list qobject_input_end_list_mipsel
#define qobject_input_end_struct qobject_input_end_struct_mipsel

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_powerpc
#define qlit_equal_qobject qlit_equal_qobject_powerpc
#define qobject_from_qlit qobject_from_qlit_powerpc
#define qobject_get_try_str qobject_get_try_str_powerpc
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_powerpc
#define qobject_input_end_list qobject_input_end_list_powerpc
#define qobject_input_end_struct qobject_input_end_struct_powerpc

View File

@ -134,6 +134,17 @@ bool qstring_is_equal(const QObject *x, const QObject *y)
qobject_to(QString, y)->string);
}
/**
* 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));
}
/**
* qstring_destroy_obj(): Free all memory allocated by a QString
* object

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_sparc
#define qlit_equal_qobject qlit_equal_qobject_sparc
#define qobject_from_qlit qobject_from_qlit_sparc
#define qobject_get_try_str qobject_get_try_str_sparc
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_sparc
#define qobject_input_end_list qobject_input_end_list_sparc
#define qobject_input_end_struct qobject_input_end_struct_sparc

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_sparc64
#define qlit_equal_qobject qlit_equal_qobject_sparc64
#define qobject_from_qlit qobject_from_qlit_sparc64
#define qobject_get_try_str qobject_get_try_str_sparc64
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_sparc64
#define qobject_input_end_list qobject_input_end_list_sparc64
#define qobject_input_end_struct qobject_input_end_struct_sparc64

View File

@ -2204,6 +2204,7 @@
#define qlist_type qlist_type_x86_64
#define qlit_equal_qobject qlit_equal_qobject_x86_64
#define qobject_from_qlit qobject_from_qlit_x86_64
#define qobject_get_try_str qobject_get_try_str_x86_64
#define qobject_input_end_implicit_struct qobject_input_end_implicit_struct_x86_64
#define qobject_input_end_list qobject_input_end_list_x86_64
#define qobject_input_end_struct qobject_input_end_struct_x86_64