![]() |
programmer's documentation
|
#include "cs_defs.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "bft_mem.h"
#include "cs_tree.h"
Functions | |
static cs_tree_node_t * | _find_or_create_node (cs_tree_node_t *root, const char *path) |
Search for a node located at path from root. More... | |
static cs_tree_node_t * | _find_node (const cs_tree_node_t *root, const char *path) |
Search for a node located at path from root. More... | |
cs_tree_node_t * | cs_tree_node_create (const char *name) |
Create an empty node. Only the name is assigned if given. More... | |
void | cs_tree_node_free (cs_tree_node_t **pnode) |
Free a cs_tree_node_t structure. More... | |
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 a node with read/write access. This node is located at "path" from the given root node level switch is indicated by a "/" in path Exit on error if not found. 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 in read-only access. This node is located at "path" from the given root node level switch is indicated by a "/" in path Exit on error if not found. 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... | |
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... | |
void | cs_tree_free (cs_tree_node_t **proot) |
Free a branch in a tree starting from root. If root is the real root of the tree, the whole tree is freed. 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... | |
|
static |
Search for a node located at path from root.
[in] | root | pointer to the root node where we start searching |
[in] | path | string describing the path access |
|
static |
Search for a node located at path from root.
[in] | root | pointer to the root node where we start searching |
[in] | path | string describing the path access |
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.
[in,out] | parent | pointer to the parent node to handle |
[in] | name | name of the node to add |
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.
[in,out] | sibling | pointer to the sibling node to handle |
[in] | name | name of the node to add |
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".
[in] | log | indicate which log file to use |
[in] | depth | starting depth in the tree |
[in] | root | pointer to a cs_tree_node_t to dump |
void cs_tree_free | ( | cs_tree_node_t ** | proot | ) |
Free a branch in a tree starting from root. If root is the real root of the tree, the whole tree is freed.
[in,out] | proot | pointer to a pointer to a cs_tree_node_t to free |
const cs_tree_node_t* cs_tree_get_node | ( | const cs_tree_node_t * | root, |
const char * | path | ||
) |
Retrieve the pointer to a node in read-only access. This node is located at "path" from the given root node level switch is indicated by a "/" in path Exit on error if not found.
[in] | root | pointer to the root node where we start searching |
[in] | path | string describing the path access |
cs_tree_node_t* cs_tree_get_node_rw | ( | cs_tree_node_t * | root, |
const char * | path | ||
) |
Retrieve the pointer to a node with read/write access. This node is located at "path" from the given root node level switch is indicated by a "/" in path Exit on error if not found.
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 Exit on error if not found.
[in,out] | root | pointer to the root node where we start searching |
[in] | path | string describing the path access |
cs_tree_node_t* cs_tree_node_create | ( | const char * | name | ) |
Create an empty node. Only the name is assigned if given.
[in] | name | name of the node or NULL |
void cs_tree_node_dump | ( | cs_log_t | log, |
int | depth, | ||
const cs_tree_node_t * | node | ||
) |
Dump a cs_tree_node_t structure.
[in] | log | indicate which log file to use |
[in] | depth | shift to apply when printing |
[in] | node | pointer to a cs_tree_node_t to dump |
void cs_tree_node_free | ( | cs_tree_node_t ** | pnode | ) |
Free a cs_tree_node_t structure.
[in,out] | pnode | pointer to a pointer to a cs_tree_node_t to free |
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.
[in,out] | node | pointer to a cs_tree_node_t to modify |
[in] | val | boolean |
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.
[in,out] | node | pointer to a cs_tree_node_t to modify |
[in] | size | number of elements in val |
[in] | val | array of boolean |
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.
[in,out] | node | pointer to a cs_tree_node_t to modify |
[in] | size | number of integers in val |
[in] | val | array of integers |
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.
[in,out] | node | pointer to a cs_tree_node_t to modify |
[in] | size | number of elements in val |
[in] | val | array of real values |
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.
[in,out] | node | pointer to a cs_tree_node_t to modify |
[in] | val | value of the string |