Database
Data Management And Parsing

This group contains the definition of a GWEN_DB database.

This group contains the definition of a GWEN_DB database.

A GWEN_DB database consists of a tree of GWEN_DB_NODE entries. Such a GWEN_DB_NODE node can either be a group node, or a variable node, or a value node. Usually an application programmer will only get in touch with group nodes. The application programmer can iterate through the group nodes with GWEN_DB_GetGroup(), GWEN_DB_Groups_foreach(), and can retrieve variable values with GWEN_DB_GetIntValue(), GWEN_DB_GetCharValue() and so on.

The following graph shows the internal structure of a GWEN_DB:

Internal structure of a GWEN_DB

As you can see the GWEN_DB consists of multiple units called NODE. Every node has a pointer to:

- its parent
- its first child (only the first)
- its successor (but not its predecessor!)

Such a node can be either of the following:

- a group containing other groups and variables
- a variable containing values (and values only)
- a value containing its value data

Each group has a name. Depending on the GWEN_DB_FLAGS given when reading a GWEN_DB from a file or creating it, it may very well be possible to have multiple groups with the same name as children of the same root node. Again: Child group nodes with the same name may very well exist. This also applies to variable nodes.

For the interested reader, we again explain the difference of the three kinds of nodes. Depending on either of these cases, you can

1. Iterate through groups or get a variable with e.g. GWEN_DB_GetNextGroup(), GWEN_DB_GetNextVar()
2. Get the type of a variable with e.g. GWEN_DB_GetVariableType() – the value of a variable is retrieved by the shortcut functions explained below.
3. Get the type of a value with GWEN_DB_GetValueType(). Again the value itself is retrieved with the shortcut functions below.

To retrieve or set the value of such a variable, the following "shortcut" functions for all three supported typed exist: GWEN_DB_GetIntValue(), GWEN_DB_GetCharValue(), GWEN_DB_GetBinValue(). These functions only accept a group and a "path" to the desired variable.