[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 5/9] qom: add generic string parsing/printing
From: |
Andreas Färber |
Subject: |
Re: [Qemu-devel] [PATCH 5/9] qom: add generic string parsing/printing |
Date: |
Tue, 21 Feb 2012 21:47:06 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.1) Gecko/20120208 Thunderbird/10.0.1 |
Am 09.02.2012 15:31, schrieb Paolo Bonzini:
> Add generic property accessors that take a string and parse it
> appropriately for the property type. All the magic here is done
> by the new string-based visitors.
>
> Signed-off-by: Paolo Bonzini <address@hidden>
> ---
> include/qemu/object.h | 24 ++++++++++++++++++++++++
> qom/object.c | 24 ++++++++++++++++++++++++
> 2 files changed, 48 insertions(+), 0 deletions(-)
>
> diff --git a/include/qemu/object.h b/include/qemu/object.h
> index 7d50da9..af071eb 100644
> --- a/include/qemu/object.h
> +++ b/include/qemu/object.h
> @@ -730,6 +730,30 @@ void object_property_set(Object *obj, struct Visitor *v,
> const char *name,
> struct Error **errp);
>
> /**
> + * object_property_parse:
> + * @obj: the object
> + * @string: the string that will be used to parse the property value.
> + * @name: the name of the property
> + * @errp: returns an error if this function fails
> + *
> + * Parses a string and writes the result into a property of an object.
> + */
> +void object_property_parse(Object *obj, const char *string,
> + const char *name, struct Error **errp);
> +
> +/**
> + * object_property_set:
> + * @obj: the object
> + * @name: the name of the property
> + * @errp: returns an error if this function fails
> + *
> + * Returns a string representation of the value of the property. The
* Returns: for gtk-doc.
> + * caller shall free the string.
> + */
> +char *object_property_print(Object *obj, const char *name,
> + struct Error **errp);
> +
> +/**
> * @object_property_get_type:
(This non-PULL version will conflict here.)
> * @obj: the object
> * @name: the name of the property
> diff --git a/qom/object.c b/qom/object.c
> index 5e5b261..97d898f 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -782,6 +784,28 @@ int64_t object_property_get_int(Object *obj, const char
> *name,
> return retval;
> }
>
> +void object_property_parse(Object *obj, const char *string,
> + const char *name, Error **errp)
> +{
> + StringInputVisitor *mi;
Curious: where does mi/mo come from?
> + mi = string_input_visitor_new(string);
> + object_property_set(obj, string_input_get_visitor(mi), name, errp);
> +
> + string_input_visitor_cleanup(mi);
> +}
> +
> +char *object_property_print(Object *obj, const char *name,
> + Error **errp)
> +{
> + StringOutputVisitor *mo;
> + char *string;
> +
> + mo = string_output_visitor_new();
> + object_property_get(obj, string_output_get_visitor(mo), name, NULL);
> + string = string_output_get_string(mo);
> + string_output_visitor_cleanup(mo);
> + return string;
> +}
Empty line please. Otherwise Liked-by: Andreas Färber <address@hidden>
> const char *object_property_get_type(Object *obj, const char *name, Error
> **errp)
> {
> ObjectProperty *prop = object_property_find(obj, name);
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
- [Qemu-devel] [PATCH 1/9] qapi: allow sharing enum implementation across visitors, (continued)
- [Qemu-devel] [PATCH 1/9] qapi: allow sharing enum implementation across visitors, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 2/9] qapi: drop qmp_input_end_optional, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 3/9] qapi: add string-based visitors, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 6/9] qdev: accept both strings and integers for PCI addresses, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 4/9] qapi: add tests for string-based visitors, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 7/9] qdev: accept hex properties only if prefixed by 0x, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 8/9] qdev: use built-in QOM string parser, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PATCH 5/9] qom: add generic string parsing/printing, Paolo Bonzini, 2012/02/09
- Re: [Qemu-devel] [PATCH 5/9] qom: add generic string parsing/printing,
Andreas Färber <=
- [Qemu-devel] [PATCH 9/9] qdev: drop unnecessary parse/print methods, Paolo Bonzini, 2012/02/09
- [Qemu-devel] [PULL v2 0/9] qdev deconstruction, command-line episode, Paolo Bonzini, 2012/02/21