aboutsummaryrefslogtreecommitdiff
path: root/qapi/string-output-visitor.c
diff options
context:
space:
mode:
authorGreg Kurz <groug@kaod.org>2016-12-16 16:26:09 +0100
committerDavid Gibson <david@gibson.dropbear.id.au>2017-06-30 14:03:31 +1000
commita733371214b68881d84725a3c71f60e2faf3b8e2 (patch)
tree36a11ce27647b240620421fac38448a43bcac0e6 /qapi/string-output-visitor.c
parent6d034b7bf8d1c20f193b00fd6434adf399d701da (diff)
qapi: add explicit null to string input and output visitors
This may be used for deprecated object properties that are kept for backwards compatibility. Signed-off-by: Greg Kurz <groug@kaod.org> Reviewed-by: Markus Armbruster <armbru@redhat.com> Tested-by: Andrea Bolognani <abologna@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'qapi/string-output-visitor.c')
-rw-r--r--qapi/string-output-visitor.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/qapi/string-output-visitor.c b/qapi/string-output-visitor.c
index 53c2175d81..af649e1d6e 100644
--- a/qapi/string-output-visitor.c
+++ b/qapi/string-output-visitor.c
@@ -256,6 +256,19 @@ static void print_type_number(Visitor *v, const char *name, double *obj,
string_output_set(sov, g_strdup_printf("%f", *obj));
}
+static void print_type_null(Visitor *v, const char *name, Error **errp)
+{
+ StringOutputVisitor *sov = to_sov(v);
+ char *out;
+
+ if (sov->human) {
+ out = g_strdup("<null>");
+ } else {
+ out = g_strdup("");
+ }
+ string_output_set(sov, out);
+}
+
static void
start_list(Visitor *v, const char *name, GenericList **list, size_t size,
Error **errp)
@@ -341,6 +354,7 @@ Visitor *string_output_visitor_new(bool human, char **result)
v->visitor.type_bool = print_type_bool;
v->visitor.type_str = print_type_str;
v->visitor.type_number = print_type_number;
+ v->visitor.type_null = print_type_null;
v->visitor.start_list = start_list;
v->visitor.next_list = next_list;
v->visitor.end_list = end_list;