GXmlEnumeration

GXmlEnumeration — Convenient static methods for enumeration serialization to string.

Functions

Types and Values

Description

Enumerations have a set of utility methods to better represent on serialisation/deserialization.

Enumerations could be converted to string using its definition on GEnumClass, by taking its nick name directly or converting to its camel case representation.

Any enumeration value type in a <code>GLib.Object</code>'s property could be deserialized from its definition given on GEnumClass (name and nick) or from its camel case representation.

Functions

gxml_enumeration_new ()

GXmlEnumeration *
gxml_enumeration_new (void);

gxml_enumeration_get_nick ()

gchar *
gxml_enumeration_get_nick (GType enumeration,
                           gint val,
                           GError **error);

Introspect an enumeration to get value's nick name.

Returns: an string representing an enumeration's value.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

val

 .

an integer to parse an enum value of type enumeration .

.

[in]

error

location to store the error occuring, or NULL to ignore

 

gxml_enumeration_get_nick_camelcase ()

gchar *
gxml_enumeration_get_nick_camelcase (GType enumeration,
                                     gint val,
                                     GError **error);

Introspect an enumeration to get value's nick name and transform to camel case representation.

Returns: an string representing an enumeration's value.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

val

 .

an integer to parse an enum value of type param enumeration.

.

[in]

error

location to store the error occuring, or NULL to ignore

 

gxml_enumeration_get_string ()

gchar *
gxml_enumeration_get_string (GType enumeration,
                             gint val,
                             gboolean use_nick,
                             gboolean camelcase,
                             GError **error);

Transform enumeration's value to its string representation.

Returns: an string representing an enumeration's value.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

val

 .

an integer to parse an enum value of type enumeration .

.

[in]

use_nick

 .

makes to returns value's nick name in GEnumClass

.

[in]

camelcase

 .

makes to returns value's nick name in GEnumClass as camel case representation. If use_nick is set this take no effect.

.

[in]

error

location to store the error occuring, or NULL to ignore

 

gxml_enumeration_parse ()

GEnumValue *
gxml_enumeration_parse (GType enumeration,
                        const gchar *val,
                        GError **error);

Parse val to an enumeration's value.

Returns: an GEnumValue representing an enumeration's value.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

val

 .

a string to parse an enum value of type param enumeration. as camel case representation. If use_nick is set this take no effect.

.

[in]

error

location to store the error occuring, or NULL to ignore

 

gxml_enumeration_to_array ()

GEnumValue *
gxml_enumeration_to_array (GType enumeration,
                           int *result_length1);

Transform an enumeration in an array of GEnumValue.

Returns: an array of GEnumValue representing an enumeration.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

Returns

.

[array length=result_length1][transfer none]


gxml_enumeration_parse_integer ()

GEnumValue *
gxml_enumeration_parse_integer (GType enumeration,
                                gint val);

From a integer valuer calculates a valid GEnumValue for a GType.

Returns: a GEnumValue or null if fails.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

val

 .

an integer in a valid range in the enumeration.

.

[in]

gxml_enumeration_to_string_array ()

gchar **
gxml_enumeration_to_string_array (GType enumeration,
                                  int *result_length1,
                                  GError **error);

Transform an enumeration in an array of strings representing enumeration values.

Returns: an array of strings representing an enumeration.

Parameters

enumeration

 .

a GType of type G_TYPE_ENUM

.

[in]

error

location to store the error occuring, or NULL to ignore

 

Returns

.

[array length=result_length1]


gxml_enumeration_ref ()

gpointer
gxml_enumeration_ref (gpointer instance);

Increases the reference count of object .

Parameters

instance

a GXmlEnumeration.

 

Returns

the same object


gxml_enumeration_unref ()

void
gxml_enumeration_unref (gpointer instance);

Decreases the reference count of object . When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

Parameters

instance

a GXmlEnumeration.

 

gxml_param_spec_enumeration ()

GParamSpec *
gxml_param_spec_enumeration (const gchar *name,
                             const gchar *nick,
                             const gchar *blurb,
                             GType object_type,
                             GParamFlags flags);

Creates a new GParamSpecBoxed instance specifying a GXML_TYPE_ENUMERATION derived property.

See g_param_spec_internal() for details on property names.

Parameters

name

canonical name of the property specified

 

nick

nick name for the property specified

 

blurb

description of the property specified

 

object_type

GXML_TYPE_ENUMERATION derived type of this property  

flags

flags for the property specified

 

gxml_value_set_enumeration ()

void
gxml_value_set_enumeration (GValue *value,
                            gpointer v_object);

Set the contents of a GXML_TYPE_ENUMERATION derived GValue to v_object .

gxml_value_set_enumeration() increases the reference count of v_object (the GValue holds a reference to v_object). If you do not wish to increase the reference count of the object (i.e. you wish to pass your current reference to the GValue because you no longer need it), use gxml_value_take_enumeration() instead.

It is important that your GValue holds a reference to v_object (either its own, or one it has taken) to ensure that the object won't be destroyed while the GValue still exists).

Parameters

value

a valid GValue of GXML_TYPE_ENUMERATION derived type

 

v_object

object value to be set

 

gxml_value_get_enumeration ()

gpointer
gxml_value_get_enumeration (const GValue *value);

Get the contents of a GXML_TYPE_ENUMERATION derived GValue.

Parameters

value

a valid GValue of GXML_TYPE_ENUMERATION derived type

 

Returns

object contents of value


gxml_value_take_enumeration ()

void
gxml_value_take_enumeration (GValue *value,
                             gpointer v_object);

Sets the contents of a GXML_TYPE_ENUMERATION derived GValue to v_object and takes over the ownership of the callers reference to v_object ; the caller doesn't have to unref it any more (i.e. the reference count of the object is not increased).

If you want the GValue to hold its own reference to v_object , use gxml_value_set_enumeration() instead.

Parameters

value

a valid GValue of GXML_TYPE_ENUMERATION derived type

 

v_object

object value to be set

 

Types and Values

GXML_TYPE_ENUMERATION

#define GXML_TYPE_ENUMERATION (gxml_enumeration_get_type ())

The type for GXmlEnumeration.


struct GXmlEnumeration

struct GXmlEnumeration {
	GTypeInstance parent_instance;
	volatile int ref_count;
	GXmlEnumerationPrivate * priv;
};

Convenient static methods for enumeration serialization to string.

Enumerations have a set of utility methods to better represent on serialisation/deserialization.

Enumerations could be converted to string using its definition on GEnumClass, by taking its nick name directly or converting to its camel case representation.

Any enumeration value type in a <code>GLib.Object</code>'s property could be deserialized from its definition given on GEnumClass (name and nick) or from its camel case representation.


struct GXmlEnumerationClass

struct GXmlEnumerationClass {
	GTypeClass parent_class;
	void (*finalize) (GXmlEnumeration *self);
};

The class structure for GXML_TYPE_ENUMERATION. All the fields in this structure are private and should never be accessed directly.

Members

finalize ()

   

enum GXmlEnumerationError

Errors when de/serializing enumerations.

Members

GXML_ENUMERATION_ERROR_INVALID_VALUE

Given value is invalid in enumeration, when transform to string.

 

GXML_ENUMERATION_ERROR_INVALID_TEXT

Given text to transform to an enumeration's value.