libcfe  0.12.1
some useful C-functions
cfe_value_extra.c File Reference
#include "config.h"
#include "cfe_value.h"
#include "cfe_value_extra.h"
#include <glib-object.h>
Include dependency graph for cfe_value_extra.c:

Go to the source code of this file.

Macros

#define ASSIGN_INT(T, G, V)
 
#define ASSIGN_UINT(T, G, V)
 

Functions

gboolean cfe_value_to_GValue (const cfe_value_t *cfe_value, GValue *gvalue)
 
gboolean cfe_value_type_is_compatible (const cfe_value_type_t cfe_type, const GType gtype)
 
GType cfe_value_type_as_gtype (const cfe_value_type_t cfe_type)
 

Macro Definition Documentation

◆ ASSIGN_INT

#define ASSIGN_INT (   T,
  G,
 
)
Value:
if(sizeof(gchar) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_CHAR) g_value_set_schar(G, (gchar)V); \
else if(sizeof(gint) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_INT) g_value_set_int(G, (gint)V); \
else if(sizeof(glong) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_LONG) g_value_set_long(G, (glong)V); \
else if(sizeof(gint64) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_INT64) g_value_set_int64(G, (gint64)V);

Definition at line 9 of file cfe_value_extra.c.

◆ ASSIGN_UINT

#define ASSIGN_UINT (   T,
  G,
 
)
Value:
if(sizeof(guchar) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_UCHAR) g_value_set_uchar(G, (guchar)V); \
else if(sizeof(guint) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_UINT) g_value_set_uint(G, (guint)V); \
else if(sizeof(gulong) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_ULONG) g_value_set_ulong(G, (gulong)V); \
else if(sizeof(guint64) >= sizeof(T) && G_VALUE_TYPE(G) == G_TYPE_UINT64) g_value_set_uint64(G, (guint64)V);

Definition at line 15 of file cfe_value_extra.c.

Function Documentation

◆ cfe_value_to_GValue()

gboolean cfe_value_to_GValue ( const cfe_value_t *  cfe_value,
GValue *  gvalue 
)

Covert a cfe_value to a GValue. Make sure that gvalue is not initialized or has is initialized with a type that is compatible with the cfe_value. For the one-on-one transaltion from cfe_value_type_t to GType see ....

Parameters
[in]cfe_valueThe cfe_value to convert.
[out]gvalueThe GValue to store the value in. Make sure it is uninitialized or initialized with a type compatible with the cfe_value.
Returns
TRUE on success, FALSE otherwise. When FALSE is returned, it is guaranteed that gvalue is not altered.

Definition at line 21 of file cfe_value_extra.c.

Here is the call graph for this function:

◆ cfe_value_type_as_gtype()

GType cfe_value_type_as_gtype ( const cfe_value_type_t  cfe_type)

Get the prefered GType for representing a cfe_type.

Parameters
[in]cfe_typeA cfe_type.
Returns
A corresponding GType. When the cfe_value cannot be represented as a GType G_TYPE_INVALID is returned.

Definition at line 270 of file cfe_value_extra.c.

Here is the caller graph for this function:

◆ cfe_value_type_is_compatible()

gboolean cfe_value_type_is_compatible ( const cfe_value_type_t  cfe_type,
const GType  gtype 
)

Checks if the cfe_type can be represented with the gtype.

Parameters
[in]cfe_typeA cfe_type.
[in]gtypeThe GType to check the compatible with.
Returns
TRUE when the cfe_type can be represented in the given GType, FALSE otherwise.

Definition at line 202 of file cfe_value_extra.c.

Here is the caller graph for this function: