|
gwenhywfar 5.14.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 |
Typesafe Macros | |
| #define | GWEN_TREE2_ELEMENT(t) |
| #define | GWEN_TREE2_FINI(t, element, pr) |
| #define | GWEN_TREE2_FUNCTION_DEFS(t, pr) |
| #define | GWEN_TREE2_FUNCTION_DEFS_CONST(t, pr) |
| #define | GWEN_TREE2_FUNCTION_DEFS_NOCONST(t, pr) |
| #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) |
| #define GWEN_DUMMY_EMPTY_ARG |
| #define GWEN_TREE2_ELEMENT | ( | t | ) |
Use this inside the declaration of a struct for which you want to create lists.
Definition at line 251 of file tree2.h.
Referenced by GWEN_Tree2_AddChild(), GWEN_Tree2_GetFirstChild(), GWEN_Tree2_GetLastChild(), GWEN_Tree2_InsertChild(), GWEN_Tree2_Replace(), GWEN_Tree2_Unlink(), GWEN_Tree2Element_free(), GWEN_Tree2Element_GetBelow(), GWEN_Tree2Element_GetChildrenCount(), GWEN_Tree2Element_GetFirstChild(), GWEN_Tree2Element_GetLastChild(), GWEN_Tree2Element_GetNext(), GWEN_Tree2Element_GetParent(), GWEN_Tree2Element_GetPrevious(), and GWEN_Tree2Element_new().
| #define GWEN_TREE2_FINI | ( | t, | |
| element, | |||
| pr ) |
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.
Referenced by GWB_Context_free(), GWEN_JsonElement_free(), GWEN_MsgEndpoint_free(), GWEN_MsgRequest_free(), and GWEN_Test_Module_free().
| #define GWEN_TREE2_FUNCTION_DEFS | ( | t, | |
| pr ) |
This macro should be used in applications, not in libraries. In libraries please use the macro GWEN_TREE2_FUNCTION_LIB_DEFS.
| #define GWEN_TREE2_FUNCTION_DEFS_CONST | ( | t, | |
| pr ) |
| #define GWEN_TREE2_FUNCTION_DEFS_NOCONST | ( | t, | |
| pr ) |
| #define GWEN_TREE2_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_TREE2_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_TREE2_FUNCTION_LIB_DEFS_NOCONST | ( | t, | |
| pr, | |||
| decl ) |
| #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.
| #define GWEN_TREE2_INIT | ( | t, | |
| element, | |||
| pr ) |
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.
Referenced by GWB_Context_dup(), GWB_Context_new(), GWEN_JsonElement_new(), GWEN_MsgEndpoint_new(), GWEN_MsgRequest_new(), and GWEN_Test_Module_new().
| typedef struct GWEN_TREE2_ELEMENT GWEN_TREE2_ELEMENT |
| GWENHYWFAR_API void GWEN_Tree2_AddChild | ( | GWEN_TREE2_ELEMENT * | where, |
| GWEN_TREE2_ELEMENT * | el ) |
Add a child below the given element.
Definition at line 122 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void * GWEN_Tree2_GetFirstChild | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Returns the data pointer of the first list element.
References GWEN_TREE2_ELEMENT, and GWENHYWFAR_API.
| GWENHYWFAR_API void * GWEN_Tree2_GetLastChild | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Returns the data pointer of the last list element.
References GWEN_TREE2_ELEMENT, and GWENHYWFAR_API.
| GWENHYWFAR_API void GWEN_Tree2_InsertChild | ( | GWEN_TREE2_ELEMENT * | where, |
| GWEN_TREE2_ELEMENT * | el ) |
Insert a child below the given element.
Definition at line 137 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void GWEN_Tree2_Replace | ( | GWEN_TREE2_ELEMENT * | elToReplace, |
| GWEN_TREE2_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 90 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void GWEN_Tree2_Unlink | ( | GWEN_TREE2_ELEMENT * | el | ) |
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.)
Definition at line 64 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void GWEN_Tree2Element_free | ( | GWEN_TREE2_ELEMENT * | el | ) |
Free (delete) a list element structure.
Definition at line 51 of file tree2.c.
References DBG_ERROR, GWEN_FREE_OBJECT, GWEN_LOGDOMAIN, and GWEN_TREE2_ELEMENT.
| GWENHYWFAR_API void * GWEN_Tree2Element_GetBelow | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Returns the element which is logically below the given one. The order of search is this:
Definition at line 168 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API uint32_t GWEN_Tree2Element_GetChildrenCount | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Returns the number of children of the given element
References GWEN_TREE2_ELEMENT.
| GWENHYWFAR_API void * GWEN_Tree2Element_GetFirstChild | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Returns the first child of the given element.
Definition at line 189 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void * GWEN_Tree2Element_GetLastChild | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Returns the last child of the given element.
Definition at line 198 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void * GWEN_Tree2Element_GetNext | ( | const GWEN_TREE2_ELEMENT * | el | ) |
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.
Definition at line 159 of file tree2.c.
References GWEN_TREE2_ELEMENT.
| GWENHYWFAR_API void * GWEN_Tree2Element_GetParent | ( | const GWEN_TREE2_ELEMENT * | el | ) |
Definition at line 207 of file tree2.c.
References GWEN_TREE2_ELEMENT, and NULL.
| GWENHYWFAR_API void * GWEN_Tree2Element_GetPrevious | ( | const GWEN_TREE2_ELEMENT * | el | ) |
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.
Definition at line 150 of file tree2.c.
References GWEN_TREE2_ELEMENT.
| GWENHYWFAR_API GWEN_TREE2_ELEMENT * GWEN_Tree2Element_new | ( | void * | d | ) |
Allocate (create) a new list element structure.
Definition at line 39 of file tree2.c.
References GWEN_NEW_OBJECT, and GWEN_TREE2_ELEMENT.