Tutorial by Examples

To initialize struct, you can do like this : public static void main (string[] args) { Value val = Value (typeof (int)); val.set_int (33); } But Vala brings another way to initialize values : public static void main (string[] args) { Value val = 33; } Your value is initializ...
Use one of GLib.Value get methods (see valadoc documentation) or cast your value with the type of your value : public static void main (string[] args) { Value val = 33; int i = val.get_int(); int j = (int)val; } Note : if your current value doesn't contain desired type, GObject s...
This exemple shows how you can pass several types in function parameters : static void print_value (Value val) { print ("value-type : %s\n", val.type().name()); print ("value-content : %s\n\n", val.strdup_contents()); } public static void main (string[] args) { ...
In previous example, Value.strdup_contents prints GLib.DateTime as pointer address. You can register functions that will transform value to desired type. First, create a function that will have this signature : static void datetime_to_string (Value src_value, ref Value dest_value) { DateTime ...

Page 1 of 1