libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_string_buffer.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblStringBuffer mutable string builder API
3 * \ingroup strings
4 *
5 * This file contains the structure and C API around the
6 * GblStringBuffer data type, a mutable container that
7 * specializes in building and constructing strings,
8 * equivalent to a C++/Rust string or a C#/Java string
9 * builder.
10 *
11 * \todo
12 * - GblStringBuffer_swap(...)
13 * - GblStringBuffer_match()
14 * - GblStringBuffer_replaceMatch()
15 * - GblStringBuffer_removeMatch()
16 * - GblStringBuffer_appendUint64()
17 * - GblStringBuffer_appendInt64()
18 *
19 * \author 2023 Falco Girgis
20 * \copyright MIT License
21 */
22
23#ifndef GIMBAL_STRING_BUFFER_H
24#define GIMBAL_STRING_BUFFER_H
25
26#include "../containers/gimbal_array_list.h"
29
30#include <stdarg.h>
31
32#define GBL_SELF_TYPE GblStringBuffer
33
35
36/*! \brief Mutable string type optimized for building and writing
37 *
38 * GblStringBuffer is a type of string which is optimized for efficient
39 * piece-wise construction, appending, and writing. It's equivalent to
40 * a "String Builder" type in other languages, such as C# and Java.
41 *
42 * It is typically used temporarily to construct a string, afterwards
43 * it is usually converted to another type for storage, such as a
44 * GblStringRef or the internal buffer is taken away from it to be stored
45 * elsewhere.
46 *
47 * Internally it is implemented similarly to a C++-vector, with both a
48 * size and a capacity, growing when needed, but not immediatley shrinking.
49 *
50 * \note
51 * The API around GblStringBuffer is based around modifying strings. For
52 * read-only operations on them, such as searching or match counting, use
53 * GblStringBuffer_view() and the GblStringView API.
54 *
55 * \note
56 * GblStringBuffer supports being created with additional trailing storage,
57 * allowing it to be over-allocated with malloc() or GBL_ALLOCA(). This means
58 * it will not create a separate heap allocation until necessary, and will
59 * instead useits trailing allocation region as its internal buffer. This can
60 * be very efficient when building temporary strings.
61 *
62 * \ingroup strings
63 * \sa GblStringRef, GblStringView, GblQuark
64 */
65typedef struct GblStringBuffer {
66 GblArrayList data; //!< Internal storage buffer
67} GblStringBuffer;
68
69/*! \name Lifetime Management
70 * \brief Methods for consruction, destruction, moving, etc
71 * \relatesalso GblStringBuffer
72 * @{
73 */
74//! Constructs the given GblStringBuffer struct with any given initial values (or defaults), returning a result code
76 const char* pString/*=NULL*/,
77 size_t length/*=0*/,
78 size_t structSize/*=DEFAULT*/,
79 GblContext* pCtx/*=NULL*/) GBL_NOEXCEPT;
80//! Destructs the given GblStringBuffer structure, releasing any allocated resources and returning a result code
82//! Transfers ownership of a given C string to the given buffer, assigning its value and updating its capacity
83GBL_EXPORT GBL_RESULT GblStringBuffer_acquire (GBL_SELF, char* pData, size_t capacity) GBL_NOEXCEPT;
84//! Takes ownership of the given GblStringBuffer's internal buffer, also returning its capacity and a result code
85GBL_EXPORT GBL_RESULT GblStringBuffer_release (GBL_SELF, char** ppStrPtr, size_t* pCapacity) GBL_NOEXCEPT;
86//! @}
87
88/*! \name Properties
89 * \brief Methods for querying or retrieving associated data
90 * \relatesalso GblStringBuffer
91 * @{
92 */
93//! Returns a mutable pointer to the internal data buffer of the given GblStringBuffer
95//! Returns the string length of the string held by the given GblStringBuffer
97//! Returns the actual size of the internal data buffer held by the given GblStringBuffer
99//! Returns the number of bytes the given GblStringBuffer can store before falling back to the heap
101//! Returns a mutable pointer to the extra stack storage region, if present
103//! Returns a pointer to the context the GblStringBuffer was created with
105//! Returns GBL_TRUE if the given GblStringBuffer is empty, otherwise returns GBL_FALSE
107//! Returns GBL_TRUE if the given GblStringBuffer holds a valid C string (with NULL terminator)
109//! Returns GBL_TRUE if the given GblStringBuffer is empty or holds only spacing characters
111//! Returns GBL_TRUE if the given GblStringBuffer's internal buffer is on the stack and not heap
113
114/*! \name Conversions
115 * \brief Methods for converting to other string types
116 * \relatesalso GblStringBuffer
117 * @{
118 */
119//! Creates and returns a new GblStringRef based on the contents of the given buffer (don't forget to unref it)
122//! Returns a pointer to a constant NULL-terminated C string for the given GblStringBuffer
124//! Returns a pointer to the interned string representation of the buffer, interning it if it hasn't been already
126//! Converts the GblStringBuffer to a GblQuark, possibly interning it, and returning its GblQuark
128//! Returns the GblQuark corresponding to the given GblStringBuffer only if it already exists
130//! Creates a GblStringView containing either the whole buffer or a subsection of it
132 size_t offset/*=0*/,
133 size_t len/*=0*/) GBL_NOEXCEPT;
134//! @}
135
136/*! \name Per-Character Access
137 * \brief Methods for getting and setting individual indices
138 * \relatesalso GblStringBuffer
139 * @{
140 */
141//! Returns the character stored in the given buffer at \p index, throwing an error and returning '\0' if invalid
143//! Sets the character stored in the given buffer at \p index to \p value, returning an error upon failure
144GBL_EXPORT GBL_RESULT GblStringBuffer_setChar (GBL_CSELF, size_t index, char value) GBL_NOEXCEPT;
145//! @}
146
147/*! \name Assignment
148 * \brief Methods for setting the value of a constructed string
149 * \relatesalso GblStringBuffer
150 * @{
151 */
152//! Assigns the value of the given GblStringBuffer to \p pStr, optionally taking its length, \p len
153GBL_EXPORT const char* GblStringBuffer_set (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
154//! Assings the value of the formatted string to the given GblStringBuffer, similarly to C's sscanf()
155GBL_EXPORT const char* GblStringBuffer_printf (GBL_SELF, const char* pFmt, ...) GBL_NOEXCEPT;
156//! Equivalent to GblStringBuffer_printf(), except passing additional arguments via a va_list
157GBL_EXPORT const char* GblStringBuffer_vPrintf (GBL_SELF, const char* pFmt, va_list varArgs) GBL_NOEXCEPT;
158//! @}
159
160/*! \name Prepending
161 * \brief Methods for adding to the beginning of the a string
162 * \relatesalso GblStringBuffer
163 * @{
164 */
165//! Inserts \p pStr (with optional length, \p len) at the beginning of the given buffer, returning a result code
166GBL_EXPORT GBL_RESULT GblStringBuffer_prepend (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
167//! Inserts \p count copies of \p value at the beginning of the given buffer, returning a result code
168GBL_EXPORT GBL_RESULT GblStringBuffer_prependPadding (GBL_SELF, char value, size_t count) GBL_NOEXCEPT;
169//! @}
170
171/*! \name Appending
172 * \brief Methods for adding to the end of a string
173 * \relatesalso GblStringBuffer
174 * @{
175 */
176//! Appends \p pStr (with optional length, \p len) to the given GblStringBuffer, returning a result code
177GBL_EXPORT GBL_RESULT GblStringBuffer_append (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
178//! Appends a printf()-style formatted string to the given GblStringBuffer, returning a result code
180//! Equivalent to GblStringBuffer_appendPrintf(), except additional arguments are provided as a va_list
181GBL_EXPORT GBL_RESULT GblStringBuffer_appendVPrintf (GBL_SELF, const char* pFmt, va_list varArgs) GBL_NOEXCEPT;
182//! Adds \p count copies of \p value to the end of the given GblStringBuffer, returning a result code
183GBL_EXPORT GBL_RESULT GblStringBuffer_appendPadding (GBL_SELF, char value, size_t count) GBL_NOEXCEPT;
184//! Adds the word "nil" to the end of the given GblStringBuffer, returning a result code
186//! Adds either "true" or "false" to the end of the given GblStringBuffer, depending on \p value, and returning a result code
188//! Adds the stringified representation of the integer, \p value, to the end of the given GblStringBuffer, returning a result code
190//! Adds the stringified respresentation of the unsigned integer, \p value, to the end of the given GblStringBuffer, returning a result code
192//! Adds the stringified representation of the float, \p value, to the end of the given GblStringBuffer, returning a result code
194//! Adds the stringified representation of the double, \p value, to the end of the given GblStringBuffer, returning a result code
196//! Adds the hexadecimal string representation of the pointer, \p pPtr, to the end of the given GblStringBuffer, returning a result code
198//! @}
199
200/*! \name Modifying
201 * \brief Methods for general string modifications
202 * \relatesalso GblStringBuffer
203 * @{
204 */
205//! Inserts \p pString at the given \p index with optional \p length, returning a result code
207 size_t index,
208 const char* pString,
209 size_t length/*=0*/) GBL_NOEXCEPT;
210//! Ovewrites a prtion of the string starting at \p index, with \p pString (\p length is optional), resizing as needed, and returning a result code
212 size_t index,
213 const char* pString,
214 size_t length/*=0*/) GBL_NOEXCEPT;
215//! Replaces \p limit instances (0 is infinite) of \p Substr with \p pReplacement, with both lenghts being optional, and returning a result code
217 const char* pSubstr,
218 const char* pReplacement,
219 size_t limit/*=0*/,
220 size_t substrLen/*=0*/,
221 size_t replLen/*=0*/) GBL_NOEXCEPT;
222//! @}
223
224/*! \name Removing
225 * \brief Methods for erasing portions of a string
226 * \relatesalso GblStringBuffer
227 * @{
228 */
229//! Erases the portion of the string from \p offset to \p offset + \p len, resizing it, and returning a result code
230GBL_EXPORT GBL_RESULT GblStringBuffer_erase (GBL_SELF, size_t offset, size_t len) GBL_NOEXCEPT;
231//! Clears the contents of the given GblStringBuffer, resetting it back to an empty state and returning a result code
233//! Removes all instances of \p pStr (\p len is optional) from the given buffer, returning the number of entries removed
234GBL_EXPORT size_t GblStringBuffer_remove (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
235//! Removes the last character from the given GblStringBuffer, returning a result code
237//! Removes any trailing newline characters (`\r` and `\n`) from the given GblStringBuffer, returning a result code
239//! Removes any leading instances of \p value from the beginning of the given GblStringBuffer, returning a result code
241//! Returns any trailing instances of \p value from the end of the given GblStringBuffer, returning a result code
243//! @}
244
245/*! \name Miscellaneous
246 * \brief Methods for other utilities and string operations
247 * \relatesalso GblStringBuffer
248 * @{
249 */
250//! Changes the casing of every character within the GblStringBuffer to lowercase, returning a result code
252//! Changes the casing of every character within the GblStringBuffer to uppercase, returning a result code
254//! Reverses the order of the characters with the given GblStringBuffer, returninga result code
256//! @}
257
258/*! \name Sizing
259 * \brief Methods for managing size and capacity
260 * \relatesalso GblStringBuffer
261 * @{
262 */
263//! Ensures that there is room for \p capacity characters within the given GblStringBuffer, returning a result code
265//! Sets the length of the given GblStringBuffer to \p size, regrowing if necessary, but not shrinking, and returning a result code
267//! Resizes the length of the given GblStringBuffer to be its current length + \p delta, returning a result code
269//! Resizes the length of the given GblStringBuffer to be its current length - \p delta, returning a result code
271//! Shrinks the capacity of the given GblStringBuffer to match its length, if it doesn't already, returning a result code
273//! @}
274
276
277//! \cond
278#define GblStringBuffer_construct(...)
279 GBL_VA_OVERLOAD_CALL_ARGC(GblStringBuffer_construct, __VA_ARGS__)
280#define GblStringBuffer_construct_1(self)
281 GblStringBuffer_construct_2(self, "")
282#define GblStringBuffer_construct_2(self, str)
283 GblStringBuffer_construct_3(self, str, 0)
284#define GblStringBuffer_construct_3(self, str, len)
285 GblStringBuffer_construct_4(self, str, len, sizeof(GblStringBuffer))
286#define GblStringBuffer_construct_4(self, str, len, size)
287 GblStringBuffer_construct_5(self, str, len, size, GBL_NULL)
288#define GblStringBuffer_construct_5(self, str, len, size, ctx)
289 ((GblStringBuffer_construct(self, str, len, size, ctx)))
290
291#define GblStringBuffer_view(...)
292 GblStringBuffer_viewDefault_(__VA_ARGS__)
293#define GblStringBuffer_viewDefault_(...)
294 GblStringBuffer_viewDefault__(__VA_ARGS__, 0, 0)
295#define GblStringBuffer_viewDefault__(buffer, offset, length, ...)
296 ((GblStringBuffer_view)(buffer, offset, length))
297
298#define GblStringBuffer_set(...)
299 GblStringBuffer_setDefault_(__VA_ARGS__)
300#define GblStringBuffer_setDefault_(...)
301 GblStringBuffer_setDefault__(__VA_ARGS__, 0)
302#define GblStringBuffer_setDefault__(buffer, str, len, ...)
303 ((GblStringBuffer_set)(buffer, str, len))
304
305#define GblStringBuffer_insert(...)
306 GblStringBuffer_insertDefault_(__VA_ARGS__)
307#define GblStringBuffer_insertDefault_(...)
308 GblStringBuffer_insertDefault__(__VA_ARGS__, 0)
309#define GblStringBuffer_insertDefault__(buffer, offset, str, len, ...)
310 ((GblStringBuffer_insert)(buffer, offset, str, len))
311
312#define GblStringBuffer_append(...)
313 GblStringBuffer_appendDefault_(__VA_ARGS__)
314#define GblStringBuffer_appendDefault_(...)
315 GblStringBuffer_appendDefault__(__VA_ARGS__, 0)
316#define GblStringBuffer_appendDefault__(buffer, str, len, ...)
317 ((GblStringBuffer_append)(buffer, str, len))
318
319#define GblStringBuffer_prepend(...)
320 GblStringBuffer_prependDefault_(__VA_ARGS__)
321#define GblStringBuffer_prependDefault_(...)
322 GblStringBuffer_prependDefault__(__VA_ARGS__, 0)
323#define GblStringBuffer_prependDefault__(buffer, str, len, ...)
324 ((GblStringBuffer_prepend)(buffer, str, len))
325
326#define GblStringBuffer_overwrite(...)
327 GblStringBuffer_overwriteDefault_(__VA_ARGS__)
328#define GblStringBuffer_overwriteDefault_(...)
329 GblStringBuffer_overwriteDefault__(__VA_ARGS__, 0)
330#define GblStringBuffer_overwriteDefault__(buffer, offset, str, len, ...)
331 ((GblStringBuffer_overwrite)(buffer, offset, str, len))
332
333#define GblStringBuffer_remove(...)
334 GblStringBuffer_removeDefault_(__VA_ARGS__)
335#define GblStringBuffer_removeDefault_(...)
336 GblStringBuffer_removeDefault__(__VA_ARGS__, 0)
337#define GblStringBuffer_removeDefault__(buffer, str, len, ...)
338 ((GblStringBuffer_remove)(buffer, str, len))
339
340#define GblStringBuffer_replace(...)
341 GblStringBuffer_replaceDefault_(__VA_ARGS__)
342#define GblStringBuffer_replaceDefault_(...)
343 GblStringBuffer_replaceDefault__(__VA_ARGS__, 0, 0, 0)
344#define GblStringBuffer_replaceDefault__(buffer, substr, repl, count, substrLen, replLen, ...)
345 (GblStringBuffer_replace(buffer, substr, repl, count, substrLen, replLen))
346//! \endcond
347
348#undef GBL_SELF_TYPE
349
350#endif // GIMBAL_STRING_BUFFER_H
#define GBL_NULL
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_EXPORT
#define GBL_VA_OVERLOAD_CALL_ARGC(BASE,...)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uintptr_t GblQuark
Uniquely identifiable interned string type.
const char GblStringRef
Reference-counted, const char*-compatible string type.
Mutable string type optimized for building and writing.
size_t GblStringBuffer_remove(GblStringBuffer *pSelf, const char *pStr, size_t len)
Removes all instances of pStr (len is optional) from the given buffer, returning the number of entrie...
GBL_RESULT GblStringBuffer_appendPointer(GblStringBuffer *pSelf, const void *pPtr)
Adds the hexadecimal string representation of the pointer, pPtr, to the end of the given GblStringBuf...
GBL_RESULT GblStringBuffer_destruct(GblStringBuffer *pSelf)
Destructs the given GblStringBuffer structure, releasing any allocated resources and returning a resu...
size_t GblStringBuffer_stackBytes(const GblStringBuffer *pSelf)
Returns the number of bytes the given GblStringBuffer can store before falling back to the heap.
char * GblStringBuffer_data(GblStringBuffer *pSelf)
Returns a mutable pointer to the internal data buffer of the given GblStringBuffer.
const GblStringRef * GblStringBuffer_createRef(const GblStringBuffer *pSelf)
Creates and returns a new GblStringRef based on the contents of the given buffer (don't forget to unr...
const char * GblStringBuffer_set(GblStringBuffer *pSelf, const char *pStr, size_t len)
Assigns the value of the given GblStringBuffer to pStr, optionally taking its length,...
GBL_RESULT GblStringBuffer_appendPadding(GblStringBuffer *pSelf, char value, size_t count)
Adds count copies of value to the end of the given GblStringBuffer, returning a result code.
GBL_RESULT GblStringBuffer_resize(GblStringBuffer *pSelf, size_t size)
Sets the length of the given GblStringBuffer to size, regrowing if necessary, but not shrinking,...
GblBool GblStringBuffer_valid(const GblStringBuffer *pSelf)
Returns GBL_TRUE if the given GblStringBuffer holds a valid C string (with NULL terminator)
GBL_RESULT GblStringBuffer_appendUint(GblStringBuffer *pSelf, unsigned value)
Adds the stringified respresentation of the unsigned integer, value, to the end of the given GblStrin...
size_t GblStringBuffer_replace(GblStringBuffer *pSelf, const char *pSubstr, const char *pReplacement, size_t limit, size_t substrLen, size_t replLen)
Replaces limit instances (0 is infinite) of Substr with pReplacement, with both lenghts being optiona...
GblBool GblStringBuffer_blank(const GblStringBuffer *pSelf)
Returns GBL_TRUE if the given GblStringBuffer is empty or holds only spacing characters.
GBL_RESULT GblStringBuffer_acquire(GblStringBuffer *pSelf, char *pData, size_t capacity)
Transfers ownership of a given C string to the given buffer, assigning its value and updating its cap...
GBL_RESULT GblStringBuffer_trimStart(GblStringBuffer *pSelf, char value)
Removes any leading instances of value from the beginning of the given GblStringBuffer,...
GblContext * GblStringBuffer_context(const GblStringBuffer *pSelf)
Returns a pointer to the context the GblStringBuffer was created with.
GBL_RESULT GblStringBuffer_upper(GblStringBuffer *pSelf)
Changes the casing of every character within the GblStringBuffer to uppercase, returning a result cod...
GBL_RESULT GblStringBuffer_appendInt(GblStringBuffer *pSelf, int value)
Adds the stringified representation of the integer, value, to the end of the given GblStringBuffer,...
GblBool GblStringBuffer_empty(const GblStringBuffer *pSelf)
Returns GBL_TRUE if the given GblStringBuffer is empty, otherwise returns GBL_FALSE.
GBL_RESULT GblStringBuffer_appendFloat(GblStringBuffer *pSelf, float value)
Adds the stringified representation of the float, value, to the end of the given GblStringBuffer,...
GBL_RESULT GblStringBuffer_prepend(GblStringBuffer *pSelf, const char *pStr, size_t len)
Inserts pStr (with optional length, len) at the beginning of the given buffer, returning a result cod...
GBL_RESULT GblStringBuffer_chop(GblStringBuffer *pSelf)
Removes the last character from the given GblStringBuffer, returning a result code.
size_t GblStringBuffer_capacity(const GblStringBuffer *pSelf)
Returns the actual size of the internal data buffer held by the given GblStringBuffer.
GBL_RESULT GblStringBuffer_appendNil(GblStringBuffer *pSelf)
Adds the word "nil" to the end of the given GblStringBuffer, returning a result code.
GblStringView GblStringBuffer_view(const GblStringBuffer *pSelf, size_t offset, size_t len)
Creates a GblStringView containing either the whole buffer or a subsection of it.
GBL_RESULT GblStringBuffer_clear(GblStringBuffer *pSelf)
Clears the contents of the given GblStringBuffer, resetting it back to an empty state and returning a...
GBL_RESULT GblStringBuffer_shrinkToFit(GblStringBuffer *pSelf)
Shrinks the capacity of the given GblStringBuffer to match its length, if it doesn't already,...
const char * GblStringBuffer_cString(const GblStringBuffer *pSelf)
Returns a pointer to a constant NULL-terminated C string for the given GblStringBuffer.
GBL_RESULT GblStringBuffer_insert(GblStringBuffer *pSelf, size_t index, const char *pString, size_t length)
Inserts pString at the given index with optional length, returning a result code.
GblArrayList data
Internal storage buffer.
const char * GblStringBuffer_printf(GblStringBuffer *pSelf, const char *pFmt,...)
Assings the value of the formatted string to the given GblStringBuffer, similarly to C's sscanf()
const char * GblStringBuffer_vPrintf(GblStringBuffer *pSelf, const char *pFmt, va_list varArgs)
Equivalent to GblStringBuffer_printf(), except passing additional arguments via a va_list.
GBL_RESULT GblStringBuffer_overwrite(GblStringBuffer *pSelf, size_t index, const char *pString, size_t length)
Ovewrites a prtion of the string starting at index, with pString (length is optional),...
GBL_RESULT GblStringBuffer_grow(GblStringBuffer *pSelf, size_t delta)
Resizes the length of the given GblStringBuffer to be its current length + delta, returning a result ...
GBL_RESULT GblStringBuffer_setChar(const GblStringBuffer *pSelf, size_t index, char value)
Sets the character stored in the given buffer at index to value, returning an error upon failure.
GBL_RESULT GblStringBuffer_construct(GblStringBuffer *pSelf, const char *pString, size_t length, size_t structSize, GblContext *pCtx)
Constructs the given GblStringBuffer struct with any given initial values (or defaults),...
GblBool GblStringBuffer_stack(const GblStringBuffer *pSelf)
Returns GBL_TRUE if the given GblStringBuffer's internal buffer is on the stack and not heap.
GblQuark GblStringBuffer_tryQuark(const GblStringBuffer *pSelf)
Returns the GblQuark corresponding to the given GblStringBuffer only if it already exists.
GBL_RESULT GblStringBuffer_release(GblStringBuffer *pSelf, char **ppStrPtr, size_t *pCapacity)
Takes ownership of the given GblStringBuffer's internal buffer, also returning its capacity and a res...
GBL_RESULT GblStringBuffer_prependPadding(GblStringBuffer *pSelf, char value, size_t count)
Inserts count copies of value at the beginning of the given buffer, returning a result code.
GblQuark GblStringBuffer_quark(const GblStringBuffer *pSelf)
Converts the GblStringBuffer to a GblQuark, possibly interning it, and returning its GblQuark.
GBL_RESULT GblStringBuffer_reserve(GblStringBuffer *pSelf, size_t capacity)
Ensures that there is room for capacity characters within the given GblStringBuffer,...
char * GblStringBuffer_stackBuffer(const GblStringBuffer *pSelf)
Returns a mutable pointer to the extra stack storage region, if present.
GBL_RESULT GblStringBuffer_erase(GblStringBuffer *pSelf, size_t offset, size_t len)
Erases the portion of the string from offset to offset + len, resizing it, and returning a result cod...
GBL_RESULT GblStringBuffer_shrink(GblStringBuffer *pSelf, size_t delta)
Resizes the length of the given GblStringBuffer to be its current length - delta, returning a result ...
GBL_RESULT GblStringBuffer_reverse(GblStringBuffer *pSelf)
Reverses the order of the characters with the given GblStringBuffer, returninga result code.
GBL_RESULT GblStringBuffer_append(GblStringBuffer *pSelf, const char *pStr, size_t len)
Appends pStr (with optional length, len) to the given GblStringBuffer, returning a result code.
GBL_RESULT GblStringBuffer_appendPrintf(GblStringBuffer *pSelf, const char *pFmt,...)
Appends a printf()-style formatted string to the given GblStringBuffer, returning a result code.
GBL_RESULT GblStringBuffer_appendVPrintf(GblStringBuffer *pSelf, const char *pFmt, va_list varArgs)
Equivalent to GblStringBuffer_appendPrintf(), except additional arguments are provided as a va_list.
GBL_RESULT GblStringBuffer_trimEnd(GblStringBuffer *pSelf, char value)
Returns any trailing instances of value from the end of the given GblStringBuffer,...
GBL_RESULT GblStringBuffer_appendDouble(GblStringBuffer *pSelf, double value)
Adds the stringified representation of the double, value, to the end of the given GblStringBuffer,...
GBL_RESULT GblStringBuffer_appendBool(GblStringBuffer *pSelf, GblBool value)
Adds either "true" or "false" to the end of the given GblStringBuffer, depending on value,...
GBL_RESULT GblStringBuffer_lower(GblStringBuffer *pSelf)
Changes the casing of every character within the GblStringBuffer to lowercase, returning a result cod...
GBL_RESULT GblStringBuffer_chomp(GblStringBuffer *pSelf)
Removes any trailing newline characters (\r and \n) from the given GblStringBuffer,...
size_t GblStringBuffer_length(const GblStringBuffer *pSelf)
Returns the string length of the string held by the given GblStringBuffer.
const char * GblStringBuffer_intern(const GblStringBuffer *pSelf)
Returns a pointer to the interned string representation of the buffer, interning it if it hasn't been...
char GblStringBuffer_at(const GblStringBuffer *pSelf, size_t index)
Returns the character stored in the given buffer at index, throwing an error and returning '\0' if in...