Go to the source code of this file.
|
#define | GWEN_DUMMY_EMPTY_ARG |
|
|
#define | GWEN_TREE2_ELEMENT(t) GWEN_TREE2_ELEMENT *_tree2_element; |
|
#define | GWEN_TREE2_FINI(t, element, pr) |
|
#define | GWEN_TREE2_FUNCTION_DEFS(t, pr) GWEN_TREE2_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) |
|
#define | GWEN_TREE2_FUNCTION_DEFS_CONST(t, pr) GWEN_TREE2_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
|
#define | GWEN_TREE2_FUNCTION_DEFS_NOCONST(t, pr) GWEN_TREE2_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
|
#define | GWEN_TREE2_FUNCTION_LIB_DEFS(t, pr, decl) |
|
#define | GWEN_TREE2_FUNCTION_LIB_DEFS_CONST(t, pr, decl) |
|
#define | GWEN_TREE2_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl) |
|
#define | GWEN_TREE2_FUNCTIONS(t, pr) |
|
#define | GWEN_TREE2_INIT(t, element, pr) element->_tree2_element=GWEN_Tree2Element_new(element); |
|
◆ GWEN_DUMMY_EMPTY_ARG
#define GWEN_DUMMY_EMPTY_ARG |
Necessary for MSVC compiler because it does not accept a left-out macro argument.
Definition at line 37 of file tree2.h.
◆ GWEN_TREE2_ELEMENT
Use this inside the declaration of a struct for which you want to create lists.
Definition at line 251 of file tree2.h.
◆ GWEN_TREE2_FINI
#define GWEN_TREE2_FINI |
( |
|
t, |
|
|
|
element, |
|
|
|
pr |
|
) |
| |
Value: if (element && element->_tree2_element) { \
pr##_Tree2_ClearChildren(element);\
pr##_Tree2_Unlink(element);\
GWEN_Tree2Element_free(element->_tree2_element); \
element->_tree2_element=0; \
}
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". t is the base type id (e.g. "AF_ACCOUNT") element is the pointer to the element to fini pr ist the prefix of functions for this type (e.g. "AF_Account")
Definition at line 457 of file tree2.h.
◆ GWEN_TREE2_FUNCTION_DEFS
◆ GWEN_TREE2_FUNCTION_DEFS_CONST
◆ GWEN_TREE2_FUNCTION_DEFS_NOCONST
◆ GWEN_TREE2_FUNCTION_LIB_DEFS
#define GWEN_TREE2_FUNCTION_LIB_DEFS |
( |
|
t, |
|
|
|
pr, |
|
|
|
decl |
|
) |
| |
Value:
GWEN_TREE2_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl)
#define GWEN_TREE2_FUNCTION_LIB_DEFS_CONST(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:
-
void MyType_Tree2_Add(MYTYPE *element, MYTYPE_TREE *list);
Adds (appends) a MYTYPE struct at the end of the given list. (We apologize for the unusual argument order here.)
-
void MyType_Tree2_Unlink(MYTYPE *element);
Removes a MyType struct from the list it is enlisted to.
-
MYTYPE *MyType_Tree2_FirstChild(MYTYPE *element);
Returns the first element of the given list.
-
MYTYPE* MyType_Tree2_Next(const MYTYPE *element);
Returns the next list element to the given one (the successor) in its list.
-
MYTYPE* MyType_Tree2_Previous(const MYTYPE *element);
Returns the previous list element to the given one (the predecessor) in its list.
-
void MyType_Tree2_Clear(MYTYPE *element);
Frees all entries of the given list. This function assumes that there is a function Mytype_free().
-
MYTYPE_TREE *MyType_Tree2_new();
Creates a new list of elements of MYTYPE type.
-
void MyType_Tree2_free(MYTYPE_TREE *l);
Clears and frees a list of elements of MYTYPE type. All objects inside the list are freed.
Definition at line 336 of file tree2.h.
◆ GWEN_TREE2_FUNCTION_LIB_DEFS_CONST
#define GWEN_TREE2_FUNCTION_LIB_DEFS_CONST |
( |
|
t, |
|
|
|
pr, |
|
|
|
decl |
|
) |
| |
Value: decl t* pr##_Tree2_GetNext(const t *element); \
decl t* pr##_Tree2_GetPrevious(const t *element); \
decl t* pr##_Tree2_GetBelow(const t *element); \
decl t* pr##_Tree2_GetFirstChild(const t *element); \
decl t* pr##_Tree2_GetLastChild(const t *element); \
decl t* pr##_Tree2_GetParent(const t *element);
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).
Definition at line 260 of file tree2.h.
◆ GWEN_TREE2_FUNCTION_LIB_DEFS_NOCONST
#define GWEN_TREE2_FUNCTION_LIB_DEFS_NOCONST |
( |
|
t, |
|
|
|
pr, |
|
|
|
decl |
|
) |
| |
Value:
\
decl void pr##_Tree2_Unlink(t *element); \
decl void pr##_Tree2_Replace(t *elToReplace, t *elReplacement); \
\
decl void pr##_Tree2_AddChild(t *where, t *element); \
decl void pr##_Tree2_InsertChild(t *where, t *element); \
\
decl void pr##_Tree2_ClearChildren(t *element); \
decl void pr##_Tree2_free(t *element);
struct GWEN_TREE2_ELEMENT GWEN_TREE2_ELEMENT
Definition at line 269 of file tree2.h.
◆ GWEN_TREE2_FUNCTIONS
#define GWEN_TREE2_FUNCTIONS |
( |
|
t, |
|
|
|
pr |
|
) |
| |
Use this inside your code files (*.c). Actually implements the functions for which the prototypes have been defined via GWEN_TREE2_FUNCTION_DEFS.
Definition at line 354 of file tree2.h.
◆ GWEN_TREE2_INIT
Use this in your code file (*.c) inside the init code for the struct you want to use in lists (in GWEN these are the functions which end with "_new".
Definition at line 445 of file tree2.h.
◆ GWEN_TREE2_ELEMENT
◆ GWEN_Tree2_AddChild()
Add a child below the given element.
◆ GWEN_Tree2_GetFirstChild()
Returns the data pointer of the first list element.
◆ GWEN_Tree2_GetLastChild()
Returns the data pointer of the last list element.
◆ GWEN_Tree2_InsertChild()
Insert a child below the given element.
◆ GWEN_Tree2_Replace()
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.
◆ GWEN_Tree2_Unlink()
Unlinks (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 tree it used to belong to. (This operation is also called "remove" elsewhere.)
◆ GWEN_Tree2Element_free()
Free (delete) a list element structure.
◆ GWEN_Tree2Element_GetBelow()
Returns the element which is logically below the given one. The order of search is this:
-
first child of the given element
-
next neighbour of the given element
-
loop for every parent: check next neighbour of the given element's parent (if any)
◆ GWEN_Tree2Element_GetChildrenCount()
Returns the number of children of the given element
◆ GWEN_Tree2Element_GetFirstChild()
Returns the first child of the given element.
◆ GWEN_Tree2Element_GetLastChild()
Returns the last child of the given element.
◆ GWEN_Tree2Element_GetNext()
Returns the data pointer of the list element that is the next one (successor) to the given one in its list. If there is no such prepending list element, returns NULL.
◆ GWEN_Tree2Element_GetParent()
◆ GWEN_Tree2Element_GetPrevious()
Returns the data pointer of the list element that is the previous (predecessor) to the given one in its list. If there is no such prepending list element, returns NULL.
◆ GWEN_Tree2Element_new()
Allocate (create) a new list element structure.