From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RzwcD-0005eT-Vk for qemu-devel@nongnu.org; Tue, 21 Feb 2012 15:47:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Rzwc8-0004NS-SN for qemu-devel@nongnu.org; Tue, 21 Feb 2012 15:47:13 -0500 Received: from cantor2.suse.de ([195.135.220.15]:36153 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Rzwc8-0004Mp-9D for qemu-devel@nongnu.org; Tue, 21 Feb 2012 15:47:08 -0500 Message-ID: <4F4402CA.2080206@suse.de> Date: Tue, 21 Feb 2012 21:47:06 +0100 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1328797918-1316-1-git-send-email-pbonzini@redhat.com> <1328797918-1316-6-git-send-email-pbonzini@redhat.com> In-Reply-To: <1328797918-1316-6-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 5/9] qom: add generic string parsing/printing List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org 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. >=20 > Signed-off-by: Paolo Bonzini > --- > include/qemu/object.h | 24 ++++++++++++++++++++++++ > qom/object.c | 24 ++++++++++++++++++++++++ > 2 files changed, 48 insertions(+), 0 deletions(-) >=20 > 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 Visit= or *v, const char *name, > struct Error **errp); > =20 > /** > + * 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; > } > =20 > +void object_property_parse(Object *obj, const char *string, > + const char *name, Error **errp) > +{ > + StringInputVisitor *mi; Curious: where does mi/mo come from? > + mi =3D 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 =3D string_output_visitor_new(); > + object_property_get(obj, string_output_get_visitor(mo), name, NULL= ); > + string =3D string_output_get_string(mo); > + string_output_visitor_cleanup(mo); > + return string; > +} Empty line please. Otherwise Liked-by: Andreas F=E4rber > const char *object_property_get_type(Object *obj, const char *name, Er= ror **errp) > { > ObjectProperty *prop =3D object_property_find(obj, name); Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg