LWN.net Logo

GVariant 0 released

From:  Ryan Lortie <desrt-AT-desrt.ca>
To:  gnome-announce-list-AT-gnome.org
Subject:  GVariant 0 released
Date:  Fri, 27 Mar 2009 14:16:30 -0400
Message-ID:  <49CD17FE.9010102@desrt.ca>
Archive-link:  Article, Thread

At long last, I am announcing the release of version 0 of GVariant.

GVariant is a datatype that can hold any value that you can send over 
DBus.  This includes booleans, bytes, 16, 32 and 64bit (un)signed 
integers, strings, object paths, signal strings, double precision 
floats, arrays, structs, dictionaries and variants.

GVariant is also a serialisation format in which any of the above value 
types may be stored.

GVariants are created with a number of possible constructor functions:

   GVariant *x = g_variant_new_int32 (123);
   GVariant *y = g_variant_new_string ("hello");

and can be accessed using a number of deconstructors:

   gint32 i = g_variant_get_int32 (x);

there is also a very rich set of functions allowing GVariant to be used 
with the varargs mechanism of C and allowing you to construct libraries 
featuring such APIs:

   GVariant *z = g_variant_new ("(iis)", 123, 456, "hello");

   const gchar *str;
   gint32 a, b;

   g_variant_get (z, "(iis)", &a, &b, &str);

Deconstruction of a container can also proceed in a more explicit way:

   GVariant *v = g_variant_get_child (z, 0);
   a = g_variant_get_int32 (v);
   g_variant_unref (v);

Floating reference counts are used when new GVariants are created, 
allowing statements like the following:

   GVariant *w = g_variant_new ("(sv)", "key",
                                g_variant_new_string ("value"));

There is an iterator interface (GVariantIter) and a builder interface 
(GVariantBuilder) for incremental access/construction to/of containers.

There is also an XML parser (based on GMarkup) and pretty printer for 
storing GVariant values in text format.  A GMarkup sub-parser is available.

The API is -approximately- stable (ie: no hard promises).  Some changes 
might occur with respect to varargs support but hopefully these changes 
will be compatible.

Sources are available at:         http://gnome.org/~ryanl/src/
GVariant is maintained in git:    git://git.desrt.ca/gvariant
gitweb access is available here:  http://git.desrt.ca/

Cheers
_______________________________________________
gnome-announce-list mailing list
gnome-announce-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gnome-announce-list



(Log in to post comments)

Copyright © 2009, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds