Re: [gnome-db] [Vala] Is there any way to deserialize something into object in vala?



I don't know about json-glib, but GDA uses a GObject/GLib C API to wrap C API from its providers, provides prepared SQL commands to be executed directly by the providers, and so on. Look at http://www.gnome-db.org/

Vala extensions are written in pure Vala. It just use GDA Vala bindings to get access to the Database and run queries to save/load fields, this is at least for GdaData.Record class. Record class is a pure Vala implementation that use Gee classes, it internally uses Gda.SqlBuilder to run queries on load or save data; they are run when you call update() or save() methods, but you can dinamically set fields' value using set_field(), no access to database are performer jet. An example for GdaData.Record is:

http://git.gnome.org/browse/libgda/tree/samples/vala/SampleDataObject.vala?id=b71b62ab68ddec29637f59dc05ae270ed10efee5

May be the only object you will get a penalty in performance (what are your requirements? Real Time?) will be GdaData.Table class, but just for update(), because it uses GDA's metadata updates to know fields, types, keys, foreign keys and referenced tables, but this is just for the first time, you will be able to use Gee classes to get access to metadata directly. With GdaData.Table you can create tables without run "CREATE" statements, just set the fields you need, keys, foreign keys and other data, and run save() to actually run a query into the database. I'm writing an example for Table class, but in the middle you can check Unit Tests at:

http://git.gnome.org/browse/libgda/tree/tests/vala/CheckTable.vala?id=b71b62ab68ddec29637f59dc05ae270ed10efee5



2012/3/22 marcin saepia net <marcin saepia net>
Hi Daniel,

thank you for your suggestion. I was considering GDA but as
performance is quite important in my project, I wanted to recreate
minimal subset of functionality of database abstraction layer by
myself and do that in Vala.

GDA is written in C, so it propably uses the same macros that
json-glib does. But I still wonder if it is possible to do that in
pure Vala?

m.

2012/3/22 Daniel Espinosa <esodan gmail com>:
> May you want to test GDA's Vala extensions.
>
> They provides a Record object that could be used as a base class for your
> objects and save all your properties directly to a database. Check out
> samples/vala code.
>
> Vala extensions are available from git.gnome.org/libgda
>
> El mar 20, 2012 7:04 a.m., "marcin saepia net" <marcin saepia net> escribió:
>>
>> Hi,
>>
>> I need to create a sort of abstraction layer between the database and
>> my vala app.
>>
>> It would be great if it was possible to interate over my class
>> properties, read they type etc. and dynamically map fields from the DB
>> to the properties.
>>
>> Is there any way to do that?
>>
>> I know that it is possible within GObject, as json-glib has that
>> functionality, but is it possible without access to low-level C
>> GLib/GObject macros? Only in Vala?
>>
>> m.
>> _______________________________________________
>> vala-list mailing list
>> vala-list gnome org
>> http://mail.gnome.org/mailman/listinfo/vala-list



--
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates: LIBRE)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]