Top |
#define | NCM_TYPE_SERIALIZE |
enum | NcmSerializeOpt |
#define | NCM_SERIALIZE_PROPERTY_TYPE |
#define | NCM_SERIALIZE_PROPERTIES_TYPE |
#define | NCM_SERIALIZE_OBJECT_TYPE |
#define | NCM_SERIALIZE_OBJECT_FORMAT |
#define | NCM_SERIALIZE_OBJECT_ARRAY_TYPE |
#define | NCM_SERIALIZE_OBJECT_ARRAY_POS_STR |
#define | NCM_SERIALIZE_OBJECT_ARRAY_OBJ_NAME_STR |
#define | NCM_SERIALIZE_OBJECT_DICT_STR_TYPE |
#define | NCM_SERIALIZE_OBJECT_DICT_INT_TYPE |
#define | NCM_SERIALIZE_VAR_DICT_TYPE |
#define | NCM_SERIALIZE_VECTOR_TYPE |
#define | NCM_SERIALIZE_MATRIX_TYPE |
#define | NCM_SERIALIZE_STRV_TYPE |
#define | NCM_SERIALIZE_AUTOSAVE_NAME |
#define | NCM_SERIALIZE_AUTOSAVE_NFORMAT |
NcmSerialize |
This object provides serialization, deserialization and duplication of objects. The serialization process is based on the GObject object system.
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed. The reverse process is called deserialization.
One support for serialized data GVariant. The GVariant is a type-safe, reference counted, immutable, and memory-efficient container for arbitrary data. It is a generic container that can hold any type of data, including basic types such as integers and floating point numbers, strings, and byte arrays, as well as more complex types such as tuples, dictionaries, and variants. The GVariant type system is designed to be extensible, so that new types can be added in the future. A serialized GVariant object can be stored in binary or text format.
NcmSerialize *
ncm_serialize_new (NcmSerializeOpt sopt
);
Creates a new NcmSerialize object.
NcmSerialize *
ncm_serialize_ref (NcmSerialize *ser
);
Increases the reference count of ser
by one.
void
ncm_serialize_free (NcmSerialize *ser
);
Decreases the reference count of ser
by one.
void
ncm_serialize_clear (NcmSerialize **ser
);
Decreases the reference count of *ser
by one, and sets *ser
to NULL.
void ncm_serialize_reset (NcmSerialize *ser
,gboolean autosave_only
);
Releases all objects in ser
and erase all serialized
objects. If autosave_only
is TRUE it will release only
autosaved objects.
void ncm_serialize_clear_instances (NcmSerialize *ser
,gboolean autosave_only
);
Releases all objects in ser
. If autosave_only
is TRUE
it will release only autosaved objects.
void
ncm_serialize_log_stats (NcmSerialize *ser
);
Releases all objects in ser
.
gboolean ncm_serialize_contain_instance (NcmSerialize *ser
,gpointer obj
);
Checks if the GObject instance obj
is contained in ser
.
gboolean ncm_serialize_contain_name (NcmSerialize *ser
,const gchar *name
);
Checks if there is an instance named name
in ser
.
guint
ncm_serialize_count_instances (NcmSerialize *ser
);
Counts the number of instances registered in ser
.
guint
ncm_serialize_count_saved_serializations
(NcmSerialize *ser
);
Counts the number of instances registered in ser
.
gpointer ncm_serialize_peek_by_name (NcmSerialize *ser
,const gchar *name
);
Peeks the instance name
or null if there isn't a instance named name
.
gpointer ncm_serialize_get_by_name (NcmSerialize *ser
,const gchar *name
);
Gets a new reference for the instance name
or null if there isn't a instance named name
.
gchar * ncm_serialize_peek_name (NcmSerialize *ser
,gpointer obj
);
Gets the named associated to the instance obj
, it is an error to call this function
when the obj
is not contained in ser
.
void ncm_serialize_set (NcmSerialize *ser
,gpointer obj
,const gchar *name
,gboolean overwrite
);
Adds the object obj
to ser
using name
.
ser |
a NcmSerialize. |
|
obj |
a GObject. |
[type GObject] |
name |
the |
|
overwrite |
whether to overwrite if there is already an object named |
void ncm_serialize_unset (NcmSerialize *ser
,gpointer obj
);
Removes the object obj
to ser
using name
, it does nothing
if the instance obj
is not present in ser
.
void ncm_serialize_remove_ser (NcmSerialize *ser
,gpointer obj
);
Removes the object obj
to ser
using name
, it does nothing
if the instance obj
is not present in ser
.
gboolean ncm_serialize_is_named (NcmSerialize *ser
,const gchar *serobj
,gchar **name
);
Checks if serobj
is a named serialized object, if so sets its name in name
and returns TRUE.
ser |
a NcmSerialize. |
|
serobj |
serialized object. |
|
name |
object name. |
[allow-none][out][transfer full] |
void ncm_serialize_set_property (NcmSerialize *ser
,GObject *obj
,const gchar *prop_str
);
Deserialize the set of object properties in params
and sets the obj
.
void ncm_serialize_set_property_from_key_file (NcmSerialize *ser
,GObject *obj
,const gchar *prop_file
);
Deserializes the set of object properties in prop_file
and sets the obj
.
ser |
a NcmSerialize. |
|
obj |
a GObject. |
|
prop_file |
a GKeyFile file containing the parameters to set. |
GObject * ncm_serialize_from_variant (NcmSerialize *ser
,GVariant *var_obj
);
Deserialize and returns the newly created object.
NcmObjArray * ncm_serialize_array_from_variant (NcmSerialize *ser
,GVariant *var
);
Creates a new NcmObjArray from a GVariant.
NcmObjDictStr * ncm_serialize_dict_str_from_variant (NcmSerialize *ser
,GVariant *var
);
Creates a new NcmObjDictStr from a GVariant.
NcmObjDictInt * ncm_serialize_dict_int_from_variant (NcmSerialize *ser
,GVariant *var
);
Creates a new NcmObjDictInt from a GVariant.
NcmVarDict * ncm_serialize_var_dict_from_variant (NcmSerialize *ser
,GVariant *var
);
Creates a new NcmVarDict from a GVariant.
GObject * ncm_serialize_from_name_params (NcmSerialize *ser
,const gchar *obj_name
,GVariant *params
);
Parses the serialized parameters and returns the newly created object using them.
ser |
a NcmSerialize. |
|
obj_name |
string containing the object name. |
|
params |
a GVariant containing the object parameters. |
GObject * ncm_serialize_from_string (NcmSerialize *ser
,const gchar *obj_ser
);
Parses the serialized and returns the newly created object.
GObject * ncm_serialize_from_yaml (NcmSerialize *ser
,const gchar *yaml_obj
);
Parses the serialized string in yaml_obj
and returns the newly created object.
NcmObjArray * ncm_serialize_array_from_yaml (NcmSerialize *ser
,const gchar *yaml_obj
);
Parses the serialized string in yaml_obj
and returns an array of newly created objects.
NcmObjDictStr * ncm_serialize_dict_str_from_yaml (NcmSerialize *ser
,const gchar *yaml_obj
);
Parses the serialized string in yaml_obj
and returns a NcmObjDictStr containing
the object names as keys and the serialized objects as values.
NcmObjDictInt * ncm_serialize_dict_int_from_yaml (NcmSerialize *ser
,const gchar *yaml_obj
);
Parses the serialized string in yaml_obj
and returns a NcmObjDictInt containing
the object names as keys and the serialized objects as values.
NcmVarDict * ncm_serialize_var_dict_from_yaml (NcmSerialize *ser
,const gchar *yaml_obj
);
Parses the serialized string in yaml_obj
and returns a NcmVarDict containing
the object names as keys and the serialized objects as values.
GObject * ncm_serialize_from_file (NcmSerialize *ser
,const gchar *filename
);
Parses the serialized string in filename
and returns the newly created object.
GObject * ncm_serialize_from_binfile (NcmSerialize *ser
,const gchar *filename
);
Parses the serialized binary data in filename
and returns the newly created object.
ser |
a NcmSerialize. |
|
filename |
File containing the binary serialized version of the object. |
NcmVarDict * ncm_serialize_var_dict_from_variant_file (NcmSerialize *ser
,const gchar *filename
,gboolean binary
);
Parses the serialized string in filename
and returns a NcmVarDict containing
the object names as keys and the serialized objects as values.
ser |
||
filename |
File containing the serialized version of the NcmVarDict |
|
binary |
Whether the file contains binary data or not |
GObject * ncm_serialize_from_yaml_file (NcmSerialize *ser
,const gchar *filename
);
Parses the YAML in filename
and returns the newly created object.
NcmObjArray * ncm_serialize_array_from_key_file (NcmSerialize *ser
,const gchar *filename
);
Loads a NcmObjArray from a file using a NcmSerialize and a GKeyFile.
NcmObjArray * ncm_serialize_array_from_yaml_file (NcmSerialize *ser
,const gchar *filename
);
Parses the YAML in filename
and returns an array of newly created objects.
NcmObjDictStr * ncm_serialize_dict_str_from_yaml_file (NcmSerialize *ser
,const gchar *filename
);
Parses the YAML in filename
and returns a NcmObjDictStr containing
NcmObjDictInt * ncm_serialize_dict_int_from_yaml_file (NcmSerialize *ser
,const gchar *filename
);
Parses the YAML in filename
and returns a NcmObjDictInt containing
NcmVarDict * ncm_serialize_var_dict_from_yaml_file (NcmSerialize *ser
,const gchar *filename
);
Parses the YAML in filename
and returns a NcmVarDict containing
the element names as keys and their values.
GVariant * ncm_serialize_gvalue_to_gvariant (NcmSerialize *ser
,GValue *val
);
Converts a GValue to a GVariant.
GVariant * ncm_serialize_to_variant (NcmSerialize *ser
,GObject *obj
);
Serialize the obj
to a GVariant
representation.
GVariant * ncm_serialize_array_to_variant (NcmSerialize *ser
,NcmObjArray *oa
);
Serializes a NcmObjArray to a GVariant.
GVariant * ncm_serialize_dict_str_to_variant (NcmSerialize *ser
,NcmObjDictStr *ods
);
Serializes a NcmObjDictStr to a GVariant.
GVariant * ncm_serialize_dict_int_to_variant (NcmSerialize *ser
,NcmObjDictInt *odi
);
Serializes a NcmObjDictInt to a GVariant.
GVariant * ncm_serialize_var_dict_to_variant (NcmSerialize *ser
,NcmVarDict *vd
);
Serializes a NcmVarDict to a GVariant.
gchar * ncm_serialize_to_string (NcmSerialize *ser
,GObject *obj
,gboolean valid_variant
);
Serialize the object obj
to a string.
ser |
a NcmSerialize. |
|
obj |
a GObject. |
|
valid_variant |
whether to use a valid GVariant representation. |
gchar * ncm_serialize_to_yaml (NcmSerialize *ser
,GObject *obj
);
Serialize the object obj
to a YAML string.
gchar * ncm_serialize_array_to_yaml (NcmSerialize *ser
,NcmObjArray *oa
);
Serialize the NcmObjArray oa
to a YAML string.
gchar * ncm_serialize_dict_str_to_yaml (NcmSerialize *ser
,NcmObjDictStr *ods
);
Serialize the NcmObjDictStr ods
to a YAML string.
gchar * ncm_serialize_dict_int_to_yaml (NcmSerialize *ser
,NcmObjDictInt *odi
);
Serialize the NcmObjDictInt odi
to a YAML string.
gchar * ncm_serialize_var_dict_to_yaml (NcmSerialize *ser
,NcmVarDict *dict
);
Serialize the NcmVarDict dict
to a YAML string.
void ncm_serialize_to_file (NcmSerialize *ser
,GObject *obj
,const gchar *filename
);
Serializes obj
and saves the string in filename
.
void ncm_serialize_to_binfile (NcmSerialize *ser
,GObject *obj
,const gchar *filename
);
Serializes obj
and saves the binary in filename
.
void ncm_serialize_var_dict_to_variant_file (NcmSerialize *ser
,NcmVarDict *vd
,const gchar *filename
,gboolean binary
);
Serializes vd
and saves the variant string in filename
.
void ncm_serialize_to_yaml_file (NcmSerialize *ser
,GObject *obj
,const gchar *filename
);
Serializes obj
and saves the YAML string in filename
.
void ncm_serialize_array_to_key_file (NcmSerialize *ser
,NcmObjArray *oa
,const gchar *filename
,gboolean save_comment
);
Saves a NcmObjArray to a file using a NcmSerialize and a GKeyFile.
void ncm_serialize_array_to_yaml_file (NcmSerialize *ser
,NcmObjArray *oa
,const gchar *filename
);
Saves a NcmObjArray to a file using a NcmSerialize and a YAML string.
void ncm_serialize_dict_str_to_yaml_file (NcmSerialize *ser
,NcmObjDictStr *ods
,const gchar *filename
);
Saves a NcmObjDictStr to a file using a NcmSerialize and a YAML string.
void ncm_serialize_dict_int_to_yaml_file (NcmSerialize *ser
,NcmObjDictInt *odi
,const gchar *filename
);
Saves a NcmObjDictInt to a file using a NcmSerialize and a YAML string.
void ncm_serialize_var_dict_to_yaml_file (NcmSerialize *ser
,NcmVarDict *vd
,const gchar *filename
);
Saves a NcmVarDict to a file using a NcmSerialize and a YAML string.
GObject * ncm_serialize_dup_obj (NcmSerialize *ser
,GObject *obj
);
Duplicates obj
by serializing and deserializing a new object.
NcmObjArray * ncm_serialize_dup_array (NcmSerialize *ser
,NcmObjArray *oa
);
Duplicates a NcmObjArray, all objects are duplicated.
gchar * ncm_serialize_variant_to_yaml (NcmSerialize *ser
,GVariant *var_obj
);
Converts a GObject serialized to a GVariant to a YAML string.
NcmSerialize *
ncm_serialize_global (void
);
Gets the global serialization object, instanciates it if necessary.
void
ncm_serialize_global_reset (gboolean autosave_only
);
Releases all objects in global NcmSerialize and erase all serialized objects.
void
ncm_serialize_global_clear_instances (gboolean autosave_only
);
Releases all objects in global NcmSerialize.
void
ncm_serialize_global_log_stats (void
);
Releases all objects in global NcmSerialize.
gboolean
ncm_serialize_global_contain_instance (gpointer obj
);
Global version of ncm_serialize_contain_instance()
.
gboolean
ncm_serialize_global_contain_name (const gchar *name
);
Global version of ncm_serialize_contain_name()
.
guint
ncm_serialize_global_count_instances (void
);
Global version of ncm_serialize_count_instances()
.
guint
ncm_serialize_global_count_saved_serializations
(void
);
Global version of ncm_serialize_count_saved_serializations()
.
gpointer
ncm_serialize_global_get_by_name (const gchar *name
);
Global version of ncm_serialize_get_by_name()
.
gchar *
ncm_serialize_global_global_peek_name (gpointer obj
);
void ncm_serialize_global_set (gpointer obj
,const gchar *name
,gboolean overwrite
);
Global version of ncm_serialize_set()
.
void
ncm_serialize_global_unset (gpointer obj
);
Global version of ncm_serialize_unset()
.
void
ncm_serialize_global_remove_ser (gpointer obj
);
Global version of ncm_serialize_remove_ser()
.
gboolean ncm_serialize_global_is_named (const gchar *serobj
,gchar **name
);
Global version of ncm_serialize_is_named()
.
void ncm_serialize_global_set_property (GObject *obj
,const gchar *prop_str
);
Global version of ncm_serialize_set_property()
.
void ncm_serialize_global_set_property_from_key_file (GObject *obj
,const gchar *prop_file
);
Global version of ncm_serialize_set_property()
.
GObject *
ncm_serialize_global_from_variant (GVariant *var_obj
);
Global version of ncm_serialize_from_variant()
.
GObject * ncm_serialize_global_from_name_params (const gchar *obj_name
,GVariant *params
);
Global version of ncm_serialize_from_name_params()
.
GObject *
ncm_serialize_global_from_string (const gchar *obj_ser
);
Global version of ncm_serialize_from_string()
.
GObject *
ncm_serialize_global_from_yaml (const gchar *yaml_obj
);
Global version of ncm_serialize_from_yaml()
.
GObject *
ncm_serialize_global_from_file (const gchar *filename
);
Global version of ncm_serialize_from_file()
.
GObject *
ncm_serialize_global_from_binfile (const gchar *filename
);
Global version of ncm_serialize_from_binfile()
.
GObject *
ncm_serialize_global_from_yaml_file (const gchar *filename
);
Global version of ncm_serialize_from_yaml_file()
.
GVariant *
ncm_serialize_global_gvalue_to_gvariant
(GValue *val
);
Global version of ncm_serialize_gvalue_to_gvariant()
.
GVariant *
ncm_serialize_global_to_variant (GObject *obj
);
Global version of ncm_serialize_to_variant()
.
gchar * ncm_serialize_global_to_string (GObject *obj
,gboolean valid_variant
);
Global version of ncm_serialize_to_string()
.
gchar *
ncm_serialize_global_to_yaml (GObject *obj
);
Global version of ncm_serialize_to_yaml()
.
void ncm_serialize_global_to_file (GObject *obj
,const gchar *filename
);
Global version of ncm_serialize_to_file()
.
void ncm_serialize_global_to_binfile (GObject *obj
,const gchar *filename
);
Global version of ncm_serialize_to_binfile()
.
void ncm_serialize_global_to_yaml_file (GObject *obj
,const gchar *filename
);
Global version of ncm_serialize_to_yaml_file()
.
GObject *
ncm_serialize_global_dup_obj (GObject *obj
);
Global version of ncm_serialize_dup_obj()
.
gchar *
ncm_serialize_global_variant_to_yaml (GVariant *var_obj
);
Global version of ncm_serialize_variant_to_yaml()
.
Converts a GObject serialized to a GVariant to a YAML string.
Options for serialization.
#define NCM_SERIALIZE_OBJECT_FORMAT "(s@"NCM_SERIALIZE_PROPERTIES_TYPE ")"
#define NCM_SERIALIZE_OBJECT_ARRAY_TYPE "a"NCM_SERIALIZE_OBJECT_TYPE
#define NCM_SERIALIZE_OBJECT_ARRAY_OBJ_NAME_STR "OBJECT:NAME"
#define NCM_SERIALIZE_OBJECT_DICT_STR_TYPE "a{s"NCM_SERIALIZE_OBJECT_TYPE "}"
#define NCM_SERIALIZE_OBJECT_DICT_INT_TYPE "a{i"NCM_SERIALIZE_OBJECT_TYPE "}"
“options”
property“options” NcmSerializeOpt
Serialization options.
Owner: NcmSerialize
Flags: Read / Write / Construct