db.h File Reference
`#include <gwenhywfar/gwenhywfarapi.h>`
`#include <gwenhywfar/path.h>`
`#include <gwenhywfar/fastbuffer.h>`
`#include <gwenhywfar/types.h>`
`#include <stdio.h>`

Go to the source code of this file.

## Macros

#define | GWEN_DB_LINE_MAXSIZE 1024
DB Flags
Please note that the setter functions also take the flags from the module Paths (e.g. GWEN_PATH_FLAGS_PATHMUSTEXIST) into account. So you most likely need to specify them, too. However, for your conveniance there is a default flag value which suffices in most cases (GWEN_DB_FLAGS_DEFAULT).
#define | GWEN_DB_FLAGS_ADD_GROUP_NEWLINES 0x00800000
#define | GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM 0x00008000
#define | GWEN_DB_FLAGS_APPEND_FILE 0x08000000
#define | GWEN_DB_FLAGS_COMPACT
#define | GWEN_DB_FLAGS_DEFAULT
#define | GWEN_DB_FLAGS_DETAILED_GROUPS 0x00200000
#define | GWEN_DB_FLAGS_DOSMODE 0x80000000
#define | GWEN_DB_FLAGS_ESCAPE_CHARVALUES 0x10000000
#define | GWEN_DB_FLAGS_HTTP
#define | GWEN_DB_FLAGS_INDEND 0x00400000
#define | GWEN_DB_FLAGS_INSERT 0x40000000
#define | GWEN_DB_FLAGS_LOCKFILE 0x20000000
#define | GWEN_DB_FLAGS_OMIT_TYPES 0x04000000
#define | GWEN_DB_FLAGS_OVERWRITE_GROUPS 0x00020000
#define | GWEN_DB_FLAGS_OVERWRITE_VARS 0x00010000
#define | GWEN_DB_FLAGS_QUOTE_VALUES 0x00080000
#define | GWEN_DB_FLAGS_QUOTE_VARNAMES 0x00040000
#define | GWEN_DB_FLAGS_UNESCAPE_CHARVALUES 0x10000000
#define | GWEN_DB_FLAGS_UNTIL_EMPTY_LINE 0x02000000
#define | GWEN_DB_FLAGS_USE_COLON 0x01000000
#define | GWEN_DB_FLAGS_WRITE_SUBGROUPS 0x00100000

## Functions

Constructing, Destructing, Copying
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_Group_dup (const GWEN_DB_NODE *n)
GWENHYWFAR_API void | GWEN_DB_Group_free (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_Group_new (const char *name)
Variable Getter and Setter

These getter functions check for the existence of the given variable and return the value specified by an index. Under the following circumstances the also given default value will be returned:

- the variable does not exist
- the variable exists but has no values (should not occur)
- the variable exists but the given value index is out of range (e.g. specifying index 1 with a variable that has only one value)
- a string value is expected but the variable is not of that type. However, if you want an integer value but the variable only has a char value then the getter functions try to convert the char to an integer. Other conversions do not take place.

The setter functions either replace an existing variable, create a missing variable, add a value or return an error if the variable does not exist (see description of the flags). All setter functions make deep copies of the given values, so you may free the params after calling the setter function.

All getter functions return a const pointer to the variable's retrieved value. All setter functions return Zero if ok and Nonzero on error.

This module knows about the following types (see GWEN_DB_VALUETYPE):

- char (simple null terminated C strings)
- int (integer values)
- bin (binary, user specified data)

Note
  The value returned by a getter function is only valid as long as the corresponding variable (node) exists.
  So if you retrieve the value of a variable and delete the variable (or even the whole DB) afterwards the pointer becomes invalid and using it will most likely crash your program.
  If you want to use such a value even after the corresponding variable has been deleted you need to make a copy.

GWENHYWFAR_API int | GWEN_DB_AddCharValue (GWEN_DB_NODE *n, const char *path, const char *val, int senseCase, int check)
GWENHYWFAR_API const void * | GWEN_DB_GetBinValue (GWEN_DB_NODE *n, const char *path, int idx, const void *defVal, unsigned int defValSize, unsigned int *returnValueSize)
GWENHYWFAR_API const char * | GWEN_DB_GetCharValue (GWEN_DB_NODE *n, const char *path, int idx, const char *defVal)
GWENHYWFAR_API int | GWEN_DB_GetIntValue (GWEN_DB_NODE *n, const char *path, int idx, int defVal)
GWENHYWFAR_API void * | GWEN_DB_GetPtrValue (GWEN_DB_NODE *n, const char *path, int idx, void *defVal)
GWENHYWFAR_API int | GWEN_DB_RemoveCharValue (GWEN_DB_NODE *n, const char *path, const char *val, int senseCase)
GWENHYWFAR_API int | GWEN_DB_SetBinValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, const void *val, unsigned int valSize)
GWENHYWFAR_API int | GWEN_DB_SetCharValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, const char *val)
GWENHYWFAR_API int | GWEN_DB_SetCharValueFromInt (GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
GWENHYWFAR_API int | GWEN_DB_SetIntValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, int val)
GWENHYWFAR_API int | GWEN_DB_SetPtrValue (GWEN_DB_NODE *n, uint32_t flags, const char *path, void *val)
GWENHYWFAR_API int | GWEN_DB_WriteVarValueToBuffer (GWEN_DB_NODE *n, const char *path, int index, GWEN_BUFFER *dstBuf)
Group Handling
GWENHYWFAR_API int | GWEN_DB_AddGroup (GWEN_DB_NODE *parent, GWEN_DB_NODE *node)
GWENHYWFAR_API int | GWEN_DB_AddGroupChildren (GWEN_DB_NODE *n, GWEN_DB_NODE *nn)
GWENHYWFAR_API int | GWEN_DB_ClearGroup (GWEN_DB_NODE *n, const char *path)
GWENHYWFAR_API int | GWEN_DB_DeleteGroup (GWEN_DB_NODE *n, const char *path)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetGroup (GWEN_DB_NODE *n, uint32_t flags, const char *path)
GWENHYWFAR_API uint32_t | GWEN_DB_GetNodeFlags (const GWEN_DB_NODE *n)
GWENHYWFAR_API const char * | GWEN_DB_GroupName (GWEN_DB_NODE *n)
GWENHYWFAR_API void | GWEN_DB_GroupRename (GWEN_DB_NODE *n, const char *newname)
GWENHYWFAR_API int | GWEN_DB_InsertGroup (GWEN_DB_NODE *parent, GWEN_DB_NODE *node)
GWENHYWFAR_API int | GWEN_DB_IsGroup (const GWEN_DB_NODE *n)
GWENHYWFAR_API void | GWEN_DB_ModifyBranchFlagsDown (GWEN_DB_NODE *n, uint32_t newflags, uint32_t mask)
GWENHYWFAR_API void | GWEN_DB_ModifyBranchFlagsUp (GWEN_DB_NODE *n, uint32_t newflags, uint32_t mask)
GWENHYWFAR_API void | GWEN_DB_SetNodeFlags (GWEN_DB_NODE *n, uint32_t flags)
GWENHYWFAR_API void | GWEN_DB_UnlinkGroup (GWEN_DB_NODE *n)
Reading and Writing From/To IO Layers
These functions read or write a DB from/to GWEN_IO_LAYER. This allows to use any source or target supported by GWEN_IO_LAYER for data storage (these are currently sockets, files and memory buffers). The flags determine how to read/write the data (e.g. if sub-groups are to be written etc).
GWENHYWFAR_API int | GWEN_DB_ReadFile (GWEN_DB_NODE *n, const char *fname, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_ReadFileAs (GWEN_DB_NODE *n, const char *fname, const char *type, GWEN_DB_NODE *params, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_ReadFromFastBuffer (GWEN_DB_NODE *n, GWEN_FAST_BUFFER *fb, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_ReadFromIo (GWEN_DB_NODE *n, GWEN_SYNCIO *sio, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_ReadFromString (GWEN_DB_NODE *n, const char *str, int len, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_WriteFile (GWEN_DB_NODE *n, const char *fname, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_WriteFileAs (GWEN_DB_NODE *n, const char *fname, const char *type, GWEN_DB_NODE *params, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_WriteToBuffer (GWEN_DB_NODE *n, GWEN_BUFFER *buf, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_WriteToFastBuffer (GWEN_DB_NODE *node, GWEN_FAST_BUFFER *fb, uint32_t dbflags)
GWENHYWFAR_API int | GWEN_DB_WriteToIo (GWEN_DB_NODE *node, GWEN_SYNCIO *sio, uint32_t dbflags)
Iterating Through Variables and variable handling
GWENHYWFAR_API int | GWEN_DB_DeleteVar (GWEN_DB_NODE *n, const char *path)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_FindFirstVar (GWEN_DB_NODE *n, const char *name)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_FindNextVar (GWEN_DB_NODE *n, const char *name)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetFirstVar (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetNextVar (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE_TYPE | GWEN_DB_GetVariableType (GWEN_DB_NODE *n, const char *p)
GWENHYWFAR_API int | GWEN_DB_IsVariable (const GWEN_DB_NODE *n)
GWENHYWFAR_API int | GWEN_DB_ValueExists (GWEN_DB_NODE *n, const char *path, unsigned int idx)
GWENHYWFAR_API int | GWEN_DB_VariableExists (GWEN_DB_NODE *n, const char *path)
GWENHYWFAR_API const char * | GWEN_DB_VariableName (GWEN_DB_NODE *n)
GWENHYWFAR_API void | GWEN_DB_VariableRename (GWEN_DB_NODE *n, const char *newname)
GWENHYWFAR_API unsigned int | GWEN_DB_Variables_Count (const GWEN_DB_NODE *node)
GWENHYWFAR_API void * | GWEN_DB_Variables_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data)
Iterating Through Values and value handling
GWENHYWFAR_API const void * | GWEN_DB_GetBinValueFromNode (const GWEN_DB_NODE *n, unsigned int *size)
GWENHYWFAR_API const char * | GWEN_DB_GetCharValueFromNode (const GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetFirstValue (GWEN_DB_NODE *n)
GWENHYWFAR_API int | GWEN_DB_GetIntValueFromNode (const GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetNextValue (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE_TYPE | GWEN_DB_GetValueType (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE_TYPE | GWEN_DB_GetValueTypeByPath (GWEN_DB_NODE *n, const char *p, unsigned int i)
GWENHYWFAR_API int | GWEN_DB_IsValue (const GWEN_DB_NODE *n)
GWENHYWFAR_API int | GWEN_DB_SetCharValueInNode (GWEN_DB_NODE *n, const char *s)
GWENHYWFAR_API unsigned int | GWEN_DB_Values_Count (const GWEN_DB_NODE *node)
GWENHYWFAR_API void * | GWEN_DB_Values_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data)
Debugging
These functions are for debugging purposes only. You should NOT consider them part of the API.
GWENHYWFAR_API void | GWEN_DB_Dump (GWEN_DB_NODE *n, int insert)
Higher Level Utility Functions
These functions make use of GWEN_DB groups.
GWENHYWFAR_API int | GWEN_DB_ReplaceVars (GWEN_DB_NODE *db, const char *s, GWEN_BUFFER *dbuf)

## Node Flags

#define | GWEN_DB_DEFAULT_LOCK_TIMEOUT 1000
typedef struct GWEN_DB_NODE | GWEN_DB_NODE
#define | GWEN_DB_NODE_FLAGS_DIRTY 0x00000001
#define | GWEN_DB_NODE_FLAGS_INHERIT_HASH_MECHANISM 0x00000004
#define | GWEN_DB_NODE_FLAGS_SAFE 0x00000008
#define | GWEN_DB_NODE_FLAGS_VOLATILE 0x00000002
enum | GWEN_DB_NODE_TYPE { GWEN_DB_NodeType_Unknown =-1 , GWEN_DB_NodeType_Group =0 , GWEN_DB_NodeType_Var , GWEN_DB_NodeType_ValueChar , GWEN_DB_NodeType_ValueInt , GWEN_DB_NodeType_ValueBin , GWEN_DB_NodeType_ValuePtr , GWEN_DB_NodeType_ValueLast }

## Iterating Through Groups

GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_FindFirstGroup (GWEN_DB_NODE *n, const char *name)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_FindNextGroup (GWEN_DB_NODE *n, const char *name)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetFirstGroup (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetNextGroup (GWEN_DB_NODE *n)
GWENHYWFAR_API GWEN_DB_NODE * | GWEN_DB_GetParentGroup (GWEN_DB_NODE *n)
GWENHYWFAR_API unsigned int | GWEN_DB_Groups_Count (const GWEN_DB_NODE *node)
GWENHYWFAR_API void * | GWEN_DB_Groups_Foreach (GWEN_DB_NODE *node, GWEN_DB_NODES_CB func, void *user_data)
typedef void *(* | GWEN_DB_NODES_CB) (GWEN_DB_NODE *node, void *user_data)

## Macro Definition Documentation

## GWEN_DB_DEFAULT_LOCK_TIMEOUT

#define GWEN_DB_DEFAULT_LOCK_TIMEOUT 1000

Definition at line 218 of file db.h.

## GWEN_DB_FLAGS_ADD_GROUP_NEWLINES

#define GWEN_DB_FLAGS_ADD_GROUP_NEWLINES 0x00800000

writes a newline to the stream after writing a group to improve the readability of the created file

Definition at line 137 of file db.h.

## GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM

#define GWEN_DB_FLAGS_ALLOW_EMPTY_STREAM 0x00008000

when reading a DB allow for empty streams (e.g. empty file)

Definition at line 119 of file db.h.

## GWEN_DB_FLAGS_APPEND_FILE

#define GWEN_DB_FLAGS_APPEND_FILE 0x08000000

appends data to an existing file instead of overwriting it

Definition at line 147 of file db.h.

## GWEN_DB_FLAGS_COMPACT

#define GWEN_DB_FLAGS_COMPACT

Value:
(\
GWEN_DB_FLAGS_QUOTE_VALUES | \
GWEN_DB_FLAGS_WRITE_SUBGROUPS | \
GWEN_DB_FLAGS_ESCAPE_CHARVALUES | \
GWEN_DB_FLAGS_UNESCAPE_CHARVALUES\
)
GWEN_DB_FLAGS_QUOTE_VALUES
#define GWEN_DB_FLAGS_QUOTE_VALUES
Definition db.h:127
GWEN_DB_FLAGS_WRITE_SUBGROUPS
#define GWEN_DB_FLAGS_WRITE_SUBGROUPS
Definition db.h:129
GWEN_DB_FLAGS_UNESCAPE_CHARVALUES
#define GWEN_DB_FLAGS_UNESCAPE_CHARVALUES
Definition db.h:152
GWEN_DB_FLAGS_ESCAPE_CHARVALUES
#define GWEN_DB_FLAGS_ESCAPE_CHARVALUES
Definition db.h:149

same like GWEN_DB_FLAGS_DEFAULT except that the produced file (when writing to a stream) is more compact (but less readable)

Definition at line 182 of file db.h.

## GWEN_DB_FLAGS_DEFAULT

#define GWEN_DB_FLAGS_DEFAULT

Value:
(\
GWEN_DB_FLAGS_QUOTE_VALUES | \
GWEN_DB_FLAGS_WRITE_SUBGROUPS | \
GWEN_DB_FLAGS_DETAILED_GROUPS | \
GWEN_DB_FLAGS_INDEND | \
GWEN_DB_FLAGS_ADD_GROUP_NEWLINES | \
GWEN_DB_FLAGS_ESCAPE_CHARVALUES | \
GWEN_DB_FLAGS_UNESCAPE_CHARVALUES\
)
GWEN_DB_FLAGS_DETAILED_GROUPS
#define GWEN_DB_FLAGS_DETAILED_GROUPS
Definition db.h:131
GWEN_DB_FLAGS_ADD_GROUP_NEWLINES
#define GWEN_DB_FLAGS_ADD_GROUP_NEWLINES
Definition db.h:137
GWEN_DB_FLAGS_INDEND
#define GWEN_DB_FLAGS_INDEND
Definition db.h:134

These are the default flags which you use in most cases

Definition at line 168 of file db.h.

## GWEN_DB_FLAGS_DETAILED_GROUPS

#define GWEN_DB_FLAGS_DETAILED_GROUPS 0x00200000

adds some comments when writing to a stream

Definition at line 131 of file db.h.

## GWEN_DB_FLAGS_DOSMODE

#define GWEN_DB_FLAGS_DOSMODE 0x80000000

When writing a DB use DOS line termination (e.g. CR/LF) instead if unix mode (LF only)

Definition at line 165 of file db.h.

## GWEN_DB_FLAGS_ESCAPE_CHARVALUES

#define GWEN_DB_FLAGS_ESCAPE_CHARVALUES 0x10000000

Char values are escaped when writing them to a file.

Definition at line 149 of file db.h.

## GWEN_DB_FLAGS_HTTP

#define GWEN_DB_FLAGS_HTTP

Value:
(\
GWEN_DB_FLAGS_USE_COLON |\
GWEN_DB_FLAGS_UNTIL_EMPTY_LINE |\
GWEN_DB_FLAGS_OMIT_TYPES | \
GWEN_DB_FLAGS_DOSMODE \
)
GWEN_DB_FLAGS_OMIT_TYPES
#define GWEN_DB_FLAGS_OMIT_TYPES
Definition db.h:145
GWEN_DB_FLAGS_UNTIL_EMPTY_LINE
#define GWEN_DB_FLAGS_UNTIL_EMPTY_LINE
Definition db.h:142
GWEN_DB_FLAGS_DOSMODE
#define GWEN_DB_FLAGS_DOSMODE
Definition db.h:165
GWEN_DB_FLAGS_USE_COLON
#define GWEN_DB_FLAGS_USE_COLON
Definition db.h:140

These flags can be used to read a DB from a HTTP header. It uses a colon instead of the equation mark with variable definitions and stops when encountering an empty line.

Definition at line 193 of file db.h.

## GWEN_DB_FLAGS_INDEND

#define GWEN_DB_FLAGS_INDEND 0x00400000

indents text according to the current path depth when writing to a stream to improve the readability of the created file

Definition at line 134 of file db.h.

## GWEN_DB_FLAGS_INSERT

#define GWEN_DB_FLAGS_INSERT 0x40000000

When setting a value or getting a group insert newly created values/groups rather than appending them.

Definition at line 160 of file db.h.

## GWEN_DB_FLAGS_LOCKFILE

#define GWEN_DB_FLAGS_LOCKFILE 0x20000000

locks a file before reading from or writing to it This is used by GWEN_DB_ReadFile and GWEN_DB_WriteFile

Definition at line 155 of file db.h.

## GWEN_DB_FLAGS_OMIT_TYPES

#define GWEN_DB_FLAGS_OMIT_TYPES 0x04000000

normally the type of a variable is written to the stream, too. This flag changes this behaviour

Definition at line 145 of file db.h.

## GWEN_DB_FLAGS_OVERWRITE_GROUPS

#define GWEN_DB_FLAGS_OVERWRITE_GROUPS 0x00020000

Overwrite existing groups when calling GWEN_DB_GetGroup()

Definition at line 123 of file db.h.

## GWEN_DB_FLAGS_OVERWRITE_VARS

#define GWEN_DB_FLAGS_OVERWRITE_VARS 0x00010000

Overwrite existing values when assigning a new value to a variable

Definition at line 121 of file db.h.

## GWEN_DB_FLAGS_QUOTE_VALUES

#define GWEN_DB_FLAGS_QUOTE_VALUES 0x00080000

quote values when writing them to a stream

Definition at line 127 of file db.h.

## GWEN_DB_FLAGS_QUOTE_VARNAMES

#define GWEN_DB_FLAGS_QUOTE_VARNAMES 0x00040000

quote variable names when writing them to a stream

Definition at line 125 of file db.h.

## GWEN_DB_FLAGS_UNESCAPE_CHARVALUES

#define GWEN_DB_FLAGS_UNESCAPE_CHARVALUES 0x10000000

Char values are unescaped when reading them from a file (uses the same bit GWEN_DB_FLAGS_ESCAPE_CHARVALUES uses)

Definition at line 152 of file db.h.

## GWEN_DB_FLAGS_UNTIL_EMPTY_LINE

#define GWEN_DB_FLAGS_UNTIL_EMPTY_LINE 0x02000000

stops reading from a stream at empty lines

Definition at line 142 of file db.h.

## GWEN_DB_FLAGS_USE_COLON

#define GWEN_DB_FLAGS_USE_COLON 0x01000000

uses a colon (":") instead of an equation mark when reading/writing variable definitions

Definition at line 140 of file db.h.

## GWEN_DB_FLAGS_WRITE_SUBGROUPS

#define GWEN_DB_FLAGS_WRITE_SUBGROUPS 0x00100000

allows writing of subgroups when writing to a stream

Definition at line 129 of file db.h.

## GWEN_DB_LINE_MAXSIZE

#define GWEN_DB_LINE_MAXSIZE 1024

maximum size of a text line when reading/writing from/to streams

Definition at line 102 of file db.h.

## GWEN_DB_NODE_FLAGS_DIRTY

#define GWEN_DB_NODE_FLAGS_DIRTY 0x00000001

is set then this node has been altered

Definition at line 207 of file db.h.

## GWEN_DB_NODE_FLAGS_INHERIT_HASH_MECHANISM

#define GWEN_DB_NODE_FLAGS_INHERIT_HASH_MECHANISM 0x00000004

this is only valid for groups. It determines whether subgroups will inherit the hash mechanism set in the root node.

Definition at line 212 of file db.h.

## GWEN_DB_NODE_FLAGS_SAFE

#define GWEN_DB_NODE_FLAGS_SAFE 0x00000008

node has to be disposed of safely (i.e. it will be overridden before freeing it)

Definition at line 214 of file db.h.

## GWEN_DB_NODE_FLAGS_VOLATILE

#define GWEN_DB_NODE_FLAGS_VOLATILE 0x00000002

variable is volatile (will not be written)

Definition at line 209 of file db.h.

## Typedef Documentation

## GWEN_DB_NODE

typedef struct GWEN_DB_NODE GWEN_DB_NODE

This is the type used to store a DB. Its contents are explicitly NOT part of the API.

A description of what can be done with this type can be found in db.h

Definition at line 228 of file db.h.

## GWEN_DB_NODES_CB

typedef void *(* GWEN_DB_NODES_CB) (GWEN_DB_NODE *node, void *user_data)

Callback function type for GWEN_DB_Groups_Foreach(), GWEN_DB_Variables_Foreach(), and GWEN_DB_Values_Foreach().

Parameters

  node | The current node element
  user_data | The arbitrary data passed to the foreach function.

Returns
  NULL if the iteration should continue, or non-NULL if the iteration should stop and that value be returned.

Definition at line 378 of file db.h.

## Enumeration Type Documentation

## GWEN_DB_NODE_TYPE

enum GWEN_DB_NODE_TYPE

This specifies the type of a value stored in the DB.

Enumerator
GWEN_DB_NodeType_Unknown | type unknown
GWEN_DB_NodeType_Group | group
GWEN_DB_NodeType_Var | variable
GWEN_DB_NodeType_ValueChar | simple, null terminated C-string
GWEN_DB_NodeType_ValueInt | integer
GWEN_DB_NodeType_ValueBin | binary, user defined data
GWEN_DB_NodeType_ValuePtr | pointer , will not be stored or read to/from files
GWEN_DB_NodeType_ValueLast | last value type

Definition at line 233 of file db.h.

## Function Documentation

## GWEN_DB_AddCharValue()

GWENHYWFAR_API int GWEN_DB_AddCharValue | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | const char * | val,
|  | int | senseCase,
|  | int | check )

Adds the given char value to the given variable if it not already exists (depending on the arguments senseCase and check).

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  path | path and name of the variable
  val | The string value that is copied into the DB
  senseCase | if 0 then the case of the value is ignored while checking
  check | if 1 then the variable will be checked for this value

References GWENHYWFAR_API.

## GWEN_DB_AddGroup()

GWENHYWFAR_API int GWEN_DB_AddGroup | ( | GWEN_DB_NODE * | parent,
|  | GWEN_DB_NODE * | node )

Adds the given group node as a new child of the given parent group node.

The group name has no influence on what will happen in this function. In other words, if the parent group already has a child group with the same name as 'node', then after this function two child group nodes with the same name will exist.

Note
  This function takes over the ownership of the new group, so you MUST NOT free it afterwards.

Parameters

  parent | Some group node that will be the parent of the added node
  node | Group node to add

References GWENHYWFAR_API.

## GWEN_DB_AddGroupChildren()

GWENHYWFAR_API int GWEN_DB_AddGroupChildren | ( | GWEN_DB_NODE * | n,
|  | GWEN_DB_NODE * | nn )

This function adds all children of the second node as new children to the first given one.

Note
  This function does NOT take over ownership of the new group. The caller is still the owner of the given group.

Parameters

  n | db node
  nn | node whose children are to be added (makes deep copies)

References GWENHYWFAR_API.

## GWEN_DB_ClearGroup()

GWENHYWFAR_API int GWEN_DB_ClearGroup | ( | GWEN_DB_NODE * | n,
|  | const char * | path )

Frees all children of the given node thereby clearing it.

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  path | path to the group under the given node to clear (if 0 then clear the given node)

References GWENHYWFAR_API.

## GWEN_DB_DeleteGroup()

GWENHYWFAR_API int GWEN_DB_DeleteGroup | ( | GWEN_DB_NODE * | n,
|  | const char * | path )

Locates and removes the group of the given name.

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  path | path to the group to delete

References GWENHYWFAR_API.

## GWEN_DB_DeleteVar()

GWENHYWFAR_API int GWEN_DB_DeleteVar | ( | GWEN_DB_NODE * | n,
|  | const char * | path )

Deletes the given variable by removing it and its values from the DB.

Parameters

  n | root of the DB
  path | path to the variable to remove

Returns
  Zero on success, nonzero on error

References GWENHYWFAR_API.

## GWEN_DB_Dump()

GWENHYWFAR_API void GWEN_DB_Dump | ( | GWEN_DB_NODE * | n,
|  | int | insert )

Dumps the content of the given DB to the given file (e.g. stderr).

Parameters

  n | node to dump
  insert | number of blanks to insert at every line

References GWENHYWFAR_API.

## GWEN_DB_FindFirstGroup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_FindFirstGroup | ( | GWEN_DB_NODE * | n,
|  | const char * | name )

Returns the first group node below the given one by name.

If there is no matching group node then NULL is returned. This can either mean that this node does not have any children or the only children are variables instead of groups or their is no group of the given name.

Parameters

  n | db node
  name | name to look for (joker and wildcards allowed)

References GWENHYWFAR_API.

## GWEN_DB_FindFirstVar()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_FindFirstVar | ( | GWEN_DB_NODE * | n,
|  | const char * | name )

Returns the first variable node below the given one by name.

If there is no matching variable node then NULL is returned. This can either mean that this node does not have any children or the only children are groups/values instead of variables or their is no variable of the given name.

Parameters

  n | db node
  name | name to look for (joker and wildcards allowed)

References GWENHYWFAR_API.

## GWEN_DB_FindNextGroup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_FindNextGroup | ( | GWEN_DB_NODE * | n,
|  | const char * | name )

Returns the next group node following the given one, which has the same parent node, by name.

If there is no matching group node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children are variables instead of groups or that there is no group with the given name.

Note
  This is one of the few functions where the returned node is not the child of the specified node, but instead it is the next node with the same parent node. In other words, this function is an exception. In most other functions the returned node is a child of the specified node.

Parameters

  n | db node
  name | name to look for (joker and wildcards allowed)

## GWEN_DB_FindNextVar()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_FindNextVar | ( | GWEN_DB_NODE * | n,
|  | const char * | name )

Returns the next variable node following the given one, which has the same parent node, by name.

If there is no matching variable node then NULL is returned. This can either mean that this node does not have any children or the only children are groups/values instead of variables or their is no variable of the given name.

Note
  This is one of the few functions where the returned node is not the child of the specified node, but instead it is the next node with the same parent node. In other words, this function is an exception. In most other functions the returned node is a child of the specified node.

Parameters

  n | db node
  name | name to look for (joker and wildcards allowed)

References GWENHYWFAR_API.

## GWEN_DB_GetBinValue()

GWENHYWFAR_API const void * GWEN_DB_GetBinValue | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | int | idx,
|  | const void * | defVal,
|  | unsigned int | defValSize,
|  | unsigned int * | returnValueSize )

Returns the variable's retrieved value. The size of the binary data is written into the int pointer argument returnValueSize.

Parameters

  n | db node
  path | path and name of the variable
  idx | index number of the value to return
  defVal | default value to return in case there is no real value
  defValSize | size of the default value
  returnValueSize | pointer to a variable to receive the length of the data returned

References GWENHYWFAR_API.

## GWEN_DB_GetBinValueFromNode()

GWENHYWFAR_API const void * GWEN_DB_GetBinValueFromNode | ( | const GWEN_DB_NODE * | n,
|  | unsigned int * | size )

References GWENHYWFAR_API.

## GWEN_DB_GetCharValue()

GWENHYWFAR_API const char * GWEN_DB_GetCharValue | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | int | idx,
|  | const char * | defVal )

Returns the variable's retrieved value.

Parameters

  n | db node
  path | path and name of the variable
  idx | index number of the value to return
  defVal | default value to return in case there is no real value

References GWENHYWFAR_API.

## GWEN_DB_GetCharValueFromNode()

GWENHYWFAR_API const char * GWEN_DB_GetCharValueFromNode | ( | const GWEN_DB_NODE * | n | ) |

Returns the value data of the given value node. If the given node is not a char-value node then 0 is returned.

References GWENHYWFAR_API.

## GWEN_DB_GetFirstGroup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetFirstGroup | ( | GWEN_DB_NODE * | n | ) |

Returns the first group node below the given one.

If there is no group node then NULL is returned. This can either mean that this node does not have any children or the only children are variables instead of groups.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetFirstValue()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetFirstValue | ( | GWEN_DB_NODE * | n | ) |

Returns the first value below the given variable. If there is no value then NULL is returned.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetFirstVar()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetFirstVar | ( | GWEN_DB_NODE * | n | ) |

Returns the first variable below the given group. If there is no variable then NULL is returned.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetGroup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetGroup | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags,
|  | const char * | path )

This function either creates a new group, returns an existing one or returns an error if there is no group but the caller wanted one (depending on the flags given).

Parameters

  n | db node
  flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use.
  path | path and name of the group to be created/located

References GWENHYWFAR_API.

## GWEN_DB_GetIntValue()

GWENHYWFAR_API int GWEN_DB_GetIntValue | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | int | idx,
|  | int | defVal )

Returns the variable's retrieved value.

Parameters

  n | db node
  path | path and name of the variable
  idx | index number of the value to return
  defVal | default value to return in case there is no real value

References GWENHYWFAR_API.

## GWEN_DB_GetIntValueFromNode()

GWENHYWFAR_API int GWEN_DB_GetIntValueFromNode | ( | const GWEN_DB_NODE * | n | ) |

References GWENHYWFAR_API.

## GWEN_DB_GetNextGroup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetNextGroup | ( | GWEN_DB_NODE * | n | ) |

Returns the next group node following the given one, which has the same parent node.

This function works absolutely independently of the group nodes' names – the returned node may or may not have the same name as the specified node. The only guarantee is that the returned node will be a group node.

If there is no group node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children are variables instead of groups.

Note
  This is one of the few functions where the returned node is not the child of the specified node, but instead it is the next node with the same parent node. In other words, this function is an exception. In most other functions the returned node is a child of the specified node.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetNextValue()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetNextValue | ( | GWEN_DB_NODE * | n | ) |

Returns the next value node following the given one, which has the same parent node.

If there is no value node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children aren't values.

Note
  This is the only function where the returned node is not the child of the specified node, but instead it is the next node with the same parent node. In other words, this function is an exception. In all other functions the returned node is a child of the specified node.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetNextVar()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetNextVar | ( | GWEN_DB_NODE * | n | ) |

Returns the next variable node following the given one, which has the same parent node.

This function works absolutely independently of the variable nodes' names – the returned node may or may not have the same name as the specified node. The only guarantee is that the returned node will be a variable node.

If there is no variable node then NULL is returned. This can either mean that the parent node does not have any further children, or that the other children are groups instead of variables.

Note
  This is the only function where the returned node is not the child of the specified node, but instead it is the next node with the same parent node. In other words, this function is an exception. In all other functions the returned node is a child of the specified node.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetNodeFlags()

GWENHYWFAR_API uint32_t GWEN_DB_GetNodeFlags | ( | const GWEN_DB_NODE * | n | ) |

Returns the node flags for the given db node. Please note that all modifications applied to a node will set the dirty flag in the node itself and all its parents. This allows to use this funcion here to check whether a DB has been modified.

Returns
  current node flags for this node (see GWEN_DB_NODE_FLAGS_DIRTY)

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetParentGroup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_GetParentGroup | ( | GWEN_DB_NODE * | n | ) |

Returns the parent group of the given node.

References GWENHYWFAR_API.

## GWEN_DB_GetPtrValue()

GWENHYWFAR_API void * GWEN_DB_GetPtrValue | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | int | idx,
|  | void * | defVal )

Returns the variable's retrieved value.

Parameters

  n | db node
  path | path and name of the variable
  idx | index number of the value to return
  defVal | default value to return in case there is no real value

References GWENHYWFAR_API.

## GWEN_DB_GetValueType()

GWENHYWFAR_API GWEN_DB_NODE_TYPE GWEN_DB_GetValueType | ( | GWEN_DB_NODE * | n | ) |

Returns the type of the given value.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_GetValueTypeByPath()

GWENHYWFAR_API GWEN_DB_NODE_TYPE GWEN_DB_GetValueTypeByPath | ( | GWEN_DB_NODE * | n,
|  | const char * | p,
|  | unsigned int | i )

References GWENHYWFAR_API.

## GWEN_DB_GetVariableType()

GWENHYWFAR_API GWEN_DB_NODE_TYPE GWEN_DB_GetVariableType | ( | GWEN_DB_NODE * | n,
|  | const char * | p )

Returns the type of the first value of the given variable

Parameters

  n | root node of the DB
  p | path of the variable to inspect

References GWENHYWFAR_API.

## GWEN_DB_Group_dup()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_Group_dup | ( | const GWEN_DB_NODE * | n | ) |

Creates a deep copy of the given node. This copy will then be owned by the caller and MUST be freed after using it by calling GWEN_DB_Group_free().

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_Group_free()

GWENHYWFAR_API void GWEN_DB_Group_free | ( | GWEN_DB_NODE * | n | ) |

Frees a DB group. I.e. this is the destructor. This is needed to avoid memory leaks.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_Group_new()

GWENHYWFAR_API GWEN_DB_NODE * GWEN_DB_Group_new | ( | const char * | name | ) |

Creates a new (empty) group with the given name. I.e. this is the constructor. When finished using this group, you should free it using GWEN_DB_Group_free() in order to avoid memory leaks.

Parameters

  name | name of the group to create

References GWENHYWFAR_API.

## GWEN_DB_GroupName()

GWENHYWFAR_API const char * GWEN_DB_GroupName | ( | GWEN_DB_NODE * | n | ) |

Returns the name of the given group.

References GWENHYWFAR_API.

## GWEN_DB_GroupRename()

GWENHYWFAR_API void GWEN_DB_GroupRename | ( | GWEN_DB_NODE * | n,
|  | const char * | newname )

Renames the given group.

Parameters

  n | db node
  newname | new name for the group

References GWENHYWFAR_API.

## GWEN_DB_Groups_Count()

GWENHYWFAR_API unsigned int GWEN_DB_Groups_Count | ( | const GWEN_DB_NODE * | node | ) |

Returns the number of group nodes that are direct children of the given node. In other words, this is the number of group nodes that will be reached in the GWEN_DB_Groups_foreach() function.

References GWENHYWFAR_API.

## GWEN_DB_Groups_Foreach()

GWENHYWFAR_API void * GWEN_DB_Groups_Foreach | ( | GWEN_DB_NODE * | node,
|  | GWEN_DB_NODES_CB | func,
|  | void * | user_data )

Iterates through all group nodes that are direct children of the given node, calling the callback function 'func' on each group node. Traversal will stop when 'func' returns a non-NULL value, and the routine will return with that value. Otherwise the routine will return NULL.

If no nodes that are groups are found as children, then this function will simply do nothing.

Parameters

  node | The group node whose children shall be iterated through.
  func | The function to be called with each group node.
  user_data | A pointer passed on to the function 'func'.

Returns
  The non-NULL pointer returned by 'func' as soon as it returns one. Otherwise (i.e. 'func' always returns NULL) returns NULL.

Author
  Christian Stimming stimm.nosp@m.ing@.nosp@m.tuhh..nosp@m.de

References GWENHYWFAR_API.

## GWEN_DB_InsertGroup()

GWENHYWFAR_API int GWEN_DB_InsertGroup | ( | GWEN_DB_NODE * | parent,
|  | GWEN_DB_NODE * | node )

Adds the given group node as the new first child of the given parent group node.

The group name has no influence on what will happen in this function. In other words, if the parent group already has a child group with the same name as 'node', then after this function two child group nodes with the same name will exist.

Note
  This function takes over the ownership of the new group, so you MUST NOT free it afterwards.

Parameters

  parent | Some group node that will be the parent of the added node
  node | Group node to add

References GWENHYWFAR_API.

## GWEN_DB_IsGroup()

GWENHYWFAR_API int GWEN_DB_IsGroup | ( | const GWEN_DB_NODE * | n | ) |

Predicate: Returns nonzero (TRUE) or zero (FALSE) if the given NODE is a Group or not. Usually these group nodes are the only nodes that the application gets in touch with.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_IsValue()

GWENHYWFAR_API int GWEN_DB_IsValue | ( | const GWEN_DB_NODE * | n | ) |

Predicate: Returns nonzero (TRUE) or zero (FALSE) if the given NODE is a Value or not. Usually the Application does not get in touch with such Nodes but only with nodes that are Groups.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_IsVariable()

GWENHYWFAR_API int GWEN_DB_IsVariable | ( | const GWEN_DB_NODE * | n | ) |

Predicate: Returns nonzero (TRUE) or zero (FALSE) if the given NODE is a Variable or not. Usually the Application does not get in touch with such Nodes but only with nodes that are Groups.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_ModifyBranchFlagsDown()

GWENHYWFAR_API void GWEN_DB_ModifyBranchFlagsDown | ( | GWEN_DB_NODE * | n,
|  | uint32_t | newflags,
|  | uint32_t | mask )

Modifies the flags of the given node and all its children according to the parameters given.

Parameters

  n | db node
  newflags | new flags to set (see GWEN_DB_NODE_FLAGS_DIRTY)
  mask | only those flags which are set in this mask are modified according to newflags

References GWENHYWFAR_API.

## GWEN_DB_ModifyBranchFlagsUp()

GWENHYWFAR_API void GWEN_DB_ModifyBranchFlagsUp | ( | GWEN_DB_NODE * | n,
|  | uint32_t | newflags,
|  | uint32_t | mask )

Modifies the flags of the given node and all its parents according to the parameters given.

Parameters

  n | db node
  newflags | new flags to set (see GWEN_DB_NODE_FLAGS_DIRTY)
  mask | only those flags which are set in this mask are modified according to newflags

References GWENHYWFAR_API.

## GWEN_DB_ReadFile()

GWENHYWFAR_API int GWEN_DB_ReadFile | ( | GWEN_DB_NODE * | n,
|  | const char * | fname,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_ReadFileAs()

GWENHYWFAR_API int GWEN_DB_ReadFileAs | ( | GWEN_DB_NODE * | n,
|  | const char * | fname,
|  | const char * | type,
|  | GWEN_DB_NODE * | params,
|  | uint32_t | dbflags )

Imports a file into a DB using a GWEN_DBIO importer.

Parameters

  n | node to read into (becomes the root of the imported data)
  fname | name of the file to import
  type | GWEN_DBIO type
  params | parameters for the GWEN_DBIO importer (content depends on the importer, may even be NULL for some types)
  dbflags | flags to use while importing (see GWEN_DB_FLAGS_OVERWRITE_VARS and others)

References GWENHYWFAR_API.

## GWEN_DB_ReadFromFastBuffer()

GWENHYWFAR_API int GWEN_DB_ReadFromFastBuffer | ( | GWEN_DB_NODE * | n,
|  | GWEN_FAST_BUFFER * | fb,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_ReadFromIo()

GWENHYWFAR_API int GWEN_DB_ReadFromIo | ( | GWEN_DB_NODE * | n,
|  | GWEN_SYNCIO * | sio,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_ReadFromString()

GWENHYWFAR_API int GWEN_DB_ReadFromString | ( | GWEN_DB_NODE * | n,
|  | const char * | str,
|  | int | len,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_RemoveCharValue()

GWENHYWFAR_API int GWEN_DB_RemoveCharValue | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | const char * | val,
|  | int | senseCase )

Removes the given char value from the given variable if it exists (depending on the arguments senseCase and check).

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  path | path and name of the variable
  val | The string value to be removed
  senseCase | if 0 then the case of the value is ignored while checking

References GWENHYWFAR_API.

## GWEN_DB_ReplaceVars()

GWENHYWFAR_API int GWEN_DB_ReplaceVars | ( | GWEN_DB_NODE * | db,
|  | const char * | s,
|  | GWEN_BUFFER * | dbuf )

Read the given string and replace every variable in that string ( noted as "$(varname)") with the value of the mentioned variable.

## GWEN_DB_SetBinValue()

GWENHYWFAR_API int GWEN_DB_SetBinValue | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags,
|  | const char * | path,
|  | const void * | val,
|  | unsigned int | valSize )

Parameters

  n | db node
  path | path and name of the variable
  flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use.
  val | The binary data that is copied into the DB.
  valSize | The number of bytes in the binary data value.

Returns
  0 on success, nonzero on error

References GWENHYWFAR_API.

## GWEN_DB_SetCharValue()

GWENHYWFAR_API int GWEN_DB_SetCharValue | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags,
|  | const char * | path,
|  | const char * | val )

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use.
  path | path and name of the variable
  val | The string value that is copied into the DB

References GWENHYWFAR_API.

## GWEN_DB_SetCharValueFromInt()

GWENHYWFAR_API int GWEN_DB_SetCharValueFromInt | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags,
|  | const char * | path,
|  | int | val )

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use.
  path | path and name of the variable
  val | The integer value to be stored as string value in the DB

References GWENHYWFAR_API.

## GWEN_DB_SetCharValueInNode()

GWENHYWFAR_API int GWEN_DB_SetCharValueInNode | ( | GWEN_DB_NODE * | n,
|  | const char * | s )

Replaces the current value data of the given node by the new string.

Returns
  0 if ok, error code otherwise

References GWENHYWFAR_API.

## GWEN_DB_SetIntValue()

GWENHYWFAR_API int GWEN_DB_SetIntValue | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags,
|  | const char * | path,
|  | int | val )

Returns
  0 on success, nonzero on error

Parameters

  n | db node
  flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use.
  path | path and name of the variable
  val | new value

References GWENHYWFAR_API.

## GWEN_DB_SetNodeFlags()

GWENHYWFAR_API void GWEN_DB_SetNodeFlags | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags )

Modifies the node flags for the given db node

Parameters

  n | db node
  flags | flags to set (see GWEN_DB_NODE_FLAGS_DIRTY)

References GWENHYWFAR_API.

## GWEN_DB_SetPtrValue()

GWENHYWFAR_API int GWEN_DB_SetPtrValue | ( | GWEN_DB_NODE * | n,
|  | uint32_t | flags,
|  | const char * | path,
|  | void * | val )

Parameters

  n | db node
  path | path and name of the variable
  flags | see GWEN_DB_FLAGS_OVERWRITE_VARS and others which can all be OR-combined to form the flags to use.
  val | The pointer that is stored within the DB.

Returns
  0 on success, nonzero on error

References GWENHYWFAR_API.

## GWEN_DB_UnlinkGroup()

GWENHYWFAR_API void GWEN_DB_UnlinkGroup | ( | GWEN_DB_NODE * | n | ) |

Unlinks a group (and thereby all its children) from its parent and brothers.

This function DOES NOT free the group, it just unlinks it. You can then use it with e.g. GWEN_DB_AddGroup or other functions to relink it at any other position of even in other DBs.

Parameters

  n | db node

References GWENHYWFAR_API.

## GWEN_DB_ValueExists()

GWENHYWFAR_API int GWEN_DB_ValueExists | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | unsigned int | idx )

Checks whether the given variable and value exists.

Returns
  Zero if variable not found, nonzero otherwise

Parameters

  n | root of the DB
  path | path to the variable to check for
  idx | index number of the variable's value to check for

References GWENHYWFAR_API.

## GWEN_DB_Values_Count()

GWENHYWFAR_API unsigned int GWEN_DB_Values_Count | ( | const GWEN_DB_NODE * | node | ) |

Returns the number of value nodes that are direct children of the given node. In other words, this is the number of value nodes that will be reached in the GWEN_DB_Values_foreach() function.

References GWENHYWFAR_API.

## GWEN_DB_Values_Foreach()

GWENHYWFAR_API void * GWEN_DB_Values_Foreach | ( | GWEN_DB_NODE * | node,
|  | GWEN_DB_NODES_CB | func,
|  | void * | user_data )

Iterates through all value nodes that are direct children of the given node, calling the callback function 'func' on each value node. Traversal will stop when 'func' returns a non-NULL value, and the routine will return with that value. Otherwise the routine will return NULL.

If no nodes that are values are found as children, then this function will simply do nothing.

Parameters

  node | The variable node whose children shall be iterated through.
  func | The function to be called with each group node.
  user_data | A pointer passed on to the function 'func'.

Returns
  The non-NULL pointer returned by 'func' as soon as it returns one. Otherwise (i.e. 'func' always returns NULL) returns NULL.

Author
  Christian Stimming stimm.nosp@m.ing@.nosp@m.tuhh..nosp@m.de

References GWENHYWFAR_API.

## GWEN_DB_VariableExists()

GWENHYWFAR_API int GWEN_DB_VariableExists | ( | GWEN_DB_NODE * | n,
|  | const char * | path )

Checks whether the given variable exists.

Returns
  Zero if variable not found, nonzero otherwise

Parameters

  n | root of the DB
  path | path to the variable to check for

References GWENHYWFAR_API.

## GWEN_DB_VariableName()

GWENHYWFAR_API const char * GWEN_DB_VariableName | ( | GWEN_DB_NODE * | n | ) |

Returns the name of the variable specified by the given node.

Parameters

  n | db node specifying a variable (not a group !)

References GWENHYWFAR_API.

## GWEN_DB_VariableRename()

GWENHYWFAR_API void GWEN_DB_VariableRename | ( | GWEN_DB_NODE * | n,
|  | const char * | newname )

References GWENHYWFAR_API.

## GWEN_DB_Variables_Count()

GWENHYWFAR_API unsigned int GWEN_DB_Variables_Count | ( | const GWEN_DB_NODE * | node | ) |

Returns the number of variable nodes that are direct children of the given node. In other words, this is the number of variable nodes that will be reached in the GWEN_DB_Variables_Foreach() function.

References GWENHYWFAR_API.

## GWEN_DB_Variables_Foreach()

GWENHYWFAR_API void * GWEN_DB_Variables_Foreach | ( | GWEN_DB_NODE * | node,
|  | GWEN_DB_NODES_CB | func,
|  | void * | user_data )

Iterates through all variable nodes that are direct children of the given node, calling the callback function 'func' on each variable node. Traversal will stop when 'func' returns a non-NULL value, and the routine will return with that value. Otherwise the routine will return NULL.

If no nodes that are variables are found as children, then this function will simply do nothing.

Parameters

  node | The group node whose children shall be iterated through.
  func | The function to be called with each group node.
  user_data | A pointer passed on to the function 'func'.

Returns
  The non-NULL pointer returned by 'func' as soon as it returns one. Otherwise (i.e. 'func' always returns NULL) returns NULL.

Author
  Christian Stimming stimm.nosp@m.ing@.nosp@m.tuhh..nosp@m.de

References GWENHYWFAR_API.

## GWEN_DB_WriteFile()

GWENHYWFAR_API int GWEN_DB_WriteFile | ( | GWEN_DB_NODE * | n,
|  | const char * | fname,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_WriteFileAs()

GWENHYWFAR_API int GWEN_DB_WriteFileAs | ( | GWEN_DB_NODE * | n,
|  | const char * | fname,
|  | const char * | type,
|  | GWEN_DB_NODE * | params,
|  | uint32_t | dbflags )

Exports a DB to a file using a GWEN_DBIO exporter.

Parameters

  n | node to write
  fname | name of the file to export to
  type | GWEN_DBIO type
  params | parameters for the GWEN_DBIO exporter (content depends on the exporter, may even be NULL for some types)
  dbflags | flags to use while exporting (see GWEN_DB_FLAGS_OVERWRITE_VARS and others)

References GWENHYWFAR_API.

## GWEN_DB_WriteToBuffer()

GWENHYWFAR_API int GWEN_DB_WriteToBuffer | ( | GWEN_DB_NODE * | n,
|  | GWEN_BUFFER * | buf,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_WriteToFastBuffer()

GWENHYWFAR_API int GWEN_DB_WriteToFastBuffer | ( | GWEN_DB_NODE * | node,
|  | GWEN_FAST_BUFFER * | fb,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_WriteToIo()

GWENHYWFAR_API int GWEN_DB_WriteToIo | ( | GWEN_DB_NODE * | node,
|  | GWEN_SYNCIO * | sio,
|  | uint32_t | dbflags )

References GWENHYWFAR_API.

## GWEN_DB_WriteVarValueToBuffer()

GWENHYWFAR_API int GWEN_DB_WriteVarValueToBuffer | ( | GWEN_DB_NODE * | n,
|  | const char * | path,
|  | int | index,
|  | GWEN_BUFFER * | dstBuf )

Returns
  0 if okay, error code on error (GWEN_ERROR_NO_DATA if the variable doesn't exist or has no value)

Parameters

  n | db node
  path | path and name of the variable
  index | number of value to read (if there are multiple values in the variable, 0 being the first)
  dstBuf | buffer to write the value into

Returns
  0 on success, nonzero on error

References GWENHYWFAR_API.