libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_string_list.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblStringList structure and related functions
3 * \ingroup strings
4 *
5 * This file contains the definition of GblStringList
6 * and its related API. A GblStringList is a container
7 * for conveniently working with multiple separate
8 * strings.
9 *
10 * \sa GblStringList
11 *
12 * \todo
13 * - Add pattern matching API
14 * - replaceInStrings
15 * - GblStringList_createSplitPattern()
16 * - test any "view" method
17 * - make splice take a range
18 * - compare/equals strings/arrays/views
19 * - pushBack/pushFront arrays
20 * - insert arrays
21 *
22 * \author 2023 Falco Girgis
23 * \copyright MIT License
24 */
25#ifndef GIMBAL_STRING_LIST_H
26#define GIMBAL_STRING_LIST_H
27
28#include "../containers/gimbal_ring_list.h"
30
31//! Represents the last position or an invalid index in a GblStringList
32#define GBL_STRING_LIST_NPOS GBL_RING_LIST_NPOS
33
34#define GBL_SELF_TYPE GblStringList
35
37
38/*! Iterator function used with GblStringList_foreach()
39
40 Callback used when iterating over a GblStringList, getting passed
41 a reference to each GblStringRef within the list, along with an
42 optional closure/capture value that can be passed in.
43
44 Returning GBL_TRUE will cause iteration to cease early.
45*/
46typedef GblBool (*GblStringListIterFn)(GblStringRef* pRef, void* pClosure);
47
48/*! List of strings with array-like API
49 * \ingroup strings
50 *
51 * GblStringList is a dynamically resizable list of immutable
52 * strings. It is implemented as a GblRingBuffer where each entry
53 * is a GblStringRef.
54 *
55 * \warning Since each entry is a GblStringRef, it should not be directly
56 * modified, as this will modify the value of every other reference to the
57 * same string data. If you must modify an entry, use GblStringList_replaceStr
58 * to replace an existing entry with a new value.
59 *
60 * \note Since GblStringList is backed by GblRingList, it gains some
61 * interesting properties. The list can be rotated, reversed, and
62 * indexed from the opposite direction using negative values. Operations
63 * such as middle insertion/deletion and joining with another list do
64 * not require dynamically resizing or moving list entries. It also
65 * becomes a reference type with reference semantics.
66 *
67 * \note Since each entry within the list is a GblStringRef, operations
68 * such as creating sublists, filtering, copying, and any operation that
69 * creates a new list from an existing list are optimized to not actually
70 * copy the values of each individual string. Instead, each derived list
71 * shares a reference to the same memory location.
72 *
73 * \note Since each entry within the list is a GblStringRef, there is a
74 * duplicate API provided for when inserting entries into the list which
75 * are already GblStringRefs. Favor the methods ending with "Ref" for
76 * when you already have a reference type, and this will ellide copying.
77 *
78 * \sa GblStringRef, GblRingBuffer
79 */
80typedef GblRingList GblStringList;
81
82/*! \name Lifetime Management
83 * \brief Methods for creating, referencing, and unreferencing lists
84 * @{
85 */
86//! Creates and returns a new, empty GblStringList reference with a size of 0
88//! Creates and returns a new GblStringList reference, populating it with a list of C strings (auto NULL-terminated)
89GBL_EXPORT GblStringList* GblStringList_create (const char* pFirst, .../*, NULL*/) GBL_NOEXCEPT;
90//! Equivalent to GblStringList_create(), except for strings N+1 are all passed via a va_list pointer
91GBL_EXPORT GblStringList* GblStringList_createVa (const char* pFirst, va_list* pVa) GBL_NOEXCEPT;
92//! Equivalent to GblStringList_create(), except for the strings are provided as GblStringRefs (which will be referenced again)
94//! Equivalent to GblStringList_createWithRefs(), except for strings N+1 are all passed via a va_list pointer
96//! Creates and returns a new GblStringList reference, populating it with the (auto) NULL-terminated list of (string, length) pairs
98 size_t firstLen,
99 ...
100 /*, NULL*/) GBL_NOEXCEPT;
101//! Equivalent to GblStringList_createWithViews(), except for views N+1 are all passed via a va_list pointer
103 size_t firstLen,
104 va_list* pVa) GBL_NOEXCEPT;
105//! Creates and returns a new GblStringList, populated by an array of const char* pointers, with either a size or NULL terminator (default)
107 size_t size/*=NPOS*/) GBL_NOEXCEPT;
108//! Creates and returns a new GblStringList, populating it with \p pStr split up by every occurence of \p pDelim
110 const char* pDelim,
111 size_t strLen/*=0*/,
112 size_t delimLen/*=0*/) GBL_NOEXCEPT;
113//! Deep copies an existing GblStringList, creating a duplicated list populated by references to the values held by \p pSrc
115 intptr_t startIdx/*=0*/,
116 size_t count/*=NPOS*/) GBL_NOEXCEPT;
117//! Creates and returns a new GblStringList, populated only by those strings from \p pSrc which match the given pattern, \p pPat
119 const char* pPat) GBL_NOEXCEPT;
120//! Returns a reference to an existing GblStringList, incrementing its reference count and returning it back
122//! Releases a reference to the given GblStringList, decrementing and returning its remaining refCount, destroying it upon hitting 0
124//! @}
125
126/*! \name Operators
127 * \brief Methods implementing basic operations
128 * @{
129 */
130//! Returns the lexicographical difference between the two lists, optionally doing so case insensitively
132 const GblStringList* pOther,
133 GblBool matchCase/*=GBL_TRUE*/) GBL_NOEXCEPT;
134//! Returns GBL_TRUE if the given list is lexicographically equal to the \p pOther list, optionally ignoring case
136 const GblStringList* pOther,
137 GblBool matchCase/*=GBL_TRUE*/) GBL_NOEXCEPT;
138//! Equivalent to GblStringList_compare(), except that an (auto) NULL-terminated list of C strings is the other value being compared
140 int matchCase,
141 ...
142 /*,NULL*/) GBL_NOEXCEPT;
143//! Equivalent to GblStringList_equals(), except that an (auto) NULL-terminated list of C strings is the value being compared
145 int matchCase,
146 ...
147 /*,NULL*/) GBL_NOEXCEPT;
148//! Equivalent to GblStringList_compareStrs(), except the NULL-terminated list of C strings is passed through a va_list pointer
150 int matchCase,
151 va_list* pVa) GBL_NOEXCEPT;
152//! Equivalent to GblStringList_equalsStrs(), except the NULL-terminated list of C strings is passed through a va_list pointer
154 int matchCase,
155 va_list* pVa) GBL_NOEXCEPT;
156
157//! @}
158
159/*! \name Properties
160 * \brief Methods for accessing properties and derived data
161 * @{
162 */
163//! Returns the number of active references to the given GblStringList
165//! Returns the number of string elements contained by the the given GblStringList
167//! Returns whether the given GblStringList contains any string elements or not
169//! Returns the first string (element 0) contained within the given GblStringList or NULL if it's empty
171//! Returns the last string (element -1) contained within the given GblStringList or NULL if it's empty
173//! Returns the string contained at the given signed\p index within the GblStringList or NULL if invalid
175//! @}
176
177/*! \name Searching
178 * \brief Methods for finding, counting, and replacing strings
179 * @{
180 */
181//! Searches the list for \p pStr, starting at \p offset, returning its index if found, or GBL_RING_LIST_NPOS otherwise
183 const char* pStr,
184 GblBool matchCase/*=GBL_TRUE*/,
185 size_t offset/*=0*/,
186 size_t strLen/*=0*/) GBL_NOEXCEPT;
187//! This function is equivalent to GblStringList_find(), except that it searches from the last to first element
189 const char* pStr,
190 GblBool matchCase/*=GBL_TRUE*/,
191 size_t offset/*=GBL_STRING_LIST_NPOS*/,
192 size_t strLen/*=0*/) GBL_NOEXCEPT;
193//! Searches the given list for the first instance of \p pStr, returning its index or GBL_RING_LIST_NPOS if it wasn't found
195 const char* pStr,
196 GblBool matchCase/*=GBL_TRUE*/,
197 size_t strLen/*=0*/) GBL_NOEXCEPT;
198//! Searches the given list for the number of occurences of \p pStr, optionally doing case insensitive comparisons
200 const char* pStr,
201 GblBool matchCase/*=GBL_TRUE*/,
202 size_t strLen/*=0*/) GBL_NOEXCEPT;
203//! @}
204
205/*! \name Assigning
206 * \brief Methods for setting elements
207 * @{
208 */
209//! Sets the string contained at the given signed \p index to \p pStr, returning a result code
211 intptr_t index,
212 const char* pStr,
213 size_t strLen/*=0*/) GBL_NOEXCEPT;
214//! Sets the string located at the given signed \p index to a new reference to \p pRef, returning a result code
216 intptr_t index,
218//! @}
219
220/*! \name Adding
221 * \brief Methods for appending and inserting strings
222 * @{
223 */
224//! Appends the given (auto) NULL-terminated list of C strings to the back of the list, returning a status code
226//! Equivalent to GblStringList_pushBack(), except the C strings are passed through a va_list pointer
228//! Appends <i>new references</i> to a list of (auto) NULL-terminated GblStringRefs to the end of the given list, returning a status code
230//! Equivalent to GblStringList_pushBackRefs(), except the GblStringRefs are passed through a va_list pointer
232//! Appends the given (auto) NULL-terminated list of (string, length) pairs to the back of the list, returning a status code
234 /* const char* pStr, */
235 /* size_t strLen,*/
236 ...
237 /*, NULL*/) GBL_NOEXCEPT;
238//! Equivalent to GblStringList_pushBackViews(), except the (string, length) pairs are passed through a va_list pointer
240//! Appends the given optionally NULL-terminated array of C strings to the back of the given list, returning a status code
242 const char** ppStrArray,
243 size_t len/*=NPOS*/) GBL_NOEXCEPT;
244
245//! Prepends the given (auto) NULL-terminated list of C strings to the front of the list, returning a status code
247//! Equivalent to GblStringList_pushFront(), except the C strings are passed through a va_list pointer
249//! Prepends <i>new references</i> to a list of (auto) NULL-terminated GblStringRefs to the front of the given list, returning a status code
251//! Equivalent to GblStringList_pushFrontRefs(), except the GblStringRefs are passed through a va_list pointer
253//! Prepends the given (auto) NULL-terminated list of (string, length) pairs to the front of the list, returning a status code
255 /* const char* pStr, */
256 /* size_t strLen,*/
257 ...
258 /*, NULL*/) GBL_NOEXCEPT;
259//! Equivalent to GblStringList_pushFrontViews(), except the (string, length) pairs are passed through a va_list pointer
261//! Prepends the given optionally NULL-terminated array of C strings to the front of the given list, returning a status code
263 const char** ppStrArray,
264 size_t len/*=NPOS*/) GBL_NOEXCEPT;
265
266//! Inserts a(n auto) NULL-terminated list of C strings to the signed \p index of the list, returning a status code
268 intptr_t index,
269 ...
270 /*, NULL*/) GBL_NOEXCEPT;
271//! Equivalent to GblStringList_insert(), except the list of C strings is passed through a va_list pointer
273 intptr_t index,
274 va_list* pVa) GBL_NOEXCEPT;
275//! Inserts <i>new references</i> to a(n auto) NULL-terminated list of GblStringRefs to \p index, returning a status code
277 intptr_t index,
278 ...
279 /*, NULL*/) GBL_NOEXCEPT;
280//! Equivalent to GblStringList_insertRefs(), except the list of GblStringRefs is passed through a va_list pointer
282 intptr_t index,
283 va_list* pVa) GBL_NOEXCEPT;
284//! Inserts the given (auto) NULL-terminated list of (string, length) pairs into \p index in the list, returning a status code
286 intptr_t index,
287 /*const char* pStr, */
288 /* size_t strLen, */
289 ...
290 /*, NULL*/) GBL_NOEXCEPT;
291//! Equivalent to GblStringList_insertViews(), except the list of pairs is provided through a va_list pointer
293 intptr_t index,
294 va_list* pVa) GBL_NOEXCEPT;
295//! Inserts the given optionally NULL-terminated list of C strings at into \p index in the list, returning a status code
297 intptr_t index,
298 const char** ppStrArray,
299 size_t len/*=NPOS*/) GBL_NOEXCEPT;
300//! @}
301
302/*! \name Removing
303 * \brief Methods for popping and erasing strings
304 * @{
305 */
306//! Pops a reference to the last string in the list off of the end, returning it or NULL if empty
308//! Pops a reference to the first string in the list off the front, returning it or NULL if empty
310//! Erases \p count (default 1) entries from the list, starting at \p index, returning a status code
312 intptr_t index,
313 size_t count/*=1*/) GBL_NOEXCEPT;
314//! Removes all instances of \p pStr, optionally ignoring case, from the given list, returning the number removed
316 const char* pStr,
317 GblBool matchCase/*=GBL_TRUE*/,
318 size_t strLen/*=0*/) GBL_NOEXCEPT;
319//! Extracts the given node from the given list, returning its internally contained GblStringRef
322//! Removes all duplicate copies of any strings contained within the given list, returning a status code
324 GblBool matchCase/*=GBL_TRUE*/) GBL_NOEXCEPT;
325//! Clears the given list, removing all string elements it contains, and returning a status code
327//! @}
328
329/*! \name Miscellaneous
330 * \brief Methods for replacing, sorting, and other utilities
331 * @{
332 */
333//! Replaces \p limit instances of \p pOld with \p pNew found within the list, returning the number found
335 const char* pOld,
336 const char* pNew,
337 GblBool matchCase/*=TRUE*/,
338 size_t limit/*=0*/,
339 size_t oldLen/*=0*/,
340 size_t newLen/*=0*/) GBL_NOEXCEPT;
341//! Equivalent to GblStringList_replace(), except the replacement is a <i>new reference</i> to the given GblStringRef
343 const char* pOld,
344 GblStringRef* pNew,
345 GblBool matchCase/*=TRUE*/,
346 size_t limit/*=0*/,
347 size_t oldLen/*=0*/) GBL_NOEXCEPT;
348//! Splices the contents of \p pOther into \p pSelf at \p index, returning a result code
350 GblStringList* pOther,
351 intptr_t index/*=-1*/) GBL_NOEXCEPT;
352//! Joins together all strings within the list into a single string, separated by \p pSeparator, returning a new reference
354 const char* pSeparator,
355 size_t sepLen/*=0*/) GBL_NOEXCEPT;
356//! Sorts the given list alphabetically in ascending order (by default) or descending order
358 GblBool descending/*=TRUE*/) GBL_NOEXCEPT;
359//! Rotates entries of the given list either forward or backwards, wrapping them back around as necessary
361//! Reverses the order of all entries within the given list, so that the old front is back and vice versa
363//! Iterates over every string within the list, passing it and \p pCl (optional) to \p pFnInit, see \sa GblStringListIterFn
365 GblStringListIterFn pFnIt,
366 void* pCl/*=NULL*/) GBL_NOEXCEPT;
367//! @}
368
370
371///\cond
372#define GblStringList_create(...)
373 (GblStringList_create)(__VA_ARGS__, GBL_NULL)
374
375#define GblStringList_createWithRefs(...)
376 (GblStringList_createWithRefs)(__VA_ARGS__, GBL_NULL)
377
378#define GblStringList_createWithViews(first, ...)
379 ((GblStringList_createWithViews)(first, __VA_ARGS__, NULL))
380
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))
387
388#define GblStringList_createWithArray(...)
389 GblStringList_createWithArrayDefault_(__VA_ARGS__)
390#define GblStringList_createWithArrayDefault_(...)
391 GblStringList_createWithArrayDefault__(__VA_ARGS__, GBL_STRING_LIST_NPOS)
392#define GblStringList_createWithArrayDefault__(array, len, ...)
393 (GblStringList_createWithArray)(array, len)
394
395#define GblStringList_createCopy(...)
396 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_createCopyDefault, __VA_ARGS__)
397#define GblStringList_createCopyDefault_1(src)
398 GblStringList_createCopyDefault_2(src, 0)
399#define GblStringList_createCopyDefault_2(src, index)
400 GblStringList_createCopyDefault_3(src, index, GBL_STRING_LIST_NPOS)
401#define GblStringList_createCopyDefault_3(src, index, count)
402 ((GblStringList_createCopy)(src, index, count))
403
404#define GblStringList_pushBack(...)
405 (GblStringList_pushBack)(__VA_ARGS__, GBL_NULL)
406
407#define GblStringList_pushBackRefs(...)
408 (GblStringList_pushBackRefs)(__VA_ARGS__, GBL_NULL)
409
410#define GblStringList_pushBackViews(...)
411 (GblStringList_pushBackViews)(__VA_ARGS__, GBL_NULL)
412
413#define GblStringList_pushBackArray(...)
414 GblStringList_pushBackArrayDefault_(__VA_ARGS__)
415#define GblStringList_pushBackArrayDefault_(...)
416 GblStringList_pushBackArrayDefault__(__VA_ARGS__, GBL_STRING_LIST_NPOS)
417#define GblStringList_pushBackArrayDefault__(list, array, size, ...)
418 ((GblStringList_pushBackArray)(list, array, size))
419
420#define GblStringList_pushFront(...)
421 (GblStringList_pushFront)(__VA_ARGS__, GBL_NULL)
422
423#define GblStringList_pushFrontRefs(...)
424 (GblStringList_pushFrontRefs)(__VA_ARGS__, GBL_NULL)
425
426#define GblStringList_pushFrontViews(...)
427 (GblStringList_pushFrontViews)(__VA_ARGS__, GBL_NULL)
428
429#define GblStringList_pushFrontArray(...)
430 GblStringList_pushFrontArrayDefault_(__VA_ARGS__)
431#define GblStringList_pushFrontArrayDefault_(...)
432 GblStringList_pushFrontArrayDefault__(__VA_ARGS__, GBL_STRING_LIST_NPOS)
433#define GblStringList_pushFrontArrayDefault__(list, array, size, ...)
434 ((GblStringList_pushFrontArray(list, array, size)))
435
436#define GblStringList_insert(...)
437 (GblStringList_insert)(__VA_ARGS__, GBL_NULL)
438
439#define GblStringList_insertRefs(...)
440 (GblStringList_insertRefs)(__VA_ARGS__, GBL_NULL)
441
442#define GblStringList_insertViews(...)
443 (GblStringList_insertViews)(__VA_ARGS__, GBL_NULL)
444
445#define GblStringList_insertArray(...)
446 GblStringList_insertArrayDefault_(__VA_ARGS__)
447#define GblStringList_insertArrayDefault_(...)
448 GblStringList_insertArrayDefault__(__VA_ARGS__, GBL_STRING_LIST_NPOS)
449#define GblStringList_insertArrayDefault__(list, idx, array, size, ...)
450 ((GblStringList_insertArray(list, idx, array, size)))
451
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))
458
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))
465
466#define GblStringList_compareStrs(...)
467 ((GblStringList_compareStrs)(__VA_ARGS__, GBL_NULL))
468
469#define GblStringList_equalsStrs(...)
470 ((GblStringList_equalsStrs)(__VA_ARGS__, GBL_NULL))
471
472#define GblStringList_find(...)
473 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_findDefault, __VA_ARGS__)
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))
482
483#define GblStringList_rfind(...)
484 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_rfindDefault, __VA_ARGS__)
485#define GblStringList_rfindDefault_2(list, str)
486 GblStringList_rfindDefault_3(list, str, GBL_TRUE)
487#define GblStringList_rfindDefault_3(list, str, match)
488 GblStringList_rfindDefault_4(list, str, match, GBL_STRING_LIST_NPOS)
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)
493
494#define GblStringList_contains(...)
495 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_containsDefault, __VA_ARGS__)
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))
502
503#define GblStringList_count(...)
504 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_countDefault, __VA_ARGS__)
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))
511
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))
518
519#define GblStringList_replace(...)
520 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_replaceDefault, __VA_ARGS__)
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))
531
532#define GblStringList_replaceWithRef(...)
533 GblStringList_replaceWithRefDefault_(__VA_ARGS__)
534#define GblStringList_replaceWithRefDefault_(...)
535 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_replaceWithRefDefault, __VA_ARGS__)
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)
544
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)
551
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))
558
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)
565
566#define GblStringList_remove(...)
567 GBL_VA_OVERLOAD_CALL_ARGC(GblStringList_removeDefault, __VA_ARGS__)
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))
574
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)
581
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)
588
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)
595///\endcond
596
597#undef GBL_SELF_TYPE
598
599#endif // GIMBAL_STRING_LIST_H
#define GBL_NULL
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_EXPORT
#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...
#define GBL_TRUE
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.