Modulemd Utility Functions

Modulemd Utility Functions — Provides private utility functions for use within libmodulemd.

Stability Level

Private, unless otherwise indicated

Functions

Types and Values

#define MODULEMD_ERROR

Description

Functions

modulemd_error_quark ()

GQuark
modulemd_error_quark (void);

Returns

A GQuark used to identify an error in the general modulemd domain.

Since: 2.0


modulemd_trace_init ()

modulemd_tracer *
modulemd_trace_init (const gchar *function_name);

Parameters

function_name

The name of the function being traced.

 

Returns

A newly-allocated modulemd_tracer object.

Allocates and returns a new modulemd_tracer that tracks the provided function_name . Also writes a g_debug() trace message indicating function_name has been entered.

DIRECT USE OF THIS FUNCTION SHOULD BE AVOIDED. Instead use MODULEMD_INIT_TRACE--which makes use of this function as part of its internal implementation.

[transfer full]

Since: 2.0


modulemd_trace_free ()

void
modulemd_trace_free (modulemd_tracer *tracer);

Writes a g_debug() trace message indicating the function name associated with tracer is being exited and frees tracer .

DIRECT USE OF THIS FUNCTION SHOULD BE AVOIDED. Instead use MODULEMD_INIT_TRACE--which makes use of this function as part of its internal implementation.

Parameters

tracer

A modulemd_tracer object representing a function being traced.

 

Since: 2.0


MODULEMD_INIT_TRACE

#define             MODULEMD_INIT_TRACE()

When used at the beginning of a function, automatically writes g_debug() trace messages when entering and leaving that function. Makes use of modulemd_trace_init() and modulemd_trace_free().

This macro manages the memory of the hidden modulemd_tracer object it creates, so the caller should not attempt to modify that object in any way.

Since: 2.0


modulemd_hash_table_deep_str_copy ()

GHashTable *
modulemd_hash_table_deep_str_copy (GHashTable *orig);

Parameters

orig

A GHashTable to copy, containing string keys and string values.

 

Returns

A newly-allocated GHashTable containing a deep copy of both the keys and values from orig .

[transfer full]

Since: 2.0


modulemd_hash_table_deep_set_copy ()

GHashTable *
modulemd_hash_table_deep_set_copy (GHashTable *orig);

Parameters

orig

A GHashTable to copy, containing string keys.

 

Returns

A newly-allocated GHashTable containing a deep copy of the keys from orig . The values from orig are ignored, and the values in the copy are set the same as the corresponding keys so the returned GHashTable can be used as a set.

[transfer full]

Since: 2.0


modulemd_hash_table_deep_str_set_copy ()

GHashTable *
modulemd_hash_table_deep_str_set_copy (GHashTable *orig);

Parameters

orig

A GHashTable to copy, containing string keys and GHashTable values.

 

Returns

A newly-allocated GHashTable containing a deep copy of the keys from orig . The corresponding GHashTable value for each key is deep copied via modulemd_hash_table_deep_str_copy() for use as a set.

[transfer full]

Since: 2.0


modulemd_hash_table_deep_str_str_set_copy ()

GHashTable *
modulemd_hash_table_deep_str_str_set_copy
                               (GHashTable *orig);

Parameters

orig

A GHashTable to copy, containing string keys and GHashTable values that are nested two levels deep.

 

Returns

A newly-allocated GHashTable containing a deep copy of the keys from orig . Each corresponding GHashTable value is deep copied, with the second level GHashTable copied for use as a set as described in modulemd_hash_table_deep_str_copy().

[transfer full]

Since: 2.0


modulemd_hash_table_sets_are_equal_wrapper ()

gboolean
modulemd_hash_table_sets_are_equal_wrapper
                               (const void *a,
                                const void *b);

Parameters

a

A void pointer.

 

b

A void pointer.

 

Returns

TRUE if both a and b (considered as GHashTables) contain an identical set of keys, FALSE if they differ.

Only the keys of a and b are compared. The values are ignored.

Since: 2.2


modulemd_hash_table_sets_are_equal ()

gboolean
modulemd_hash_table_sets_are_equal (GHashTable *a,
                                    GHashTable *b);

Parameters

a

A GHashTable object.

 

b

A GHashTable object.

 

Returns

TRUE if both a and b contain an identical set of keys, FALSE if they differ.

Only the keys of a and b are compared. The values are ignored.

Since: 2.0


modulemd_hash_table_equals ()

gboolean
modulemd_hash_table_equals (GHashTable *a,
                            GHashTable *b,
                            GEqualFunc compare_func);

Parameters

a

A GHashTable object.

 

b

A GHashTable object.

 

compare_func

A GEqualFunc function that is called to determine the equivalence of pairs of GHashTable values.

 

Returns

TRUE if both a and b contain identical keys and identical corresponding values (as determined by compare_func ), FALSE if they differ.

Since: 2.2


modulemd_strcmp_sort ()

gint
modulemd_strcmp_sort (gconstpointer a,
                      gconstpointer b);

Parameters

a

A gconstpointer.

 

b

A gconstpointer.

 

Returns

0 if a and b are pointers to identical strings, a negative value if a is less than b , and a positive value if a is greater than b .

Since: 2.0


modulemd_ordered_str_keys ()

GPtrArray *
modulemd_ordered_str_keys (GHashTable *htable,
                           GCompareFunc compare_func);

Parameters

htable

A GHashTable.

 

compare_func

A GCompareFunc function that is called to determine the equivalence of pairs of GHashTable keys from htable . This should almost always be passed as modulemd_strcmp_sort().

 

Returns

A GPtrArray of the keys from htable sorted according to compare_func .

[transfer container]

Since: 2.0


modulemd_ordered_str_keys_as_strv ()

GStrv
modulemd_ordered_str_keys_as_strv (GHashTable *htable);

Parameters

htable

A GHashTable.

 

Returns

A GStrv list of the keys from htable sorted according to modulemd_strcmp_sort().

[transfer full]

Since: 2.0


modulemd_variant_deep_copy ()

GVariant *
modulemd_variant_deep_copy (GVariant *variant);

Parameters

variant

A GVariant opaque data structure.

 

Returns

A newly-allocated deep copy of variant .

[transfer full]

Since: 2.0


modulemd_hash_table_unref ()

void
modulemd_hash_table_unref (void *table);

Decrements the reference count of table (considered as a GHashTable). If the reference count drops to 0, all keys, values, and memory associated with table will be released.

The main purpose of this function is to provide a GDestroyNotify() function for GPtrArray, GHashTable, and similar object types.

Parameters

table

A void pointer.

[nullable]

Since: 2.0


modulemd_validate_nevra ()

gboolean
modulemd_validate_nevra (const gchar *nevra);

Parameters

nevra

A NEVRA (Name, Epoch, Version, Release, Architecture) string.

 

Returns

TRUE if nevra is in proper N-E:V-R.A format, FALSE otherwise.

Since: 2.0


modulemd_boolean_equals ()

gboolean
modulemd_boolean_equals (gboolean a,
                         gboolean b);

Since a gboolean could contain any value represented by a gint, a and b are compared for logical equivalence.

Parameters

a

A gboolean value.

 

b

A gboolean value.

 

Returns

TRUE if a and b are logically equal, FALSE otherwise.

Since: 2.7


MODULEMD_REPLACE_SET()

#define             MODULEMD_REPLACE_SET(_dest, _set)

Frees the existing GHashTable at _dest . If _set is not NULL, assigns a deep copy of _set 's keys for use as a set.

This helper function is intended for use in GOBJECT_copy() functions to simplify copying internal set variables and avoid code duplication.

Parameters

_dest

A reference to a GHashTable.

 

_set

A reference to a GHashTable.

[nullable]

Since: 2.0


MODULEMD_SETTER_GETTER_STRING_EXT()

#define             MODULEMD_SETTER_GETTER_STRING_EXT(                                    \
              is_static, ObjName, obj_name, OBJ_NAME, attr, ATTR)

A convenience macro for defining standard set and get methods for a string attribute of an object.

This is the internal implementation for MODULEMD_SETTER_GETTER_STRING and MODULEMD_SETTER_GETTER_STRING_STATIC which should be used instead.

Parameters

is_static

static for private methods, or empty comment for public.

 

ObjName

The name of the object type, in camel case.

 

obj_name

The name of the object type, in lowercase with words separated by '_'.

 

OBJ_NAME

The name of the object type, in uppercase with words separated by '_'.

 

attr

The name of the object attribute, in lowercase.

 

ATTR

The name of the object attribute, in uppercase.

 

Since: 2.2


MODULEMD_SETTER_GETTER_STRING()

#define             MODULEMD_SETTER_GETTER_STRING(                                        \
              ObjName, obj_name, OBJ_NAME, attr, ATTR)

A convenience macro for defining standard public set and get methods for a string attribute of an object.

Parameters

ObjName

The name of the object type, in camel case.

 

obj_name

The name of the object type, in lowercase with words separated by '_'.

 

OBJ_NAME

The name of the object type, in uppercase with words separated by '_'.

 

attr

The name of the object attribute, in lowercase.

 

ATTR

The name of the object attribute, in uppercase.

 

Since: 2.2


MODULEMD_SETTER_GETTER_STRING_STATIC()

#define             MODULEMD_SETTER_GETTER_STRING_STATIC(                                 \
              ObjName, obj_name, OBJ_NAME, attr, ATTR)

A is a convenience macro for defining standard private (static) set and get methods for a string attribute of an object.

Parameters

ObjName

The name of the object type, in camel case.

 

obj_name

The name of the object type, in lowercase with words separated by '_'.

 

OBJ_NAME

The name of the object type, in uppercase with words separated by '_'.

 

attr

The name of the object attribute, in lowercase.

 

ATTR

The name of the object attribute, in uppercase.

 

Since: 2.2

Types and Values

MODULEMD_ERROR

#define MODULEMD_ERROR modulemd_error_quark ()

A convenience macro for identifying an error in the general modulemd domain.