xb-value-bindings

## xb-value-bindings xb-value-bindings — |

## Functions

#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 ()

## Types and Values

| XbValueBindings

## Description

## Functions

### XB_VALUE_BINDINGS_INIT

    #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

### xb_value_bindings_init ()

    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).

#### Parameters

self | an uninitialised XbValueBindings to initialise |

Since: 0.3.0

### xb_value_bindings_clear ()

    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.

#### Parameters

self | an XbValueBindings |

Since: 0.3.0

### xb_value_bindings_copy ()

    XbValueBindings *
    xb_value_bindings_copy (XbValueBindings *self);

Copy `self` into a new heap-allocated XbValueBindings instance.

#### Parameters

self | an XbValueBindings |

#### Returns

a copy of `self` .

[transfer full]

Since: 0.3.0

### xb_value_bindings_free ()

    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.

#### Parameters

self | a heap-allocated XbValueBindings |

Since: 0.3.0

### xb_value_bindings_is_bound ()

    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()`.

#### Parameters

self | an XbValueBindings |
idx | 0-based index of the binding to check |

#### Returns

`TRUE` if a value is bound to `idx` , `FALSE` otherwise

Since: 0.3.0

### xb_value_bindings_bind_str ()

    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.

#### Parameters

self | an XbValueBindings |
idx | 0-based index to bind to |
str | a string to bind to `idx` . | [transfer full][not nullable]
destroy_func | function to free `str` . | [nullable]

Since: 0.3.0

### xb_value_bindings_bind_val ()

    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` .

#### Parameters

self | an XbValueBindings |
idx | 0-based index to bind to |
val | an integer to bind to `idx` |

Since: 0.3.0

### xb_value_bindings_lookup_opcode ()

    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`.

#### Parameters

self | an XbValueBindings |
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]

#### Returns

`TRUE` if `idx` was bound, `FALSE` otherwise

Since: 0.3.0

### xb_value_bindings_copy_binding ()

    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.

#### Parameters

self | an XbValueBindings to copy from |
idx | 0-based index to look up the binding from in `self` |
dest | an XbValueBindings to copy to |
dest_idx | 0-based index to copy the binding to in `dest` |

#### Returns

`TRUE` if `idx` was bound, `FALSE` otherwise

Since: 0.3.0

## Types and Values

### XbValueBindings

    typedef struct {
    } XbValueBindings;

An opaque struct which contains values bound to a query.

Since: 0.3.0