Top |
#define | XB_VALUE_BINDINGS_INIT |
void | xb_value_bindings_init () |
void | xb_value_bindings_clear () |
XbValueBindings * | xb_value_bindings_copy () |
void | xb_value_bindings_free () |
gboolean | xb_value_bindings_is_bound () |
void | xb_value_bindings_bind_str () |
void | xb_value_bindings_bind_val () |
gboolean | xb_value_bindings_lookup_opcode () |
gboolean | xb_value_bindings_copy_binding () |
#define XB_VALUE_BINDINGS_INIT()
Static initialiser for XbValueBindings so it can be used on the stack.
Use it in association with g_auto()
, to ensure the bindings are freed once
finished with:
1 2 3 |
g_auto(XbValueBindings) bindings = XB_VALUE_BINDINGS_INIT (); xb_value_bindings_bind_str (&bindings, 0, "test", NULL); |
Since: 0.3.0
void
xb_value_bindings_init (XbValueBindings *self
);
Initialise a stack-allocated XbValueBindings struct so it can be used.
Stack-allocated XbValueBindings instances should be freed once finished
with, using xb_value_bindings_clear()
(or g_auto(XbValueBindings)
, which is
equivalent).
Since: 0.3.0
void
xb_value_bindings_clear (XbValueBindings *self
);
Clear an XbValueBindings, freeing any allocated memory it points to.
After this function has been called, the contents of the XbValueBindings are
undefined, and it’s only safe to call xb_value_bindings_init()
on it.
Since: 0.3.0
XbValueBindings *
xb_value_bindings_copy (XbValueBindings *self
);
Copy self
into a new heap-allocated XbValueBindings instance.
Since: 0.3.0
void
xb_value_bindings_free (XbValueBindings *self
);
Free a heap-allocated XbValueBindings instance. This should be used on
XbValueBindings instances created with xb_value_bindings_copy()
.
For stack-allocated instances, xb_value_bindings_clear()
should be used
instead.
Since: 0.3.0
gboolean xb_value_bindings_is_bound (XbValueBindings *self
,guint idx
);
Check whether a value has been bound to the given index using (for example)
xb_value_bindings_bind_str()
.
Since: 0.3.0
void xb_value_bindings_bind_str (XbValueBindings *self
,guint idx
,const gchar *str
,GDestroyNotify destroy_func
);
Bind str
to idx
in the value bindings.
This will overwrite any previous binding at idx
. It will take ownership of
str
, and an appropriate destroy_func
must be provided to free str
once the
binding is no longer needed. destroy_func
will be called exactly once at
some point before the XbValueBindings is cleared or freed.
self |
||
idx |
0-based index to bind to |
|
str |
a string to bind to |
[transfer full][not nullable] |
destroy_func |
function to free |
[nullable] |
Since: 0.3.0
void xb_value_bindings_bind_val (XbValueBindings *self
,guint idx
,guint32 val
);
Bind val
to idx
in the value bindings.
This will overwrite any previous binding at idx
.
Since: 0.3.0
gboolean xb_value_bindings_lookup_opcode (XbValueBindings *self
,guint idx
,XbOpcode *opcode_out
);
Initialises an XbOpcode with the value bound to idx
, if a value is bound.
If no value is bound, opcode_out
is not touched and FALSE
is returned.
opcode_out
is initialised to point to the data inside the XbValueBindings,
so must have a shorter lifetime than the XbValueBindings. It will be of kind
XB_OPCODE_KIND_BOUND_TEXT
or XB_OPCODE_KIND_BOUND_INTEGER
.
self |
||
idx |
0-based index to look up the binding from |
|
opcode_out |
pointer to an XbOpcode to initialise from the binding. |
[out caller-allocates][not nullable] |
Since: 0.3.0
gboolean xb_value_bindings_copy_binding (XbValueBindings *self
,guint idx
,XbValueBindings *dest
,guint dest_idx
);
Copies the value bound at idx
on self
to dest_idx
on dest
. If no value is
bound at idx
, dest
is not modified and FALSE
is returned.
dest
must be initialised. If a binding already exists at dest_idx
, it will
be overwritten.
self |
an XbValueBindings to copy from |
|
idx |
0-based index to look up the binding from in |
|
dest |
an XbValueBindings to copy to |
|
dest_idx |
0-based index to copy the binding to in |
Since: 0.3.0