gwenhywfar
5.11.1beta
|
Go to the source code of this file.
Macros | |
#define | GWEN_DUMMY_EMPTY_ARG |
#define | GWEN_LIST1_H |
Typesafe Macros | |
#define | GWEN_LIST_ELEMENT(t) GWEN_LIST1_ELEMENT *_list1_element; |
#define | GWEN_LIST_FINI(t, element) |
#define | GWEN_LIST_FUNCTION_DEFS(t, pr) GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, GWEN_DUMMY_EMPTY_ARG) |
#define | GWEN_LIST_FUNCTION_DEFS_CONST(t, pr) GWEN_LIST_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
#define | GWEN_LIST_FUNCTION_DEFS_NOCONST(t, pr) GWEN_LIST_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
#define | GWEN_LIST_FUNCTION_LIB_DEFS(t, pr, decl) |
#define | GWEN_LIST_FUNCTION_LIB_DEFS_CONST(t, pr, decl) |
#define | GWEN_LIST_FUNCTION_LIB_DEFS_NOCONST(t, pr, decl) |
#define | GWEN_LIST_FUNCTIONS(t, pr) |
#define | GWEN_LIST_INIT(t, element) element->_list1_element=GWEN_List1Element_new(element); |
#define GWEN_DUMMY_EMPTY_ARG |
#define GWEN_LIST_ELEMENT | ( | t | ) | GWEN_LIST1_ELEMENT *_list1_element; |
#define GWEN_LIST_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_LIST_FUNCTION_DEFS | ( | t, | |
pr | |||
) | GWEN_LIST_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_LIST_FUNCTION_LIB_DEFS.
#define GWEN_LIST_FUNCTION_DEFS_CONST | ( | t, | |
pr | |||
) | GWEN_LIST_FUNCTION_LIB_DEFS_CONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
#define GWEN_LIST_FUNCTION_DEFS_NOCONST | ( | t, | |
pr | |||
) | GWEN_LIST_FUNCTION_LIB_DEFS_NOCONST(t, pr, GWEN_DUMMY_EMPTY_ARG) |
#define GWEN_LIST_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_LIST_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_LIST_FUNCTION_LIB_DEFS_NOCONST | ( | t, | |
pr, | |||
decl | |||
) |
#define GWEN_LIST_FUNCTIONS | ( | t, | |
pr | |||
) |
Use this inside your code files (*.c). Actually implements the functions for which the prototypes have been defined via GWEN_LIST_FUNCTION_DEFS.
#define GWEN_LIST_INIT | ( | t, | |
element | |||
) | element->_list1_element=GWEN_List1Element_new(element); |
typedef struct GWEN_LIST1 GWEN_LIST1 |
typedef struct GWEN_LIST1_ELEMENT GWEN_LIST1_ELEMENT |
typedef int GWENHYWFAR_CB(* GWEN_LIST1_SORT_FN) (const void *a, const void *b, int ascending) |
GWENHYWFAR_API int GWEN_List1_Add | ( | GWEN_LIST1 * | l, |
GWEN_LIST1_ELEMENT * | el | ||
) |
Adds (appends) a list element at the end of the list. (This operation is also called "append" or "push_back" elsewhere.)
GWENHYWFAR_API int GWEN_List1_AddList | ( | GWEN_LIST1 * | dest, |
GWEN_LIST1 * | l | ||
) |
Adds (appends) the second list to the end of the first list. (This operation is also called "append" or "concatenate" elsewhere.)
GWENHYWFAR_API int GWEN_List1_Del | ( | GWEN_LIST1_ELEMENT * | el | ) |
Deletes (removes) a list element from the list it used to belong to. The list 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.)
GWENHYWFAR_API void GWEN_List1_free | ( | GWEN_LIST1 * | l | ) |
Free (delete) an existing list. The list elements are untouched by this function; they need to be freed beforehand.
GWENHYWFAR_API int GWEN_List1_GetCount | ( | const GWEN_LIST1 * | l | ) |
Returns the number of elements in this list. This value is cached in the list structure, so this function is a cheap function.
GWENHYWFAR_API void* GWEN_List1_GetFirst | ( | const GWEN_LIST1 * | l | ) |
Returns the data pointer of the first list element.
GWENHYWFAR_API void* GWEN_List1_GetLast | ( | const GWEN_LIST1 * | l | ) |
Returns the data pointer of the last list element.
GWENHYWFAR_API int GWEN_List1_Insert | ( | GWEN_LIST1 * | l, |
GWEN_LIST1_ELEMENT * | el | ||
) |
Inserts (prepends) a list element at the beginning of the list. (This operation is also called "prepend" or "push_front" elsewhere.)
GWENHYWFAR_API GWEN_LIST1* GWEN_List1_new | ( | void | ) |
Allocate (create) a new empty list.
GWENHYWFAR_API GWEN_LIST1_SORT_FN GWEN_List1_SetSortFn | ( | GWEN_LIST1 * | l, |
GWEN_LIST1_SORT_FN | fn | ||
) |
GWENHYWFAR_API void GWEN_List1_Sort | ( | GWEN_LIST1 * | l, |
int | ascending | ||
) |
GWENHYWFAR_API void GWEN_List1Element_free | ( | GWEN_LIST1_ELEMENT * | el | ) |
Free (delete) a list element structure.
GWENHYWFAR_API void* GWEN_List1Element_GetData | ( | const GWEN_LIST1_ELEMENT * | el | ) |
Returns the data pointer of the given list element structure.
GWENHYWFAR_API void* GWEN_List1Element_GetNext | ( | const GWEN_LIST1_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.
GWENHYWFAR_API void* GWEN_List1Element_GetPrevious | ( | const GWEN_LIST1_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.
GWENHYWFAR_API GWEN_LIST1_ELEMENT* GWEN_List1Element_new | ( | void * | d | ) |
Allocate (create) a new list element structure.