programmer's documentation
Data Structures | Macros | Functions
cs_tree.h File Reference
#include "cs_defs.h"
#include "cs_base.h"
#include "cs_log.h"
Include dependency graph for cs_tree.h:

Go to the source code of this file.

Data Structures

struct  cs_tree_node_t
 

Macros

#define CS_TREE_NODE_INTEGER   (1 << 0) /* 1: value is an integer */
 
#define CS_TREE_NODE_REAL   (1 << 1) /* 2: value is a cs_real_t */
 
#define CS_TREE_NODE_BOOL   (1 << 2) /* 4: value is a bool */
 

Functions

cs_tree_node_t * cs_tree_node_create (const char *name)
 Create an empty node. More...
 
void cs_tree_node_free (cs_tree_node_t **pnode)
 Free a branch in a tree starting from a node. More...
 
void cs_tree_node_set_name (cs_tree_node_t *node, const char *name)
 Name or rename a node. More...
 
void cs_tree_node_set_val_string (cs_tree_node_t *node, const char *val)
 Allocate the value member of a node and assign to it a string. More...
 
static void cs_tree_node_set_string_val (cs_tree_node_t *node, const char *val)
 Allocate the value member of a node and assign to it a string. More...
 
void cs_tree_node_set_bool (cs_tree_node_t *node, bool val)
 Allocate the value member of a node and assign to it a boolean. More...
 
void cs_tree_node_set_bool_val (cs_tree_node_t *node, int size, const bool *val)
 Allocate the value member of a node and assign to it a boolean. More...
 
void cs_tree_node_set_int_val (cs_tree_node_t *node, int size, const int *val)
 Allocate the value member of a node and assign to it an integer. More...
 
void cs_tree_node_set_real_val (cs_tree_node_t *node, int size, const cs_real_t *val)
 Allocate the value member of a node and assign to it an array of real values. More...
 
void cs_tree_node_dump (cs_log_t log, int depth, const cs_tree_node_t *node)
 Dump a cs_tree_node_t structure. More...
 
cs_tree_node_t * cs_tree_get_node_rw (cs_tree_node_t *root, const char *path)
 Retrieve the pointer to the value member of the node. More...
 
const cs_tree_node_t * cs_tree_get_node (const cs_tree_node_t *root, const char *path)
 Retrieve the pointer to a node with read-only access. More...
 
static const char * cs_tree_get_node_string_val (const cs_tree_node_t *root, const char *path)
 Retrieve a read-only pointer to the value member of the node in case of a string. More...
 
cs_tree_node_t * cs_tree_add_child (cs_tree_node_t *parent, const char *name)
 Create and add a node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_child_str (cs_tree_node_t *parent, const char *name, const char *val_str)
 Create and add a node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_string_child (cs_tree_node_t *parent, const char *name, const char *val_str)
 Create and add a node in a tree below the given parent node. More...
 
cs_tree_node_t * cs_tree_add_sibling (cs_tree_node_t *sibling, const char *name)
 Create and add a node in a tree at the right of the given node. More...
 
static cs_tree_node_t * cs_tree_add_child_bool (cs_tree_node_t *parent, const char *name, bool val)
 Create and add a boolean-valued node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_bool_child (cs_tree_node_t *parent, const char *name, bool val)
 Create and add a boolean-valued node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_child_int (cs_tree_node_t *parent, const char *name, int val)
 Create and add an integer-valued node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_int_child (cs_tree_node_t *parent, const char *name, int val)
 Create and add an integer-valued node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_child_real (cs_tree_node_t *parent, const char *name, cs_real_t val)
 Create and add a real-valued node in a tree below the given parent node. More...
 
static cs_tree_node_t * cs_tree_add_real_child (cs_tree_node_t *parent, const char *name, cs_real_t val)
 Create and add a real-valued node in a tree below the given parent node. More...
 
void cs_tree_dump (cs_log_t log, int depth, const cs_tree_node_t *root)
 Dump a cs_tree_node_t structure starting from the node "root". More...
 

Macro Definition Documentation

◆ CS_TREE_NODE_BOOL

#define CS_TREE_NODE_BOOL   (1 << 2) /* 4: value is a bool */

◆ CS_TREE_NODE_INTEGER

#define CS_TREE_NODE_INTEGER   (1 << 0) /* 1: value is an integer */

◆ CS_TREE_NODE_REAL

#define CS_TREE_NODE_REAL   (1 << 1) /* 2: value is a cs_real_t */

Function Documentation

◆ cs_tree_add_bool_child()

static cs_tree_node_t* cs_tree_add_bool_child ( cs_tree_node_t *  parent,
const char *  name,
bool  val 
)
inlinestatic

Create and add a boolean-valued node in a tree below the given parent node.

Deprecated:
Use cs_tree_add_child_bool instead.
Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]valnode value to assign
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_child()

cs_tree_node_t* cs_tree_add_child ( cs_tree_node_t *  parent,
const char *  name 
)

Create and add a node in a tree below the given parent node.

Parameters
[in,out]parentpointer to the parent node to handle.
[in]namename of the node to add
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_child_bool()

static cs_tree_node_t* cs_tree_add_child_bool ( cs_tree_node_t *  parent,
const char *  name,
bool  val 
)
inlinestatic

Create and add a boolean-valued node in a tree below the given parent node.

Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]valnode value to assign
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_child_int()

static cs_tree_node_t* cs_tree_add_child_int ( cs_tree_node_t *  parent,
const char *  name,
int  val 
)
inlinestatic

Create and add an integer-valued node in a tree below the given parent node.

Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]valnode value to assign
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_child_real()

static cs_tree_node_t* cs_tree_add_child_real ( cs_tree_node_t *  parent,
const char *  name,
cs_real_t  val 
)
inlinestatic

Create and add a real-valued node in a tree below the given parent node.

Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]valnode value to assign
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_child_str()

static cs_tree_node_t* cs_tree_add_child_str ( cs_tree_node_t *  parent,
const char *  name,
const char *  val_str 
)
inlinestatic

Create and add a node in a tree below the given parent node.

This node has a string value set to val_str.

Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]val_strnode value to set
Returns
a pointer to the new node in the tree structure

◆ cs_tree_add_int_child()

static cs_tree_node_t* cs_tree_add_int_child ( cs_tree_node_t *  parent,
const char *  name,
int  val 
)
inlinestatic

Create and add an integer-valued node in a tree below the given parent node.

Deprecated:
Use cs_tree_add_child_int instead.
Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]valnode value to assign
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_real_child()

static cs_tree_node_t* cs_tree_add_real_child ( cs_tree_node_t *  parent,
const char *  name,
cs_real_t  val 
)
inlinestatic

Create and add a real-valued node in a tree below the given parent node.

Deprecated:
Use cs_tree_add_child_real instead.
Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]valnode value to assign
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_sibling()

cs_tree_node_t* cs_tree_add_sibling ( cs_tree_node_t *  sibling,
const char *  name 
)

Create and add a node in a tree at the right of the given node.

Parameters
[in,out]siblingpointer to the sibling node to handle
[in]namename of the node to add
Returns
pointer to the new node in the tree structure

◆ cs_tree_add_string_child()

static cs_tree_node_t* cs_tree_add_string_child ( cs_tree_node_t *  parent,
const char *  name,
const char *  val_str 
)
inlinestatic

Create and add a node in a tree below the given parent node.

This node has a string value set to val_str.

Deprecated:
Use cs_tree_add_child_str instead.
Parameters
[in,out]parentpointer to the parent node to handle
[in]namename of the node to add
[in]val_strnode value to set
Returns
a pointer to the new node in the tree structure

◆ cs_tree_dump()

void cs_tree_dump ( cs_log_t  log,
int  depth,
const cs_tree_node_t *  root 
)

Dump a cs_tree_node_t structure starting from the node "root".

Parameters
[in]logindicate which log file to use
[in]depthstarting depth in the tree
[in]rootpointer to a cs_tree_node_t to dump

◆ cs_tree_get_node()

const cs_tree_node_t* cs_tree_get_node ( const cs_tree_node_t *  root,
const char *  path 
)

Retrieve the pointer to a node with read-only access.

This node is located at "path" from the given root node level switch is indicated by a "/" in path.

Exits on error if not found.

Parameters
[in]rootpointer to the root node where we start searching
[in]pathstring describing the path access
Returns
pointer to the node

◆ cs_tree_get_node_rw()

cs_tree_node_t* cs_tree_get_node_rw ( cs_tree_node_t *  root,
const char *  path 
)

Retrieve the pointer to the value member of the node.

This node can be modified.

This node is located at "path" from the given root node level switch is indicated by a "/" in path

Exits on error if not found.

Parameters
[in,out]rootpointer to the root node where we start searching
[in]pathstring describing the path access
Returns
pointer to the node

◆ cs_tree_get_node_string_val()

static const char* cs_tree_get_node_string_val ( const cs_tree_node_t *  root,
const char *  path 
)
inlinestatic

Retrieve a read-only pointer to the value member of the node in case of a string.

This node is located at "path" from the given root node level switch is indicated by a "/" in path.

Parameters
[in,out]rootpointer to the root node where we start searching
[in]pathstring describing the path access
Returns
pointer to the string

◆ cs_tree_node_create()

cs_tree_node_t* cs_tree_node_create ( const char *  name)

Create an empty node.

Only the name is assigned if given

Parameters
[in]namename of the node, or NULL
Returns
pointer to a new allocated cs_tree_node_t structure

◆ cs_tree_node_dump()

void cs_tree_node_dump ( cs_log_t  log,
int  depth,
const cs_tree_node_t *  node 
)

Dump a cs_tree_node_t structure.

Parameters
[in]logindicate which log file to use
[in]depthshift to apply when printing
[in]nodepointer to a cs_tree_node_t to dump

◆ cs_tree_node_free()

void cs_tree_node_free ( cs_tree_node_t **  pnode)

Free a branch in a tree starting from a node.

If the node is the root of the tree, the whole tree is freed.

Parameters
[in,out]pnodepointer to a pointer to a cs_tree_node_t to free

◆ cs_tree_node_set_bool()

void cs_tree_node_set_bool ( cs_tree_node_t *  node,
bool  val 
)

Allocate the value member of a node and assign to it a boolean.

Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]valboolean

◆ cs_tree_node_set_bool_val()

void cs_tree_node_set_bool_val ( cs_tree_node_t *  node,
int  size,
const bool *  val 
)

Allocate the value member of a node and assign to it a boolean.

Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]sizenumber of elements in val
[in]valarray of boolean

◆ cs_tree_node_set_int_val()

void cs_tree_node_set_int_val ( cs_tree_node_t *  node,
int  size,
const int *  val 
)

Allocate the value member of a node and assign to it an integer.

Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]sizenumber of integers in val
[in]valarray of integers

◆ cs_tree_node_set_name()

void cs_tree_node_set_name ( cs_tree_node_t *  node,
const char *  name 
)

Name or rename a node.

Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]namename to set

◆ cs_tree_node_set_real_val()

void cs_tree_node_set_real_val ( cs_tree_node_t *  node,
int  size,
const cs_real_t val 
)

Allocate the value member of a node and assign to it an array of real values.

Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]sizenumber of elements in val
[in]valarray of real values

◆ cs_tree_node_set_string_val()

static void cs_tree_node_set_string_val ( cs_tree_node_t *  node,
const char *  val 
)
inlinestatic

Allocate the value member of a node and assign to it a string.

Deprecated:
Use cs_tree_node_set_val_string instead.
Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]valvalue of the string

◆ cs_tree_node_set_val_string()

void cs_tree_node_set_val_string ( cs_tree_node_t *  node,
const char *  val 
)

Allocate the value member of a node and assign to it a string.

Parameters
[in,out]nodepointer to a cs_tree_node_t to modify
[in]valvalue of the string