Top | ![]() |
![]() |
![]() |
![]() |
Functions
Types and Values
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_VECTOR_TYPE |
#define | NCM_SERIALIZE_MATRIX_TYPE |
#define | NCM_SERIALIZE_STRV_TYPE |
#define | NCM_SERIALIZE_AUTOSAVE_NAME |
#define | NCM_SERIALIZE_AUTOSAVE_NFORMAT |
Description
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.
Functions
ncm_serialize_new ()
NcmSerialize *
ncm_serialize_new (NcmSerializeOpt sopt
);
Creates a new NcmSerialize object.
ncm_serialize_ref ()
NcmSerialize *
ncm_serialize_ref (NcmSerialize *ser
);
Increases the reference count of ser
by one.
ncm_serialize_free ()
void
ncm_serialize_free (NcmSerialize *ser
);
Decreases the reference count of ser
by one.
ncm_serialize_clear ()
void
ncm_serialize_clear (NcmSerialize **ser
);
Decreases the reference count of *ser
by one, and sets *ser
to NULL.
ncm_serialize_reset ()
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.
ncm_serialize_clear_instances ()
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.
ncm_serialize_log_stats ()
void
ncm_serialize_log_stats (NcmSerialize *ser
);
Releases all objects in ser
.
ncm_serialize_contain_instance ()
gboolean ncm_serialize_contain_instance (NcmSerialize *ser
,gpointer obj
);
Checks if the GObject instance obj
is contained in ser
.
ncm_serialize_contain_name ()
gboolean ncm_serialize_contain_name (NcmSerialize *ser
,const gchar *name
);
Checks if there is an instance named name
in ser
.
ncm_serialize_count_instances ()
guint
ncm_serialize_count_instances (NcmSerialize *ser
);
Counts the number of instances registered in ser
.
ncm_serialize_count_saved_serializations ()
guint
ncm_serialize_count_saved_serializations
(NcmSerialize *ser
);
Counts the number of instances registered in ser
.
ncm_serialize_peek_by_name ()
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
.
ncm_serialize_get_by_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
.
ncm_serialize_peek_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
.
ncm_serialize_set ()
void ncm_serialize_set (NcmSerialize *ser
,gpointer obj
,const gchar *name
,gboolean overwrite
);
Adds the object obj
to ser
using name
.
Parameters
ser |
a NcmSerialize. |
|
obj |
a GObject. |
[type GObject] |
name |
the |
|
overwrite |
whether to overwrite if there is already an object named |
ncm_serialize_unset ()
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
.
ncm_serialize_remove_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
.
ncm_serialize_is_named ()
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.
Parameters
ser |
a NcmSerialize. |
|
serobj |
serialized object. |
|
name |
object name. |
[allow-none][out][transfer full] |
ncm_serialize_set_property ()
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
.
ncm_serialize_set_property_from_key_file ()
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
.
Parameters
ser |
a NcmSerialize. |
|
obj |
a GObject. |
|
prop_file |
a GKeyFile file containing the parameters to set. |
ncm_serialize_from_variant ()
GObject * ncm_serialize_from_variant (NcmSerialize *ser
,GVariant *var_obj
);
Deserialize and returns the newly created object.
ncm_serialize_from_name_params ()
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.
Parameters
ser |
a NcmSerialize. |
|
obj_name |
string containing the object name. |
|
params |
a GVariant containing the object parameters. |
ncm_serialize_from_string ()
GObject * ncm_serialize_from_string (NcmSerialize *ser
,const gchar *obj_ser
);
Parses the serialized and returns the newly created object.
ncm_serialize_from_file ()
GObject * ncm_serialize_from_file (NcmSerialize *ser
,const gchar *filename
);
Parses the serialized string in filename
and returns the newly created object.
ncm_serialize_from_binfile ()
GObject * ncm_serialize_from_binfile (NcmSerialize *ser
,const gchar *filename
);
Parses the serialized binary data in filename
and returns the newly created object.
Parameters
ser |
a NcmSerialize. |
|
filename |
File containing the binary serialized version of the object. |
ncm_serialize_gvalue_to_gvariant ()
GVariant * ncm_serialize_gvalue_to_gvariant (NcmSerialize *ser
,GValue *val
);
ncm_serialize_to_variant ()
GVariant * ncm_serialize_to_variant (NcmSerialize *ser
,GObject *obj
);
Serialize the obj
to a GVariant
representation.
ncm_serialize_to_string ()
gchar * ncm_serialize_to_string (NcmSerialize *ser
,GObject *obj
,gboolean valid_variant
);
Serialize the object obj
to a string.
Parameters
ser |
a NcmSerialize. |
|
obj |
a GObject. |
|
valid_variant |
whether to use a valid GVariant representation. |
ncm_serialize_to_yaml ()
gchar * ncm_serialize_to_yaml (NcmSerialize *ser
,GObject *obj
);
Serialize the object obj
to a YAML string.
ncm_serialize_to_file ()
void ncm_serialize_to_file (NcmSerialize *ser
,GObject *obj
,const gchar *filename
);
Serializes obj
and saves the string in filename
.
ncm_serialize_to_binfile ()
void ncm_serialize_to_binfile (NcmSerialize *ser
,GObject *obj
,const gchar *filename
);
Serializes obj
and saves the binary in filename
.
ncm_serialize_to_yaml_file ()
void ncm_serialize_to_yaml_file (NcmSerialize *ser
,GObject *obj
,const gchar *filename
);
Serializes obj
and saves the YAML string in filename
.
ncm_serialize_dup_obj ()
GObject * ncm_serialize_dup_obj (NcmSerialize *ser
,GObject *obj
);
Duplicates obj
by serializing and deserializing a new object.
ncm_serialize_variant_to_yaml ()
gchar * ncm_serialize_variant_to_yaml (NcmSerialize *ser
,GVariant *var_obj
);
Converts a GObject serialized to a GVariant to a YAML string.
ncm_serialize_global ()
NcmSerialize *
ncm_serialize_global (void
);
Gets the global serialization object, instanciates it if necessary.
ncm_serialize_global_reset ()
void
ncm_serialize_global_reset (gboolean autosave_only
);
Releases all objects in global NcmSerialize and erase all serialized objects.
ncm_serialize_global_clear_instances ()
void
ncm_serialize_global_clear_instances (gboolean autosave_only
);
Releases all objects in global NcmSerialize.
ncm_serialize_global_log_stats ()
void
ncm_serialize_global_log_stats (void
);
Releases all objects in global NcmSerialize.
ncm_serialize_global_contain_instance ()
gboolean
ncm_serialize_global_contain_instance (gpointer obj
);
Global version of ncm_serialize_contain_instance()
.
ncm_serialize_global_contain_name ()
gboolean
ncm_serialize_global_contain_name (const gchar *name
);
Global version of ncm_serialize_contain_name()
.
ncm_serialize_global_count_instances ()
guint
ncm_serialize_global_count_instances (void
);
Global version of ncm_serialize_count_instances()
.
ncm_serialize_global_count_saved_serializations ()
guint
ncm_serialize_global_count_saved_serializations
(void
);
Global version of ncm_serialize_count_saved_serializations()
.
ncm_serialize_global_get_by_name ()
gpointer
ncm_serialize_global_get_by_name (const gchar *name
);
Global version of ncm_serialize_get_by_name()
.
ncm_serialize_global_global_peek_name ()
gchar *
ncm_serialize_global_global_peek_name (gpointer obj
);
ncm_serialize_global_set ()
void ncm_serialize_global_set (gpointer obj
,const gchar *name
,gboolean overwrite
);
Global version of ncm_serialize_set()
.
Parameters
obj |
a GObject. |
[type GObject] |
name |
the |
|
overwrite |
whether to overwrite if there is already an object named |
ncm_serialize_global_unset ()
void
ncm_serialize_global_unset (gpointer obj
);
Global version of ncm_serialize_unset()
.
ncm_serialize_global_remove_ser ()
void
ncm_serialize_global_remove_ser (gpointer obj
);
Global version of ncm_serialize_remove_ser()
.
ncm_serialize_global_is_named ()
gboolean ncm_serialize_global_is_named (const gchar *serobj
,gchar **name
);
Global version of ncm_serialize_is_named()
.
ncm_serialize_global_set_property ()
void ncm_serialize_global_set_property (GObject *obj
,const gchar *prop_str
);
Global version of ncm_serialize_set_property()
.
ncm_serialize_global_set_property_from_key_file ()
void ncm_serialize_global_set_property_from_key_file (GObject *obj
,const gchar *prop_file
);
Global version of ncm_serialize_set_property()
.
ncm_serialize_global_from_variant ()
GObject *
ncm_serialize_global_from_variant (GVariant *var_obj
);
Global version of ncm_serialize_from_variant()
.
ncm_serialize_global_from_name_params ()
GObject * ncm_serialize_global_from_name_params (const gchar *obj_name
,GVariant *params
);
Global version of ncm_serialize_from_name_params()
.
Parameters
obj_name |
string containing the object name. |
|
params |
a GVariant containing the object parameters. |
ncm_serialize_global_from_string ()
GObject *
ncm_serialize_global_from_string (const gchar *obj_ser
);
Global version of ncm_serialize_from_string()
.
ncm_serialize_global_from_file ()
GObject *
ncm_serialize_global_from_file (const gchar *filename
);
Global version of ncm_serialize_from_file()
.
ncm_serialize_global_from_binfile ()
GObject *
ncm_serialize_global_from_binfile (const gchar *filename
);
Global version of ncm_serialize_from_binfile()
.
ncm_serialize_global_gvalue_to_gvariant ()
GVariant *
ncm_serialize_global_gvalue_to_gvariant
(GValue *val
);
Global version of ncm_serialize_gvalue_to_gvariant()
.
ncm_serialize_global_to_variant ()
GVariant *
ncm_serialize_global_to_variant (GObject *obj
);
Global version of ncm_serialize_to_variant()
.
ncm_serialize_global_to_string ()
gchar * ncm_serialize_global_to_string (GObject *obj
,gboolean valid_variant
);
Global version of ncm_serialize_to_string()
.
ncm_serialize_global_to_yaml ()
gchar *
ncm_serialize_global_to_yaml (GObject *obj
);
Global version of ncm_serialize_to_yaml()
.
ncm_serialize_global_to_file ()
void ncm_serialize_global_to_file (GObject *obj
,const gchar *filename
);
Global version of ncm_serialize_to_file()
.
ncm_serialize_global_to_binfile ()
void ncm_serialize_global_to_binfile (GObject *obj
,const gchar *filename
);
Global version of ncm_serialize_to_binfile()
.
ncm_serialize_global_to_yaml_file ()
void ncm_serialize_global_to_yaml_file (GObject *obj
,const gchar *filename
);
Global version of ncm_serialize_to_yaml_file()
.
ncm_serialize_global_dup_obj ()
GObject *
ncm_serialize_global_dup_obj (GObject *obj
);
Global version of ncm_serialize_dup_obj()
.
ncm_serialize_global_variant_to_yaml ()
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.
Types and Values
enum NcmSerializeOpt
Options for serialization.
NCM_SERIALIZE_OBJECT_FORMAT
#define NCM_SERIALIZE_OBJECT_FORMAT "{s@"NCM_SERIALIZE_PROPERTIES_TYPE "}"
Property Details
The “options”
property
“options” NcmSerializeOpt
Serialization options.
Owner: NcmSerialize
Flags: Read / Write / Construct