|
gwenhywfar 5.10.1
|
#include <gwenhywfar/gwenhywfarapi.h>#include <gwenhywfar/types.h>#include <assert.h>
Go to the source code of this file.
Macros | |
| #define | GWEN_DUMMY_EMPTY_ARG |
| #define | GWEN_TREE_H |
Typesafe Macros | |
| #define | GWEN_TREE_ELEMENT(t) GWEN_TREE_ELEMENT *_tree_element; |
| #define | GWEN_TREE_FINI(t, element) |
| #define | GWEN_TREE_FUNCTION_DEFS(t, pr) GWEN_TREE_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) |
| #define | GWEN_TREE_FUNCTION_DEFS_CONST(t, pr) GWEN_TREE_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
| #define | GWEN_TREE_FUNCTION_DEFS_NOCONST(t, pr) GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
| #define | GWEN_TREE_FUNCTION_LIB_DEFS(t, pr, decl) |
| #define | GWEN_TREE_FUNCTION_LIB_DEFS_CONST(t, pr, decl) |
| #define | GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl) |
| #define | GWEN_TREE_FUNCTIONS(t, pr) |
| #define | GWEN_TREE_INIT(t, element) element->_tree_element=GWEN_TreeElement_new(element); |
| #define GWEN_DUMMY_EMPTY_ARG |
| #define GWEN_TREE_ELEMENT | ( | t | ) | GWEN_TREE_ELEMENT *_tree_element; |
| #define GWEN_TREE_FINI | ( | t, | |
| element | |||
| ) |
Use this in your code file (*.c) inside the fini code for the struct you want to use in lists (in GWEN these are the functions which end with "_free".
| #define GWEN_TREE_FUNCTION_DEFS | ( | t, | |
| pr | |||
| ) | GWEN_TREE_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) |
This macro should be used in applications, not in libraries. In libraries please use the macro GWEN_TREE_FUNCTION_LIB_DEFS.
| #define GWEN_TREE_FUNCTION_DEFS_CONST | ( | t, | |
| pr | |||
| ) | GWEN_TREE_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
| #define GWEN_TREE_FUNCTION_DEFS_NOCONST | ( | t, | |
| pr | |||
| ) | GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
| #define GWEN_TREE_FUNCTION_LIB_DEFS | ( | t, | |
| pr, | |||
| decl | |||
| ) |
Use this in public header files to define some prototypes for list functions. Let's assume the type of your list elements is "MYTYPE" and you want to use the prefix "MyType_" for the list functions. The following function prototypes will then be created:
| #define GWEN_TREE_FUNCTION_LIB_DEFS_CONST | ( | t, | |
| pr, | |||
| decl | |||
| ) |
Use this macro in your public header files to export only list functions which do not modify a list. This allows your code to return lists which can not be modified by callers. It also prevents callers from creating their own lists (this is sometimes needed).
| #define GWEN_TREE_FUNCTION_LIB_DEFS_NOCONST | ( | t, | |
| pr, | |||
| decl | |||
| ) |
| #define GWEN_TREE_FUNCTIONS | ( | t, | |
| pr | |||
| ) |
Use this inside your code files (*.c). Actually implements the functions for which the prototypes have been defined via GWEN_TREE_FUNCTION_DEFS.
| #define GWEN_TREE_INIT | ( | t, | |
| element | |||
| ) | element->_tree_element=GWEN_TreeElement_new(element); |
| typedef struct GWEN_TREE_ELEMENT GWEN_TREE_ELEMENT |
| GWENHYWFAR_API void GWEN_Tree_Add | ( | GWEN_TREE * | l, |
| GWEN_TREE_ELEMENT * | el | ||
| ) |
Adds (appends) a toplevel tree element. (This operation is also called "append" or "push_back" elsewhere.)
Definition at line 65 of file tree.c.
References DBG_ERROR, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_Tree_AddList().

| GWENHYWFAR_API void GWEN_Tree_AddChild | ( | GWEN_TREE_ELEMENT * | where, |
| GWEN_TREE_ELEMENT * | el | ||
| ) |
Add a child below the given element.
Definition at line 234 of file tree.c.
References DBG_ERROR, and GWEN_LOGDOMAIN.
| GWENHYWFAR_API void GWEN_Tree_AddList | ( | GWEN_TREE * | dest, |
| GWEN_TREE * | l | ||
| ) |
Adds (appends) the second list to the end of the first list. (This operation is also called "append" or "concatenate" elsewhere.) The second list will be empty upon return.
Definition at line 91 of file tree.c.
References GWEN_Tree_Add(), and GWEN_Tree_Del().

| GWENHYWFAR_API void GWEN_Tree_Del | ( | GWEN_TREE_ELEMENT * | el | ) |
Deletes (removes) a tree element from the tree it used to belong to. The tree element is not free'd or anything, it is only removed from the list it used to belong to. (This operation is also called "remove" or "unlink" elsewhere.)
Definition at line 129 of file tree.c.
References DBG_ERROR, GWEN_LOGDOMAIN, and NULL.
Referenced by GWEN_Tree_AddList(), and GWEN_TreeElement_free().

| GWENHYWFAR_API void GWEN_Tree_free | ( | GWEN_TREE * | l | ) |
Free (delete) an existing list. The list elements are untouched by this function; they need to be freed beforehand.
Definition at line 48 of file tree.c.
References GWEN_FREE_OBJECT.
| GWENHYWFAR_API int GWEN_Tree_GetCount | ( | const GWEN_TREE * | l | ) |
| GWENHYWFAR_API void * GWEN_Tree_GetFirst | ( | const GWEN_TREE * | l | ) |
| GWENHYWFAR_API void * GWEN_Tree_GetLast | ( | const GWEN_TREE * | l | ) |
| GWENHYWFAR_API void GWEN_Tree_Insert | ( | GWEN_TREE * | l, |
| GWEN_TREE_ELEMENT * | el | ||
| ) |
Inserts (prepends) a toplevel tree element at the beginning of the list. (This operation is also called "prepend" or "push_front" elsewhere.)
Definition at line 106 of file tree.c.
References DBG_ERROR, GWEN_LOGDOMAIN, and NULL.
| GWENHYWFAR_API void GWEN_Tree_InsertChild | ( | GWEN_TREE_ELEMENT * | where, |
| GWEN_TREE_ELEMENT * | el | ||
| ) |
Insert a child below the given element.
Definition at line 260 of file tree.c.
References DBG_ERROR, GWEN_LOGDOMAIN, and NULL.
| GWENHYWFAR_API GWEN_TREE * GWEN_Tree_new | ( | void | ) |
Allocate (create) a new empty list.
Definition at line 39 of file tree.c.
References GWEN_NEW_OBJECT.
| GWENHYWFAR_API void GWEN_Tree_Replace | ( | GWEN_TREE_ELEMENT * | elToReplace, |
| GWEN_TREE_ELEMENT * | elReplacement | ||
| ) |
Replaces a tree element with another one, so the replacement takes the place of the given element. The given element to replace is unlinked in the process and can be free'd. The replacement MUST NOT be part of any tree.
Definition at line 173 of file tree.c.
References DBG_ERROR, GWEN_LOGDOMAIN, and NULL.
| GWENHYWFAR_API void GWEN_TreeElement_free | ( | GWEN_TREE_ELEMENT * | el | ) |
Free (delete) a list element structure.
Definition at line 316 of file tree.c.
References DBG_ERROR, GWEN_FREE_OBJECT, GWEN_LOGDOMAIN, and GWEN_Tree_Del().

| GWENHYWFAR_API void * GWEN_TreeElement_GetBelow | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API uint32_t GWEN_TreeElement_GetChildrenCount | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API void * GWEN_TreeElement_GetFirstChild | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API void * GWEN_TreeElement_GetLastChild | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API void * GWEN_TreeElement_GetNext | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API void * GWEN_TreeElement_GetParent | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API void * GWEN_TreeElement_GetPrevious | ( | const GWEN_TREE_ELEMENT * | el | ) |
| GWENHYWFAR_API GWEN_TREE_ELEMENT * GWEN_TreeElement_new | ( | void * | d | ) |
Allocate (create) a new list element structure.
Definition at line 304 of file tree.c.
References GWEN_NEW_OBJECT.