2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25#ifndef GIMBAL_STRING_LIST_H
26#define GIMBAL_STRING_LIST_H
28#include "../containers/gimbal_ring_list.h"
34#define GBL_SELF_TYPE GblStringList
39
40
41
42
43
44
45
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
83
84
85
127
128
129
160
161
162
178
179
180
206
207
208
221
222
223
242 const char** ppStrArray,
263 const char** ppStrArray,
298 const char** ppStrArray,
303
304
305
330
331
332
354 const char* pSeparator,
365 GblStringListIterFn pFnIt,
372#define GblStringList_create(...)
373 (GblStringList_create
)(__VA_ARGS__, GBL_NULL)
375#define GblStringList_createWithRefs(...)
376 (GblStringList_createWithRefs
)(__VA_ARGS__, GBL_NULL)
378#define GblStringList_createWithViews(first, ...)
379 ((GblStringList_createWithViews
)(first, __VA_ARGS__, NULL
))
381#define GblStringList_createSplit(...)
382 GblStringList_createSplitDefault_
(__VA_ARGS__)
383#define GblStringList_createSplitDefault_(...)
384 GblStringList_createSplitDefault__
(__VA_ARGS__, 0
, 0
)
385#define GblStringList_createSplitDefault__(str, del, strLen, delLen, ...)
386 ((GblStringList_createSplit
)(str, del, strLen, delLen))
388#define GblStringList_createWithArray(...)
389 GblStringList_createWithArrayDefault_
(__VA_ARGS__)
390#define GblStringList_createWithArrayDefault_(...)
392#define GblStringList_createWithArrayDefault__(array, len, ...)
393 (GblStringList_createWithArray
)(array, len)
395#define GblStringList_createCopy(...)
397#define GblStringList_createCopyDefault_1(src)
398 GblStringList_createCopyDefault_2
(src, 0
)
399#define GblStringList_createCopyDefault_2(src, index)
401#define GblStringList_createCopyDefault_3(src, index, count)
402 ((GblStringList_createCopy
)(src, index, count))
404#define GblStringList_pushBack(...)
405 (GblStringList_pushBack
)(__VA_ARGS__, GBL_NULL)
407#define GblStringList_pushBackRefs(...)
408 (GblStringList_pushBackRefs
)(__VA_ARGS__, GBL_NULL)
410#define GblStringList_pushBackViews(...)
411 (GblStringList_pushBackViews
)(__VA_ARGS__, GBL_NULL)
413#define GblStringList_pushBackArray(...)
414 GblStringList_pushBackArrayDefault_
(__VA_ARGS__)
415#define GblStringList_pushBackArrayDefault_(...)
417#define GblStringList_pushBackArrayDefault__(list, array, size, ...)
418 ((GblStringList_pushBackArray
)(list, array, size))
420#define GblStringList_pushFront(...)
421 (GblStringList_pushFront
)(__VA_ARGS__, GBL_NULL)
423#define GblStringList_pushFrontRefs(...)
424 (GblStringList_pushFrontRefs
)(__VA_ARGS__, GBL_NULL)
426#define GblStringList_pushFrontViews(...)
427 (GblStringList_pushFrontViews
)(__VA_ARGS__, GBL_NULL)
429#define GblStringList_pushFrontArray(...)
430 GblStringList_pushFrontArrayDefault_
(__VA_ARGS__)
431#define GblStringList_pushFrontArrayDefault_(...)
433#define GblStringList_pushFrontArrayDefault__(list, array, size, ...)
434 ((GblStringList_pushFrontArray
(list, array, size)))
436#define GblStringList_insert(...)
437 (GblStringList_insert
)(__VA_ARGS__, GBL_NULL)
439#define GblStringList_insertRefs(...)
440 (GblStringList_insertRefs
)(__VA_ARGS__, GBL_NULL)
442#define GblStringList_insertViews(...)
443 (GblStringList_insertViews
)(__VA_ARGS__, GBL_NULL)
445#define GblStringList_insertArray(...)
446 GblStringList_insertArrayDefault_
(__VA_ARGS__)
447#define GblStringList_insertArrayDefault_(...)
449#define GblStringList_insertArrayDefault__(list, idx, array, size, ...)
450 ((GblStringList_insertArray
(list, idx, array, size)))
452#define GblStringList_compare(...)
453 GblStringList_compareDefault_
(__VA_ARGS__)
454#define GblStringList_compareDefault_(...)
455 GblStringList_compareDefault__
(__VA_ARGS__, GBL_TRUE)
456#define GblStringList_compareDefault__(list1, list2, match, ...)
457 ((GblStringList_compare
)(list1, list2, match))
459#define GblStringList_equals(...)
460 GblStringList_equalsDefault_
(__VA_ARGS__)
461#define GblStringList_equalsDefault_(...)
462 GblStringList_equalsDefault__
(__VA_ARGS__, GBL_TRUE)
463#define GblStringList_equalsDefault__(list1, list2, match, ...)
464 ((GblStringList_equals
)(list1, list2, match))
466#define GblStringList_compareStrs(...)
467 ((GblStringList_compareStrs
)(__VA_ARGS__, GBL_NULL))
469#define GblStringList_equalsStrs(...)
470 ((GblStringList_equalsStrs
)(__VA_ARGS__, GBL_NULL))
472#define GblStringList_find(...)
474#define GblStringList_findDefault_2(list, str)
475 GblStringList_findDefault_3
(list, str, GBL_TRUE)
476#define GblStringList_findDefault_3(list, str, match)
477 GblStringList_findDefault_4
(list, str, match, 0
)
478#define GblStringList_findDefault_4(list, str, match, offset)
479 GblStringList_findDefault_5
(list, str, match, offset, 0
)
480#define GblStringList_findDefault_5(list, str, match, offset, len)
481 ((GblStringList_find
)(list, str, match, offset, len))
483#define GblStringList_rfind(...)
485#define GblStringList_rfindDefault_2(list, str)
486 GblStringList_rfindDefault_3
(list, str, GBL_TRUE)
487#define GblStringList_rfindDefault_3(list, str, match)
489#define GblStringList_rfindDefault_4(list, str, match, offset)
490 GblStringList_rfindDefault_5
(list, str, match, offset, 0
)
491#define GblStringList_rfindDefault_5(list, str, match, offset, len)
492 (GblStringList_rfind
)(list, str, match, offset, len)
494#define GblStringList_contains(...)
496#define GblStringList_containsDefault_2(list, str)
497 GblStringList_containsDefault_3
(list, str, GBL_TRUE)
498#define GblStringList_containsDefault_3(list, str, match)
499 GblStringList_containsDefault_4
(list, str, match, 0
)
500#define GblStringList_containsDefault_4(list, str, match, len)
501 ((GblStringList_contains
)(list, str, match, len))
503#define GblStringList_count(...)
505#define GblStringList_countDefault_2(list, str)
506 GblStringList_countDefault_3
(list, str, GBL_TRUE)
507#define GblStringList_countDefault_3(list, str, match)
508 GblStringList_countDefault_4
(list, str, match, 0
)
509#define GblStringList_countDefault_4(list, str, match, len)
510 ((GblStringList_count
)(list, str, match, len))
512#define GblStringList_set(...)
513 GblStringList_setDefault_
(__VA_ARGS__)
514#define GblStringList_setDefault_(...)
515 GblStringList_setDefault__
(__VA_ARGS__, 0
)
516#define GblStringList_setDefault__(list, idx, str, len, ...)
517 ((GblStringList_set
)(list, idx, str, len))
519#define GblStringList_replace(...)
521#define GblStringList_replaceDefault_3(list, old, repl)
522 GblStringList_replaceDefault_4
(list, old, repl, GBL_TRUE)
523#define GblStringList_replaceDefault_4(list, old, repl, match)
524 GblStringList_replaceDefault_5
(list, old, repl, match, 0
)
525#define GblStringList_replaceDefault_5(list, old, repl, match, limit)
526 GblStringList_replaceDefault_6
(list, old, repl, match, limit, 0
)
527#define GblStringList_replaceDefault_6(list, old, repl, match, limit, oldLen)
528 GblStringList_replaceDefault_7
(list, old, repl, match, limit, oldLen, 0
)
529#define GblStringList_replaceDefault_7(list, old, repl, match, limit, oldLen, newLen)
530 ((GblStringList_replace
)(list, old, repl, match, limit, oldLen, newLen))
532#define GblStringList_replaceWithRef(...)
533 GblStringList_replaceWithRefDefault_
(__VA_ARGS__)
534#define GblStringList_replaceWithRefDefault_(...)
536#define GblStringList_replaceWithRefDefault_3(list, old, repl)
537 GblStringList_replaceWithRefDefault_4
(list, old, repl, GBL_TRUE)
538#define GblStringList_replaceWithRefDefault_4(list, old, repl, match)
539 GblStringList_replaceWithRefDefault_5
(list, old, repl, match, 0
)
540#define GblStringList_replaceWithRefDefault_5(list, old, repl, match, limit)
541 GblStringList_replaceWithRefDefault_6
(list, old, repl, match, limit, 0
)
542#define GblStringList_replaceWithRefDefault_6(list, old, repl, match, limit, oldLen)
543 (GblStringList_replaceWithRef
)(list, old, repl, match, limit, oldLen)
545#define GblStringList_splice(...)
546 GblStringList_spliceDefault_
(__VA_ARGS__)
547#define GblStringList_spliceDefault_(...)
548 GblStringList_spliceDefault__
(__VA_ARGS__, -1
)
549#define GblStringList_spliceDefault__(list, other, index, ...)
550 (GblStringList_splice
)(list, other, index)
552#define GblStringList_join(...)
553 GblStringList_joinDefault_
(__VA_ARGS__)
554#define GblStringList_joinDefault_(...)
555 GblStringList_joinDefault__
(__VA_ARGS__, 0
)
556#define GblStringList_joinDefault__(list, sep, len, ...)
557 ((GblStringList_join
)(list, sep, len))
559#define GblStringList_erase(...)
560 GblStringList_eraseDefault_
(__VA_ARGS__)
561#define GblStringList_eraseDefault_(...)
562 GblStringList_eraseDefault__
(__VA_ARGS__, 1
)
563#define GblStringList_eraseDefault__(list, index, count, ...)
564 (GblStringList_erase
)(list, index, count)
566#define GblStringList_remove(...)
568#define GblStringList_removeDefault_2(list, str)
569 GblStringList_removeDefault_3
(list, str, GBL_TRUE)
570#define GblStringList_removeDefault_3(list, str, match)
571 GblStringList_removeDefault_4
(list, str, match, 0
)
572#define GblStringList_removeDefault_4(list, str, match, len)
573 ((GblStringList_remove
)(list, str, match, len))
575#define GblStringList_deduplicate(...)
576 GblStringList_deduplicateDefault_
(__VA_ARGS__)
577#define GblStringList_deduplicateDefault_(...)
578 GblStringList_deduplicateDefault__
(__VA_ARGS__, GBL_TRUE)
579#define GblStringList_deduplicateDefault__(list, match, ...)
580 (GblStringList_deduplicate
)(list, match)
582#define GblStringList_sort(...)
583 GblStringList_sortDefault_
(__VA_ARGS__)
584#define GblStringList_sortDefault_(...)
585 GblStringList_sortDefault__
(__VA_ARGS__, GBL_TRUE)
586#define GblStringList_sortDefault__(list, asc, ...)
587 (GblStringList_sort
)(list, asc)
589#define GblStringList_foreach(...)
590 GblStringList_foreachDefault_
(__VA_ARGS__)
591#define GblStringList_foreachDefault_(...)
592 GblStringList_foreachDefault__
(__VA_ARGS__, GBL_NULL)
593#define GblStringList_foreachDefault__(list, iter, cl, ...)
594 (GblStringList_foreach
)(list, iter, cl)
#define GBL_VA_OVERLOAD_CALL_ARGC(BASE,...)
#define GBL_RING_LIST_NPOS
#define GBL_STRING_LIST_NPOS
Represents the last position or an invalid index in a GblStringList.
void GblStringList_sort(GblStringList *pSelf, GblBool descending)
Sorts the given list alphabetically in ascending order (by default) or descending order.
GblStringList * GblStringList_createEmpty(void)
Creates and returns a new, empty GblStringList reference with a size of 0.
size_t GblStringList_replaceWithRef(GblStringList *pSelf, const char *pOld, GblStringRef *pNew, GblBool matchCase, size_t limit, size_t oldLen)
Equivalent to GblStringList_replace(), except the replacement is a new reference to the given GblStri...
GBL_RESULT GblStringList_set(GblStringList *pSelf, intptr_t index, const char *pStr, size_t strLen)
Sets the string contained at the given signed index to pStr, returning a result code.
GBL_RESULT GblStringList_erase(GblStringList *pSelf, intptr_t index, size_t count)
Erases count (default 1) entries from the list, starting at index, returning a status code.
void GblStringList_rotate(GblStringList *pSelf, intptr_t n)
Rotates entries of the given list either forward or backwards, wrapping them back around as necessary...
GblRefCount GblStringList_unref(GblStringList *pSelf)
Releases a reference to the given GblStringList, decrementing and returning its remaining refCount,...
GBL_RESULT GblStringList_splice(GblStringList *pSelf, GblStringList *pOther, intptr_t index)
Splices the contents of pOther into pSelf at index, returning a result code.
GblStringList * GblStringList_createFilter(const GblStringList *pSrc, const char *pPat)
Creates and returns a new GblStringList, populated only by those strings from pSrc which match the gi...
GblStringList * GblStringList_create(const char *pFirst,...)
Creates and returns a new GblStringList reference, populating it with a list of C strings (auto NULL-...
GBL_RESULT GblStringList_setRef(GblStringList *pSelf, intptr_t index, GblStringRef *pRef)
Sets the string located at the given signed index to a new reference to pRef, returning a result code...
GBL_RESULT GblStringList_deduplicate(GblStringList *pSelf, GblBool matchCase)
Removes all duplicate copies of any strings contained within the given list, returning a status code.
GblBool GblStringList_empty(const GblStringList *pSelf)
Returns whether the given GblStringList contains any string elements or not.
GBL_RESULT GblStringList_pushBackArray(GblStringList *pSelf, const char **ppStrArray, size_t len)
Appends the given optionally NULL-terminated array of C strings to the back of the given list,...
GblStringRef * GblStringList_join(const GblStringList *pSelf, const char *pSeparator, size_t sepLen)
Joins together all strings within the list into a single string, separated by pSeparator,...
size_t GblStringList_size(const GblStringList *pSelf)
Returns the number of string elements contained by the the given GblStringList.
size_t GblStringList_replace(GblStringList *pSelf, const char *pOld, const char *pNew, GblBool matchCase, size_t limit, size_t oldLen, size_t newLen)
Replaces limit instances of pOld with pNew found within the list, returning the number found.
GblStringList * GblStringList_createSplit(const char *pStr, const char *pDelim, size_t strLen, size_t delimLen)
Creates and returns a new GblStringList, populating it with pStr split up by every occurence of pDeli...
int GblStringList_compareStrsVa(const GblStringList *pSelf, int matchCase, va_list *pVa)
Equivalent to GblStringList_compareStrs(), except the NULL-terminated list of C strings is passed thr...
GBL_RESULT GblStringList_insertRefs(GblStringList *pSelf, intptr_t index,...)
Inserts new references to a(n auto) NULL-terminated list of GblStringRefs to index,...
GblRefCount GblStringList_refCount(const GblStringList *pSelf)
Returns the number of active references to the given GblStringList.
GBL_RESULT GblStringList_pushBackViewsVa(GblStringList *pSelf, va_list *pVa)
Equivalent to GblStringList_pushBackViews(), except the (string, length) pairs are passed through a v...
int GblStringList_compareStrs(const GblStringList *pSelf, int matchCase,...)
Equivalent to GblStringList_compare(), except that an (auto) NULL-terminated list of C strings is the...
GBL_RESULT GblStringList_insertViews(GblStringList *pSelf, intptr_t index,...)
Inserts the given (auto) NULL-terminated list of (string, length) pairs into index in the list,...
size_t GblStringList_rfind(const GblStringList *pSelf, const char *pStr, GblBool matchCase, size_t offset, size_t strLen)
This function is equivalent to GblStringList_find(), except that it searches from the last to first e...
GBL_RESULT GblStringList_insertArray(GblStringList *pSelf, intptr_t index, const char **ppStrArray, size_t len)
Inserts the given optionally NULL-terminated list of C strings at into index in the list,...
GblStringRef * GblStringList_back(const GblStringList *pSelf)
Returns the last string (element -1) contained within the given GblStringList or NULL if it's empty.
GblStringList * GblStringList_createWithArray(const char **ppStr, size_t size)
Creates and returns a new GblStringList, populated by an array of const char* pointers,...
GblStringRef * GblStringList_popFront(GblStringList *pSelf)
Pops a reference to the first string in the list off the front, returning it or NULL if empty.
GblStringList * GblStringList_ref(const GblStringList *pSelf)
Returns a reference to an existing GblStringList, incrementing its reference count and returning it b...
int GblStringList_compare(const GblStringList *pSelf, const GblStringList *pOther, GblBool matchCase)
Returns the lexicographical difference between the two lists, optionally doing so case insensitively.
GBL_RESULT GblStringList_pushBackViews(GblStringList *pSelf,...)
Appends the given (auto) NULL-terminated list of (string, length) pairs to the back of the list,...
GblStringRef * GblStringList_front(const GblStringList *pSelf)
Returns the first string (element 0) contained within the given GblStringList or NULL if it's empty.
void GblStringList_reverse(GblStringList *pSelf)
Reverses the order of all entries within the given list, so that the old front is back and vice versa...
GblStringList * GblStringList_createWithViews(const char *pFirst, size_t firstLen,...)
Creates and returns a new GblStringList reference, populating it with the (auto) NULL-terminated list...
GBL_RESULT GblStringList_pushFrontRefs(GblStringList *pSelf,...)
Prepends new references to a list of (auto) NULL-terminated GblStringRefs to the front of the given l...
GblStringRef * GblStringList_at(const GblStringList *pSelf, intptr_t index)
Returns the string contained at the given signedindex within the GblStringList or NULL if invalid.
GBL_RESULT GblStringList_insert(GblStringList *pSelf, intptr_t index,...)
Inserts a(n auto) NULL-terminated list of C strings to the signed index of the list,...
GBL_RESULT GblStringList_pushBackRefs(GblStringList *pSelf,...)
Appends new references to a list of (auto) NULL-terminated GblStringRefs to the end of the given list...
GblBool GblStringList_equalsStrsVa(const GblStringList *pSelf, int matchCase, va_list *pVa)
Equivalent to GblStringList_equalsStrs(), except the NULL-terminated list of C strings is passed thro...
GBL_RESULT GblStringList_pushFrontVa(GblStringList *pSelf, va_list *pVa)
Equivalent to GblStringList_pushFront(), except the C strings are passed through a va_list pointer.
GBL_RESULT GblStringList_pushBackRefsVa(GblStringList *pSelf, va_list *pVa)
Equivalent to GblStringList_pushBackRefs(), except the GblStringRefs are passed through a va_list poi...
GblBool GblStringList_equalsStrs(const GblStringList *pSelf, int matchCase,...)
Equivalent to GblStringList_equals(), except that an (auto) NULL-terminated list of C strings is the ...
GblBool GblStringList_foreach(GblStringList *pSelf, GblStringListIterFn pFnIt, void *pCl)
Iterates over every string within the list, passing it and pCl (optional) to pFnInit,...
GBL_RESULT GblStringList_insertRefsVa(GblStringList *pSelf, intptr_t index, va_list *pVa)
Equivalent to GblStringList_insertRefs(), except the list of GblStringRefs is passed through a va_lis...
GblStringList * GblStringList_createVa(const char *pFirst, va_list *pVa)
Equivalent to GblStringList_create(), except for strings N+1 are all passed via a va_list pointer.
GBL_RESULT GblStringList_pushBack(GblStringList *pSelf,...)
Appends the given (auto) NULL-terminated list of C strings to the back of the list,...
size_t GblStringList_find(const GblStringList *pSelf, const char *pStr, GblBool matchCase, size_t offset, size_t strLen)
Searches the list for pStr, starting at offset, returning its index if found, or GBL_RING_LIST_NPOS o...
GBL_RESULT GblStringList_pushFrontViewsVa(GblStringList *pSelf, va_list *pVa)
Equivalent to GblStringList_pushFrontViews(), except the (string, length) pairs are passed through a ...
GblStringList * GblStringList_createWithRefs(GblStringRef *pFirst,...)
Equivalent to GblStringList_create(), except for the strings are provided as GblStringRefs (which wil...
GBL_RESULT GblStringList_pushFrontArray(GblStringList *pSelf, const char **ppStrArray, size_t len)
Prepends the given optionally NULL-terminated array of C strings to the front of the given list,...
GBL_RESULT GblStringList_pushFrontRefsVa(GblStringList *pSelf, va_list *pVa)
Equivalent to GblStringList_pushFrontRefs(), except the GblStringRefs are passed through a va_list po...
GblStringRef * GblStringList_popBack(GblStringList *pSelf)
Pops a reference to the last string in the list off of the end, returning it or NULL if empty.
GblBool GblStringList_equals(const GblStringList *pSelf, const GblStringList *pOther, GblBool matchCase)
Returns GBL_TRUE if the given list is lexicographically equal to the pOther list, optionally ignoring...
GBL_RESULT GblStringList_pushFront(GblStringList *pSelf,...)
Prepends the given (auto) NULL-terminated list of C strings to the front of the list,...
GBL_RESULT GblStringList_pushBackVa(GblStringList *pSelf, va_list *pVa)
Equivalent to GblStringList_pushBack(), except the C strings are passed through a va_list pointer.
GBL_RESULT GblStringList_insertVa(GblStringList *pSelf, intptr_t index, va_list *pVa)
Equivalent to GblStringList_insert(), except the list of C strings is passed through a va_list pointe...
GblStringList * GblStringList_createCopy(const GblStringList *pSrc, intptr_t startIdx, size_t count)
Deep copies an existing GblStringList, creating a duplicated list populated by references to the valu...
GBL_RESULT GblStringList_pushFrontViews(GblStringList *pSelf,...)
Prepends the given (auto) NULL-terminated list of (string, length) pairs to the front of the list,...
GblStringList * GblStringList_createWithViewsVa(const char *pFirst, size_t firstLen, va_list *pVa)
Equivalent to GblStringList_createWithViews(), except for views N+1 are all passed via a va_list poin...
GblStringRef * GblStringList_extract(GblStringList *pSelf, GblStringList *pNode)
Extracts the given node from the given list, returning its internally contained GblStringRef.
GblBool GblStringList_contains(const GblStringList *pSelf, const char *pStr, GblBool matchCase, size_t strLen)
Searches the given list for the first instance of pStr, returning its index or GBL_RING_LIST_NPOS if ...
GBL_RESULT GblStringList_clear(GblStringList *pSelf)
Clears the given list, removing all string elements it contains, and returning a status code.
size_t GblStringList_count(const GblStringList *pSelf, const char *pStr, GblBool matchCase, size_t strLen)
Searches the given list for the number of occurences of pStr, optionally doing case insensitive compa...
GBL_RESULT GblStringList_insertViewsVa(GblStringList *pSelf, intptr_t index, va_list *pVa)
Equivalent to GblStringList_insertViews(), except the list of pairs is provided through a va_list poi...
size_t GblStringList_remove(GblStringList *pSelf, const char *pStr, GblBool matchCase, size_t strLen)
Removes all instances of pStr, optionally ignoring case, from the given list, returning the number re...
GblStringList * GblStringList_createWithRefsVa(GblStringRef *pFirst, va_list *pVa)
Equivalent to GblStringList_createWithRefs(), except for strings N+1 are all passed via a va_list poi...
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
GblRingList GblStringList
List of strings with array-like API.
const char GblStringRef
Reference-counted, const char*-compatible string type.