I am using GSettings in my Vala application to store some data. And one of my fields should store date. And all functions in Vala that manage date and time return int64 value.
I know how to store int values in GSettings schema, but I want to do it without converting int64 to int.
I know it's not a problem nowadays and I can safely convert int64 DateTime to int, but someday it will overflow and won't work correctly.
So, the question: is storing int64 in GSettings possible? And if yes, how?
You can use any
Varianttype. The type string forint64isx. You can then useVariant.int64to create a new variant andGLib.Settings.get_valueandGLib.Settings.set_valueto manipulate it.Vala can also marshal
Varianttypes automatically in most cases. If your schema is set correctly, you can simply callset_valuewith aint64and it will be automarshalled. Similarly, if you cast the return ofget_valuetoint64, it will be unmarhsalled.