New upstream version 8.1.0
This commit is contained in:
73
client_module/source/common/toolkit/list/Int64CpyList.h
Normal file
73
client_module/source/common/toolkit/list/Int64CpyList.h
Normal file
@@ -0,0 +1,73 @@
|
||||
#ifndef INT64CPYLIST_H_
|
||||
#define INT64CPYLIST_H_
|
||||
|
||||
#include <common/toolkit/list/PointerList.h>
|
||||
|
||||
/**
|
||||
* We need to copy int64 values (instead of just assigning them to just to the internal pointer)
|
||||
* because we might be running on 32bit archs.
|
||||
*/
|
||||
|
||||
struct Int64CpyList;
|
||||
typedef struct Int64CpyList Int64CpyList;
|
||||
|
||||
static inline void Int64CpyList_init(Int64CpyList* this);
|
||||
static inline void Int64CpyList_uninit(Int64CpyList* this);
|
||||
static inline void Int64CpyList_append(Int64CpyList* this, int64_t value);
|
||||
static inline size_t Int64CpyList_length(Int64CpyList* this);
|
||||
static inline void Int64CpyList_clear(Int64CpyList* this);
|
||||
|
||||
struct Int64CpyList
|
||||
{
|
||||
struct PointerList pointerList;
|
||||
};
|
||||
|
||||
|
||||
void Int64CpyList_init(Int64CpyList* this)
|
||||
{
|
||||
PointerList_init( (PointerList*)this);
|
||||
}
|
||||
|
||||
void Int64CpyList_uninit(Int64CpyList* this)
|
||||
{
|
||||
struct PointerListElem* elem = ( (PointerList*)this)->head;
|
||||
while(elem)
|
||||
{
|
||||
struct PointerListElem* next = elem->next;
|
||||
kfree(elem->valuePointer);
|
||||
elem = next;
|
||||
}
|
||||
|
||||
|
||||
PointerList_uninit( (PointerList*)this);
|
||||
}
|
||||
|
||||
void Int64CpyList_append(Int64CpyList* this, int64_t value)
|
||||
{
|
||||
int64_t* valueCopyPointer = (int64_t*)os_kmalloc(sizeof(int64_t) );
|
||||
|
||||
*valueCopyPointer = value;
|
||||
|
||||
PointerList_append( (PointerList*)this, valueCopyPointer);
|
||||
}
|
||||
|
||||
static inline size_t Int64CpyList_length(Int64CpyList* this)
|
||||
{
|
||||
return PointerList_length( (PointerList*)this);
|
||||
}
|
||||
|
||||
void Int64CpyList_clear(Int64CpyList* this)
|
||||
{
|
||||
struct PointerListElem* elem = ( (PointerList*)this)->head;
|
||||
while(elem)
|
||||
{
|
||||
struct PointerListElem* next = elem->next;
|
||||
kfree(elem->valuePointer);
|
||||
elem = next;
|
||||
}
|
||||
|
||||
PointerList_clear( (PointerList*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*INT64CPYLIST_H_*/
|
||||
43
client_module/source/common/toolkit/list/Int64CpyListIter.h
Normal file
43
client_module/source/common/toolkit/list/Int64CpyListIter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef INT64CPYLISTITER_H_
|
||||
#define INT64CPYLISTITER_H_
|
||||
|
||||
#include "Int64CpyList.h"
|
||||
#include "PointerListIter.h"
|
||||
|
||||
struct Int64CpyListIter;
|
||||
typedef struct Int64CpyListIter Int64CpyListIter;
|
||||
|
||||
static inline void Int64CpyListIter_init(Int64CpyListIter* this, Int64CpyList* list);
|
||||
static inline void Int64CpyListIter_next(Int64CpyListIter* this);
|
||||
static inline int64_t Int64CpyListIter_value(Int64CpyListIter* this);
|
||||
static inline bool Int64CpyListIter_end(Int64CpyListIter* this);
|
||||
|
||||
|
||||
struct Int64CpyListIter
|
||||
{
|
||||
struct PointerListIter pointerListIter;
|
||||
};
|
||||
|
||||
|
||||
void Int64CpyListIter_init(Int64CpyListIter* this, Int64CpyList* list)
|
||||
{
|
||||
PointerListIter_init( (PointerListIter*)this, (PointerList*)list);
|
||||
}
|
||||
|
||||
void Int64CpyListIter_next(Int64CpyListIter* this)
|
||||
{
|
||||
PointerListIter_next( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
int64_t Int64CpyListIter_value(Int64CpyListIter* this)
|
||||
{
|
||||
return *(int64_t*)PointerListIter_value( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
bool Int64CpyListIter_end(Int64CpyListIter* this)
|
||||
{
|
||||
return PointerListIter_end( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*INT64CPYLISTITER_H_*/
|
||||
54
client_module/source/common/toolkit/list/NumNodeIDList.h
Normal file
54
client_module/source/common/toolkit/list/NumNodeIDList.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef NUMNODEIDLIST_H_
|
||||
#define NUMNODEIDLIST_H_
|
||||
|
||||
#include <common/nodes/NumNodeID.h>
|
||||
#include <common/toolkit/list/PointerList.h>
|
||||
|
||||
/**
|
||||
* Derived from PointerList. Internally, we cast NumNodeID values directly to pointers here (instead
|
||||
* of allocating them and assigning the pointer to the allocated mem here).
|
||||
*/
|
||||
|
||||
struct NumNodeIDList;
|
||||
typedef struct NumNodeIDList NumNodeIDList;
|
||||
|
||||
static inline void NumNodeIDList_init(NumNodeIDList* this);
|
||||
static inline void NumNodeIDList_uninit(NumNodeIDList* this);
|
||||
static inline void NumNodeIDList_append(NumNodeIDList* this, NumNodeID value);
|
||||
static inline size_t NumNodeIDList_length(NumNodeIDList* this);
|
||||
static inline void NumNodeIDList_clear(NumNodeIDList* this);
|
||||
|
||||
struct NumNodeIDList
|
||||
{
|
||||
struct PointerList pointerList;
|
||||
};
|
||||
|
||||
|
||||
void NumNodeIDList_init(NumNodeIDList* this)
|
||||
{
|
||||
PointerList_init( (PointerList*)this);
|
||||
}
|
||||
|
||||
void NumNodeIDList_uninit(NumNodeIDList* this)
|
||||
{
|
||||
PointerList_uninit( (PointerList*)this);
|
||||
}
|
||||
|
||||
void NumNodeIDList_append(NumNodeIDList* this, NumNodeID value)
|
||||
{
|
||||
/* cast value directly to pointer type here to store value directly in the pointer variable
|
||||
without allocating extra mem */
|
||||
PointerList_append( (PointerList*)this, (void*)(size_t)value.value);
|
||||
}
|
||||
|
||||
static inline size_t NumNodeIDList_length(NumNodeIDList* this)
|
||||
{
|
||||
return PointerList_length( (PointerList*)this);
|
||||
}
|
||||
|
||||
void NumNodeIDList_clear(NumNodeIDList* this)
|
||||
{
|
||||
PointerList_clear( (PointerList*)this);
|
||||
}
|
||||
|
||||
#endif /* NUMNODEIDLIST_H_ */
|
||||
43
client_module/source/common/toolkit/list/NumNodeIDListIter.h
Normal file
43
client_module/source/common/toolkit/list/NumNodeIDListIter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef NUMNODEIDLISTITER_H_
|
||||
#define NUMNODEIDLISTITER_H_
|
||||
|
||||
#include <common/toolkit/list/PointerListIter.h>
|
||||
#include "NumNodeIDList.h"
|
||||
|
||||
struct NumNodeIDListIter;
|
||||
typedef struct NumNodeIDListIter NumNodeIDListIter;
|
||||
|
||||
static inline void NumNodeIDListIter_init(NumNodeIDListIter* this, NumNodeIDList* list);
|
||||
static inline void NumNodeIDListIter_next(NumNodeIDListIter* this);
|
||||
static inline NumNodeID NumNodeIDListIter_value(NumNodeIDListIter* this);
|
||||
static inline bool NumNodeIDListIter_end(NumNodeIDListIter* this);
|
||||
|
||||
|
||||
struct NumNodeIDListIter
|
||||
{
|
||||
struct PointerListIter pointerListIter;
|
||||
};
|
||||
|
||||
|
||||
void NumNodeIDListIter_init(NumNodeIDListIter* this, NumNodeIDList* list)
|
||||
{
|
||||
PointerListIter_init( (PointerListIter*)this, (PointerList*)list);
|
||||
}
|
||||
|
||||
void NumNodeIDListIter_next(NumNodeIDListIter* this)
|
||||
{
|
||||
PointerListIter_next( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
NumNodeID NumNodeIDListIter_value(NumNodeIDListIter* this)
|
||||
{
|
||||
return (NumNodeID){(size_t)PointerListIter_value( (PointerListIter*)this)};
|
||||
}
|
||||
|
||||
bool NumNodeIDListIter_end(NumNodeIDListIter* this)
|
||||
{
|
||||
return PointerListIter_end( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /* NUMNODEIDLISTITER_H_ */
|
||||
267
client_module/source/common/toolkit/list/PointerList.h
Normal file
267
client_module/source/common/toolkit/list/PointerList.h
Normal file
@@ -0,0 +1,267 @@
|
||||
#ifndef POINTERLIST_H_
|
||||
#define POINTERLIST_H_
|
||||
|
||||
#include <common/Common.h>
|
||||
|
||||
struct PointerListElem;
|
||||
typedef struct PointerListElem PointerListElem;
|
||||
struct PointerList;
|
||||
typedef struct PointerList PointerList;
|
||||
|
||||
static inline void PointerList_init(PointerList* this);
|
||||
static inline void PointerList_uninit(PointerList* this);
|
||||
|
||||
static inline void PointerList_addHead(PointerList* this, void* valuePointer);
|
||||
static inline void PointerList_addTail(PointerList* this, void* valuePointer);
|
||||
static inline void PointerList_append(PointerList* this, void* valuePointer);
|
||||
static inline void PointerList_removeHead(PointerList* this);
|
||||
static inline void PointerList_removeTail(PointerList* this);
|
||||
static inline void PointerList_removeElem(PointerList* this, PointerListElem* elem);
|
||||
static inline void PointerList_moveToHead(PointerList* this, PointerListElem* elem);
|
||||
static inline void PointerList_moveToTail(PointerList* this, PointerListElem* elem);
|
||||
static inline size_t PointerList_length(const PointerList* this);
|
||||
static inline void PointerList_clear(PointerList* this);
|
||||
|
||||
static inline PointerListElem* PointerList_getTail(PointerList* this);
|
||||
static inline PointerListElem* PointerList_getHead(PointerList* this);
|
||||
|
||||
|
||||
struct PointerListElem
|
||||
{
|
||||
void* valuePointer;
|
||||
|
||||
struct PointerListElem* prev;
|
||||
struct PointerListElem* next;
|
||||
};
|
||||
|
||||
struct PointerList
|
||||
{
|
||||
struct PointerListElem* head;
|
||||
struct PointerListElem* tail;
|
||||
|
||||
size_t length;
|
||||
};
|
||||
|
||||
void PointerList_init(PointerList* this)
|
||||
{
|
||||
this->head = NULL;
|
||||
this->tail = NULL;
|
||||
|
||||
this->length = 0;
|
||||
}
|
||||
|
||||
void PointerList_uninit(PointerList* this)
|
||||
{
|
||||
PointerList_clear(this);
|
||||
}
|
||||
|
||||
static inline void __PointerList_addHead(PointerList* this, PointerListElem* elem)
|
||||
{
|
||||
if(this->length)
|
||||
{ // elements exist => replace head
|
||||
elem->next = this->head;
|
||||
this->head->prev = elem;
|
||||
this->head = elem;
|
||||
}
|
||||
else
|
||||
{ // no elements exist yet
|
||||
this->head = elem;
|
||||
this->tail = elem;
|
||||
|
||||
elem->next = NULL;
|
||||
}
|
||||
|
||||
elem->prev = NULL;
|
||||
this->length++;
|
||||
}
|
||||
|
||||
void PointerList_addHead(PointerList* this, void* valuePointer)
|
||||
{
|
||||
PointerListElem* elem = (PointerListElem*)os_kmalloc(
|
||||
sizeof(PointerListElem) );
|
||||
elem->valuePointer = valuePointer;
|
||||
__PointerList_addHead(this, elem);
|
||||
}
|
||||
|
||||
static inline void __PointerList_addTail(PointerList* this, PointerListElem* elem)
|
||||
{
|
||||
if(this->length)
|
||||
{ // elements exist => replace tail
|
||||
elem->prev = this->tail;
|
||||
this->tail->next = elem;
|
||||
this->tail = elem;
|
||||
}
|
||||
else
|
||||
{ // no elements exist yet
|
||||
this->head = elem;
|
||||
this->tail = elem;
|
||||
|
||||
elem->prev = NULL;
|
||||
}
|
||||
|
||||
elem->next = NULL;
|
||||
this->length++;
|
||||
}
|
||||
|
||||
void PointerList_addTail(PointerList* this, void* valuePointer)
|
||||
{
|
||||
PointerListElem* elem = (PointerListElem*)os_kmalloc(sizeof(PointerListElem) );
|
||||
elem->valuePointer = valuePointer;
|
||||
__PointerList_addTail(this, elem);
|
||||
}
|
||||
|
||||
void PointerList_append(PointerList* this, void* valuePointer)
|
||||
{
|
||||
PointerList_addTail(this, valuePointer);
|
||||
}
|
||||
|
||||
static inline void __PointerList_removeHead(PointerList* this, bool freeElem)
|
||||
{
|
||||
#ifdef BEEGFS_DEBUG
|
||||
if(!this->length)
|
||||
{
|
||||
BEEGFS_BUG_ON(true, "Attempt to remove head from empty list");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(this->length == 1)
|
||||
{ // removing the last element
|
||||
if (freeElem)
|
||||
kfree(this->head);
|
||||
this->head = NULL;
|
||||
this->tail = NULL;
|
||||
this->length = 0;
|
||||
}
|
||||
else
|
||||
{ // there are more elements in the list
|
||||
PointerListElem* newHead = this->head->next;
|
||||
|
||||
if (freeElem)
|
||||
kfree(this->head);
|
||||
|
||||
this->head = newHead;
|
||||
this->head->prev = NULL;
|
||||
|
||||
this->length--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PointerList_removeHead(PointerList* this)
|
||||
{
|
||||
__PointerList_removeHead(this, true);
|
||||
}
|
||||
|
||||
static inline void __PointerList_removeTail(PointerList* this, bool freeElem)
|
||||
{
|
||||
#ifdef BEEGFS_DEBUG
|
||||
if(!this->length)
|
||||
{
|
||||
BEEGFS_BUG_ON(true, "Attempt to remove tail from empty list");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if(this->length == 1)
|
||||
{ // removing the last element
|
||||
if (freeElem)
|
||||
kfree(this->tail);
|
||||
this->head = NULL;
|
||||
this->tail = NULL;
|
||||
this->length = 0;
|
||||
}
|
||||
else
|
||||
{ // there are more elements in the list
|
||||
PointerListElem* newTail = this->tail->prev;
|
||||
|
||||
if (freeElem)
|
||||
kfree(this->tail);
|
||||
|
||||
this->tail = newTail;
|
||||
this->tail->next = NULL;
|
||||
|
||||
this->length--;
|
||||
}
|
||||
}
|
||||
|
||||
void PointerList_removeTail(PointerList* this)
|
||||
{
|
||||
__PointerList_removeTail(this, true);
|
||||
}
|
||||
|
||||
static inline void __PointerList_removeElem(PointerList* this, PointerListElem* elem, bool freeElem)
|
||||
{
|
||||
if(elem == this->head)
|
||||
__PointerList_removeHead(this, freeElem);
|
||||
else
|
||||
if(elem == this->tail)
|
||||
__PointerList_removeTail(this, freeElem);
|
||||
else
|
||||
{
|
||||
// not head and not tail, so this elem is somewhere in the middle
|
||||
|
||||
PointerListElem* prev = elem->prev;
|
||||
PointerListElem* next = elem->next;
|
||||
|
||||
prev->next = next;
|
||||
next->prev = prev;
|
||||
|
||||
if (freeElem)
|
||||
kfree(elem);
|
||||
|
||||
this->length--;
|
||||
}
|
||||
}
|
||||
|
||||
void PointerList_removeElem(PointerList* this, PointerListElem* elem)
|
||||
{
|
||||
__PointerList_removeElem(this, elem, true);
|
||||
}
|
||||
|
||||
size_t PointerList_length(const PointerList* this)
|
||||
{
|
||||
return this->length;
|
||||
}
|
||||
|
||||
void PointerList_clear(PointerList* this)
|
||||
{
|
||||
// free all elems
|
||||
PointerListElem* elem = this->head;
|
||||
while(elem)
|
||||
{
|
||||
PointerListElem* next = elem->next;
|
||||
kfree(elem);
|
||||
elem = next;
|
||||
}
|
||||
|
||||
// reset attributes
|
||||
this->head = NULL;
|
||||
this->tail = NULL;
|
||||
|
||||
this->length = 0;
|
||||
}
|
||||
|
||||
PointerListElem* PointerList_getTail(PointerList* this)
|
||||
{
|
||||
return this->tail;
|
||||
}
|
||||
|
||||
PointerListElem* PointerList_getHead(PointerList* this)
|
||||
{
|
||||
return this->head;
|
||||
}
|
||||
|
||||
void PointerList_moveToHead(PointerList* this, PointerListElem *elem)
|
||||
{
|
||||
__PointerList_removeElem(this, elem, false);
|
||||
__PointerList_addHead(this, elem);
|
||||
}
|
||||
|
||||
void PointerList_moveToTail(PointerList* this, PointerListElem *elem)
|
||||
{
|
||||
__PointerList_removeElem(this, elem, false);
|
||||
__PointerList_addTail(this, elem);
|
||||
}
|
||||
|
||||
#endif /*POINTERLIST_H_*/
|
||||
62
client_module/source/common/toolkit/list/PointerListIter.h
Normal file
62
client_module/source/common/toolkit/list/PointerListIter.h
Normal file
@@ -0,0 +1,62 @@
|
||||
#ifndef POINTERLISTITER_H_
|
||||
#define POINTERLISTITER_H_
|
||||
|
||||
#include "PointerList.h"
|
||||
|
||||
struct PointerListIter;
|
||||
typedef struct PointerListIter PointerListIter;
|
||||
|
||||
static inline void PointerListIter_init(PointerListIter* this, PointerList* list);
|
||||
static inline void PointerListIter_next(PointerListIter* this);
|
||||
static inline void* PointerListIter_value(PointerListIter* this);
|
||||
static inline bool PointerListIter_end(PointerListIter* this);
|
||||
static inline PointerListIter PointerListIter_remove(PointerListIter* this);
|
||||
|
||||
struct PointerListIter
|
||||
{
|
||||
PointerList* list;
|
||||
PointerListElem* elem;
|
||||
};
|
||||
|
||||
void PointerListIter_init(PointerListIter* this, PointerList* list)
|
||||
{
|
||||
this->list = list;
|
||||
this->elem = list->head;
|
||||
}
|
||||
|
||||
void PointerListIter_next(PointerListIter* this)
|
||||
{
|
||||
// note: must not return the value because the current elem could be the end of the list
|
||||
|
||||
this->elem = this->elem->next;
|
||||
}
|
||||
|
||||
void* PointerListIter_value(PointerListIter* this)
|
||||
{
|
||||
return this->elem->valuePointer;
|
||||
}
|
||||
|
||||
bool PointerListIter_end(PointerListIter* this)
|
||||
{
|
||||
return (this->elem == NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* note: the current iterator becomes invalid after the call (use the returned iterator)
|
||||
* @return the new iterator that points to the element just behind the erased one
|
||||
*/
|
||||
PointerListIter PointerListIter_remove(PointerListIter* this)
|
||||
{
|
||||
PointerListIter newIter = *this;
|
||||
|
||||
PointerListElem* elem = this->elem;
|
||||
|
||||
PointerListIter_next(&newIter);
|
||||
|
||||
PointerList_removeElem(this->list, elem);
|
||||
|
||||
return newIter;
|
||||
}
|
||||
|
||||
|
||||
#endif /*POINTERLISTITER_H_*/
|
||||
77
client_module/source/common/toolkit/list/StrCpyList.h
Normal file
77
client_module/source/common/toolkit/list/StrCpyList.h
Normal file
@@ -0,0 +1,77 @@
|
||||
#ifndef STRCPYLIST_H_
|
||||
#define STRCPYLIST_H_
|
||||
|
||||
#include "StringList.h"
|
||||
|
||||
struct StrCpyList;
|
||||
typedef struct StrCpyList StrCpyList;
|
||||
|
||||
static inline void StrCpyList_init(StrCpyList* this);
|
||||
static inline void StrCpyList_uninit(StrCpyList* this);
|
||||
static inline void StrCpyList_addHead(StrCpyList* this, const char* valuePointer);
|
||||
static inline void StrCpyList_append(StrCpyList* this, const char* valuePointer);
|
||||
static inline size_t StrCpyList_length(StrCpyList* this);
|
||||
static inline void StrCpyList_clear(StrCpyList* this);
|
||||
|
||||
struct StrCpyList
|
||||
{
|
||||
struct StringList stringList;
|
||||
};
|
||||
|
||||
|
||||
void StrCpyList_init(StrCpyList* this)
|
||||
{
|
||||
StringList_init( (StringList*)this);
|
||||
}
|
||||
|
||||
void StrCpyList_uninit(StrCpyList* this)
|
||||
{
|
||||
struct PointerListElem* elem = ( (PointerList*)this)->head;
|
||||
while(elem)
|
||||
{
|
||||
struct PointerListElem* next = elem->next;
|
||||
kfree(elem->valuePointer);
|
||||
elem = next;
|
||||
}
|
||||
|
||||
|
||||
StringList_uninit( (StringList*)this);
|
||||
}
|
||||
|
||||
void StrCpyList_addHead(StrCpyList* this, const char* valuePointer)
|
||||
{
|
||||
size_t valueLen = strlen(valuePointer)+1;
|
||||
char* valueCopy = (char*)os_kmalloc(valueLen);
|
||||
memcpy(valueCopy, valuePointer, valueLen);
|
||||
|
||||
StringList_addHead( (StringList*)this, valueCopy);
|
||||
}
|
||||
|
||||
void StrCpyList_append(StrCpyList* this, const char* valuePointer)
|
||||
{
|
||||
size_t valueLen = strlen(valuePointer)+1;
|
||||
char* valueCopy = (char*)os_kmalloc(valueLen);
|
||||
memcpy(valueCopy, valuePointer, valueLen);
|
||||
|
||||
StringList_append( (StringList*)this, valueCopy);
|
||||
}
|
||||
|
||||
size_t StrCpyList_length(StrCpyList* this)
|
||||
{
|
||||
return StringList_length( (StringList*)this);
|
||||
}
|
||||
|
||||
void StrCpyList_clear(StrCpyList* this)
|
||||
{
|
||||
struct PointerListElem* elem = ( (PointerList*)this)->head;
|
||||
while(elem)
|
||||
{
|
||||
struct PointerListElem* next = elem->next;
|
||||
kfree(elem->valuePointer);
|
||||
elem = next;
|
||||
}
|
||||
|
||||
StringList_clear( (StringList*)this);
|
||||
}
|
||||
|
||||
#endif /*STRCPYLIST_H_*/
|
||||
43
client_module/source/common/toolkit/list/StrCpyListIter.h
Normal file
43
client_module/source/common/toolkit/list/StrCpyListIter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef STRCPYLISTITER_H_
|
||||
#define STRCPYLISTITER_H_
|
||||
|
||||
#include "StrCpyList.h"
|
||||
#include "StringListIter.h"
|
||||
|
||||
struct StrCpyListIter;
|
||||
typedef struct StrCpyListIter StrCpyListIter;
|
||||
|
||||
static inline void StrCpyListIter_init(StrCpyListIter* this, StrCpyList* list);
|
||||
static inline void StrCpyListIter_next(StrCpyListIter* this);
|
||||
static inline char* StrCpyListIter_value(StrCpyListIter* this);
|
||||
static inline bool StrCpyListIter_end(StrCpyListIter* this);
|
||||
|
||||
|
||||
struct StrCpyListIter
|
||||
{
|
||||
struct StringListIter stringListIter;
|
||||
};
|
||||
|
||||
|
||||
void StrCpyListIter_init(StrCpyListIter* this, StrCpyList* list)
|
||||
{
|
||||
StringListIter_init( (StringListIter*)this, (StringList*)list);
|
||||
}
|
||||
|
||||
void StrCpyListIter_next(StrCpyListIter* this)
|
||||
{
|
||||
StringListIter_next( (StringListIter*)this);
|
||||
}
|
||||
|
||||
char* StrCpyListIter_value(StrCpyListIter* this)
|
||||
{
|
||||
return (char*)StringListIter_value( (StringListIter*)this);
|
||||
}
|
||||
|
||||
bool StrCpyListIter_end(StrCpyListIter* this)
|
||||
{
|
||||
return StringListIter_end( (StringListIter*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*STRCPYLISTITER_H_*/
|
||||
52
client_module/source/common/toolkit/list/StringList.h
Normal file
52
client_module/source/common/toolkit/list/StringList.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef STRINGLIST_H_
|
||||
#define STRINGLIST_H_
|
||||
|
||||
#include "PointerList.h"
|
||||
|
||||
struct StringList;
|
||||
typedef struct StringList StringList;
|
||||
|
||||
static inline void StringList_init(StringList* this);
|
||||
static inline void StringList_uninit(StringList* this);
|
||||
static inline void StringList_addHead(StringList* this, char* valuePointer);
|
||||
static inline void StringList_append(StringList* this, char* valuePointer);
|
||||
static inline size_t StringList_length(StringList* this);
|
||||
static inline void StringList_clear(StringList* this);
|
||||
|
||||
struct StringList
|
||||
{
|
||||
PointerList pointerList;
|
||||
};
|
||||
|
||||
|
||||
void StringList_init(StringList* this)
|
||||
{
|
||||
PointerList_init( (PointerList*)this);
|
||||
}
|
||||
|
||||
void StringList_uninit(StringList* this)
|
||||
{
|
||||
PointerList_uninit( (PointerList*)this);
|
||||
}
|
||||
|
||||
void StringList_addHead(StringList* this, char* valuePointer)
|
||||
{
|
||||
PointerList_addHead( (PointerList*)this, valuePointer);
|
||||
}
|
||||
|
||||
void StringList_append(StringList* this, char* valuePointer)
|
||||
{
|
||||
PointerList_append( (PointerList*)this, valuePointer);
|
||||
}
|
||||
|
||||
size_t StringList_length(StringList* this)
|
||||
{
|
||||
return PointerList_length( (PointerList*)this);
|
||||
}
|
||||
|
||||
void StringList_clear(StringList* this)
|
||||
{
|
||||
PointerList_clear( (PointerList*)this);
|
||||
}
|
||||
|
||||
#endif /*STRINGLIST_H_*/
|
||||
43
client_module/source/common/toolkit/list/StringListIter.h
Normal file
43
client_module/source/common/toolkit/list/StringListIter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef STRINGLISTITER_H_
|
||||
#define STRINGLISTITER_H_
|
||||
|
||||
#include "StringList.h"
|
||||
#include "PointerListIter.h"
|
||||
|
||||
struct StringListIter;
|
||||
typedef struct StringListIter StringListIter;
|
||||
|
||||
static inline void StringListIter_init(StringListIter* this, StringList* list);
|
||||
static inline void StringListIter_next(StringListIter* this);
|
||||
static inline char* StringListIter_value(StringListIter* this);
|
||||
static inline bool StringListIter_end(StringListIter* this);
|
||||
|
||||
|
||||
struct StringListIter
|
||||
{
|
||||
PointerListIter pointerListIter;
|
||||
};
|
||||
|
||||
|
||||
void StringListIter_init(StringListIter* this, StringList* list)
|
||||
{
|
||||
PointerListIter_init( (PointerListIter*)this, (PointerList*)list);
|
||||
}
|
||||
|
||||
void StringListIter_next(StringListIter* this)
|
||||
{
|
||||
PointerListIter_next( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
char* StringListIter_value(StringListIter* this)
|
||||
{
|
||||
return (char*)PointerListIter_value( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
bool StringListIter_end(StringListIter* this)
|
||||
{
|
||||
return PointerListIter_end( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /*STRINGLISTITER_H_*/
|
||||
53
client_module/source/common/toolkit/list/UInt16List.h
Normal file
53
client_module/source/common/toolkit/list/UInt16List.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef UINT16LIST_H_
|
||||
#define UINT16LIST_H_
|
||||
|
||||
#include <common/toolkit/list/PointerList.h>
|
||||
|
||||
/**
|
||||
* Derived from PointerList. Internally, we cast uint16_t values directly to pointers here (instead
|
||||
* of allocating them and assigning the pointer to the allocated mem here).
|
||||
*/
|
||||
|
||||
struct UInt16List;
|
||||
typedef struct UInt16List UInt16List;
|
||||
|
||||
static inline void UInt16List_init(UInt16List* this);
|
||||
static inline void UInt16List_uninit(UInt16List* this);
|
||||
static inline void UInt16List_append(UInt16List* this, uint16_t value);
|
||||
static inline size_t UInt16List_length(UInt16List* this);
|
||||
static inline void UInt16List_clear(UInt16List* this);
|
||||
|
||||
struct UInt16List
|
||||
{
|
||||
struct PointerList pointerList;
|
||||
};
|
||||
|
||||
|
||||
void UInt16List_init(UInt16List* this)
|
||||
{
|
||||
PointerList_init( (PointerList*)this);
|
||||
}
|
||||
|
||||
void UInt16List_uninit(UInt16List* this)
|
||||
{
|
||||
PointerList_uninit( (PointerList*)this);
|
||||
}
|
||||
|
||||
void UInt16List_append(UInt16List* this, uint16_t value)
|
||||
{
|
||||
/* cast value directly to pointer type here to store value directly in the pointer variable
|
||||
without allocating extra mem */
|
||||
PointerList_append( (PointerList*)this, (void*)(size_t)value);
|
||||
}
|
||||
|
||||
static inline size_t UInt16List_length(UInt16List* this)
|
||||
{
|
||||
return PointerList_length( (PointerList*)this);
|
||||
}
|
||||
|
||||
void UInt16List_clear(UInt16List* this)
|
||||
{
|
||||
PointerList_clear( (PointerList*)this);
|
||||
}
|
||||
|
||||
#endif /* UINT16LIST_H_ */
|
||||
43
client_module/source/common/toolkit/list/UInt16ListIter.h
Normal file
43
client_module/source/common/toolkit/list/UInt16ListIter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef UINT16LISTITER_H_
|
||||
#define UINT16LISTITER_H_
|
||||
|
||||
#include <common/toolkit/list/PointerListIter.h>
|
||||
#include "UInt16List.h"
|
||||
|
||||
struct UInt16ListIter;
|
||||
typedef struct UInt16ListIter UInt16ListIter;
|
||||
|
||||
static inline void UInt16ListIter_init(UInt16ListIter* this, UInt16List* list);
|
||||
static inline void UInt16ListIter_next(UInt16ListIter* this);
|
||||
static inline uint16_t UInt16ListIter_value(UInt16ListIter* this);
|
||||
static inline bool UInt16ListIter_end(UInt16ListIter* this);
|
||||
|
||||
|
||||
struct UInt16ListIter
|
||||
{
|
||||
struct PointerListIter pointerListIter;
|
||||
};
|
||||
|
||||
|
||||
void UInt16ListIter_init(UInt16ListIter* this, UInt16List* list)
|
||||
{
|
||||
PointerListIter_init( (PointerListIter*)this, (PointerList*)list);
|
||||
}
|
||||
|
||||
void UInt16ListIter_next(UInt16ListIter* this)
|
||||
{
|
||||
PointerListIter_next( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
uint16_t UInt16ListIter_value(UInt16ListIter* this)
|
||||
{
|
||||
return (uint16_t)(size_t)PointerListIter_value( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
bool UInt16ListIter_end(UInt16ListIter* this)
|
||||
{
|
||||
return PointerListIter_end( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /* UINT16LISTITER_H_ */
|
||||
53
client_module/source/common/toolkit/list/UInt8List.h
Normal file
53
client_module/source/common/toolkit/list/UInt8List.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef UINT8LIST_H_
|
||||
#define UINT8LIST_H_
|
||||
|
||||
#include <common/toolkit/list/PointerList.h>
|
||||
|
||||
/**
|
||||
* Derived from PointerList. Internally, we cast uint8_t values directly to pointers here (instead
|
||||
* of allocating them and assigning the pointer to the allocated mem here).
|
||||
*/
|
||||
|
||||
struct UInt8List;
|
||||
typedef struct UInt8List UInt8List;
|
||||
|
||||
static inline void UInt8List_init(UInt8List* this);
|
||||
static inline void UInt8List_uninit(UInt8List* this);
|
||||
static inline void UInt8List_append(UInt8List* this, uint8_t value);
|
||||
static inline size_t UInt8List_length(UInt8List* this);
|
||||
static inline void UInt8List_clear(UInt8List* this);
|
||||
|
||||
struct UInt8List
|
||||
{
|
||||
struct PointerList pointerList;
|
||||
};
|
||||
|
||||
|
||||
void UInt8List_init(UInt8List* this)
|
||||
{
|
||||
PointerList_init( (PointerList*)this);
|
||||
}
|
||||
|
||||
void UInt8List_uninit(UInt8List* this)
|
||||
{
|
||||
PointerList_uninit( (PointerList*)this);
|
||||
}
|
||||
|
||||
void UInt8List_append(UInt8List* this, uint8_t value)
|
||||
{
|
||||
/* cast value directly to pointer type here to store value directly in the pointer variable
|
||||
without allocating extra mem */
|
||||
PointerList_append( (PointerList*)this, (void*)(size_t)value);
|
||||
}
|
||||
|
||||
static inline size_t UInt8List_length(UInt8List* this)
|
||||
{
|
||||
return PointerList_length( (PointerList*)this);
|
||||
}
|
||||
|
||||
void UInt8List_clear(UInt8List* this)
|
||||
{
|
||||
PointerList_clear( (PointerList*)this);
|
||||
}
|
||||
|
||||
#endif /* UINT8LIST_H_ */
|
||||
43
client_module/source/common/toolkit/list/UInt8ListIter.h
Normal file
43
client_module/source/common/toolkit/list/UInt8ListIter.h
Normal file
@@ -0,0 +1,43 @@
|
||||
#ifndef UINT8LISTITER_H_
|
||||
#define UINT8LISTITER_H_
|
||||
|
||||
#include <common/toolkit/list/PointerListIter.h>
|
||||
#include "UInt8List.h"
|
||||
|
||||
struct UInt8ListIter;
|
||||
typedef struct UInt8ListIter UInt8ListIter;
|
||||
|
||||
static inline void UInt8ListIter_init(UInt8ListIter* this, UInt8List* list);
|
||||
static inline void UInt8ListIter_next(UInt8ListIter* this);
|
||||
static inline uint8_t UInt8ListIter_value(UInt8ListIter* this);
|
||||
static inline bool UInt8ListIter_end(UInt8ListIter* this);
|
||||
|
||||
|
||||
struct UInt8ListIter
|
||||
{
|
||||
struct PointerListIter pointerListIter;
|
||||
};
|
||||
|
||||
|
||||
void UInt8ListIter_init(UInt8ListIter* this, UInt8List* list)
|
||||
{
|
||||
PointerListIter_init( (PointerListIter*)this, (PointerList*)list);
|
||||
}
|
||||
|
||||
void UInt8ListIter_next(UInt8ListIter* this)
|
||||
{
|
||||
PointerListIter_next( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
uint8_t UInt8ListIter_value(UInt8ListIter* this)
|
||||
{
|
||||
return (uint8_t)(size_t)PointerListIter_value( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
bool UInt8ListIter_end(UInt8ListIter* this)
|
||||
{
|
||||
return PointerListIter_end( (PointerListIter*)this);
|
||||
}
|
||||
|
||||
|
||||
#endif /* UINT8LISTITER_H_ */
|
||||
Reference in New Issue
Block a user