0

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?

4

1 回答 1

1

您可以使用任何Variant类型。的类型字符串int64x。然后,您可以使用Variant.int64来创建新变体并GLib.Settings.get_value对其GLib.Settings.set_value进行操作。

Variant在大多数情况下,Vala 还可以自动编组类型。如果您的架构设置正确,您可以简单地set_value使用 a调用,int64它将被自动编组。同样,如果您将返回get_valueto int64,它将被取消编组。

于 2014-12-04T18:48:18.330 回答