4 #include <HashVector.h>
5 #include <TupleSchema.h>
9 * A BindingTable is a chain of \ref HashVector "HashVectors" of
10 * Binding items that associate a (char*) name with a (void*) value.
12 typedef HashVector/*<Binding>*/ BindingTable;
15 * \brief Allocate a new \ref BindingTable.
17 * \returns the allocated \ref bandingtable.
19 * \related BindingTable
21 extern BindingTable *BindingTable_create();
24 * \brief Reclaim a \ref BindingTable with all its bindings.
26 * \param bt is the \ref BindingTable to reclaim.
28 * \related BindingTable
30 extern void BindingTable_release(BindingTable *bt);
33 * \brief Set a Binding in a \ref BindingTable.
35 * \param bt is the \ref BindingTable concerned.
37 * \param name is the Binding name.
39 * \param value is the Binding value.
41 * \note Binding names are equal or not by means of strcmp, and each
42 * name has a at most single Binding.
44 * The name and the value are held as given with all memory management
45 * the callers responsibility. This function will however create new
46 * Binding objects and reclaim the old ones as needed.
48 * A value of \b 0 indicates "unbound".
50 * \related BindingTable
52 extern void BindingTable_set(BindingTable *bt,char *name,void *value);
55 * \brief Get a Binding from a BindingTable chain.
57 * \param bt is the first BindingTable concerned.
59 * \param name is the Binding variable name.
61 * \returns the value of the found Binding, or \b 0 if none is found.
63 * \note Binding names are equal or not by means of strcmp, and each
64 * name has a at most single Binding.
66 * \note Not also that a name can be made unbound on top of being
67 * bound by setting it to \b 0.
69 * \related BindingTable
71 extern void *BindingTable_get(BindingTable *bt,char *name);
74 * \brief Replace all names with their values.
76 * \param bt is the BindingTable concerned.
78 * \param t is the tuple of (char*) names to dereference.
80 extern void BindingTable_deref(BindingTable *bt,Tuple *t);
83 * \brief Set values for names, optionally unbinding names as well.
85 * \param bt is the bindingtable concerned.
87 * \param nm is the Tuple of names to bind.
89 * \param vs is the Tuple of values.
91 * \param all is a flag to assign all (1) or only non-zero (0) values.
93 * \note The values tuple must be as wide as the names tuple.
95 extern void BindingTable_set_all(BindingTable *bt,Tuple *nm,Tuple *vs,int all);