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)
121//! Returns a pointer to a constant NULL-terminated C string for the given GblStringBuffer
123//! Returns a pointer to the interned string representation of the buffer, interning it if it hasn't been already
125//! Converts the GblStringBuffer to a GblQuark, possibly interning it, and returning its GblQuark
127//! Returns the GblQuark corresponding to the given GblStringBuffer only if it already exists
129//! Creates a GblStringView containing either the whole buffer or a subsection of it
131 size_t offset/*=0*/,
132 size_t len/*=0*/) GBL_NOEXCEPT;
133//! @}
134
135/*! \name Per-Character Access
136 * \brief Methods for getting and setting individual indices
137 * \relatesalso GblStringBuffer
138 * @{
139 */
140//! Returns the character stored in the given buffer at \p index, throwing an error and returning '\0' if invalid
142//! Sets the character stored in the given buffer at \p index to \p value, returning an error upon failure
143GBL_EXPORT GBL_RESULT GblStringBuffer_setChar (GBL_CSELF, size_t index, char value) GBL_NOEXCEPT;
144//! @}
145
146/*! \name Assignment
147 * \brief Methods for setting the value of a constructed string
148 * \relatesalso GblStringBuffer
149 * @{
150 */
151//! Assigns the value of the given GblStringBuffer to \p pStr, optionally taking its length, \p len
152GBL_EXPORT const char* GblStringBuffer_set (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
153//! Assings the value of the formatted string to the given GblStringBuffer, similarly to C's sscanf()
154GBL_EXPORT const char* GblStringBuffer_printf (GBL_SELF, const char* pFmt, ...) GBL_NOEXCEPT;
155//! Equivalent to GblStringBuffer_printf(), except passing additional arguments via a va_list
156GBL_EXPORT const char* GblStringBuffer_vPrintf (GBL_SELF, const char* pFmt, va_list varArgs) GBL_NOEXCEPT;
157//! @}
158
159/*! \name Prepending
160 * \brief Methods for adding to the beginning of the a string
161 * \relatesalso GblStringBuffer
162 * @{
163 */
164//! Inserts \p pStr (with optional length, \p len) at the beginning of the given buffer, returning a result code
165GBL_EXPORT GBL_RESULT GblStringBuffer_prepend (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
166//! Inserts \p count copies of \p value at the beginning of the given buffer, returning a result code
167GBL_EXPORT GBL_RESULT GblStringBuffer_prependPadding (GBL_SELF, char value, size_t count) GBL_NOEXCEPT;
168//! @}
169
170/*! \name Appending
171 * \brief Methods for adding to the end of a string
172 * \relatesalso GblStringBuffer
173 * @{
174 */
175//! Appends \p pStr (with optional length, \p len) to the given GblStringBuffer, returning a result code
176GBL_EXPORT GBL_RESULT GblStringBuffer_append (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
177//! Appends a printf()-style formatted string to the given GblStringBuffer, returning a result code
179//! Equivalent to GblStringBuffer_appendPrintf(), except additional arguments are provided as a va_list
180GBL_EXPORT GBL_RESULT GblStringBuffer_appendVPrintf (GBL_SELF, const char* pFmt, va_list varArgs) GBL_NOEXCEPT;
181//! Adds \p count copies of \p value to the end of the given GblStringBuffer, returning a result code
182GBL_EXPORT GBL_RESULT GblStringBuffer_appendPadding (GBL_SELF, char value, size_t count) GBL_NOEXCEPT;
183//! Adds the word "nil" to the end of the given GblStringBuffer, returning a result code
185//! Adds either "true" or "false" to the end of the given GblStringBuffer, depending on \p value, and returning a result code
187//! Adds the stringified representation of the integer, \p value, to the end of the given GblStringBuffer, returning a result code
189//! Adds the stringified respresentation of the unsigned integer, \p value, to the end of the given GblStringBuffer, returning a result code
191//! Adds the stringified representation of the float, \p value, to the end of the given GblStringBuffer, returning a result code
193//! Adds the stringified representation of the double, \p value, to the end of the given GblStringBuffer, returning a result code
195//! Adds the hexadecimal string representation of the pointer, \p pPtr, to the end of the given GblStringBuffer, returning a result code
197//! @}
198
199/*! \name Modifying
200 * \brief Methods for general string modifications
201 * \relatesalso GblStringBuffer
202 * @{
203 */
204//! Inserts \p pString at the given \p index with optional \p length, returning a result code
206 size_t index,
207 const char* pString,
208 size_t length/*=0*/) GBL_NOEXCEPT;
209//! 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
211 size_t index,
212 const char* pString,
213 size_t length/*=0*/) GBL_NOEXCEPT;
214//! Replaces \p limit instances (0 is infinite) of \p Substr with \p pReplacement, with both lenghts being optional, and returning a result code
216 const char* pSubstr,
217 const char* pReplacement,
218 size_t limit/*=0*/,
219 size_t substrLen/*=0*/,
220 size_t replLen/*=0*/) GBL_NOEXCEPT;
221//! @}
222
223/*! \name Removing
224 * \brief Methods for erasing portions of a string
225 * \relatesalso GblStringBuffer
226 * @{
227 */
228//! Erases the portion of the string from \p offset to \p offset + \p len, resizing it, and returning a result code
229GBL_EXPORT GBL_RESULT GblStringBuffer_erase (GBL_SELF, size_t offset, size_t len) GBL_NOEXCEPT;
230//! Clears the contents of the given GblStringBuffer, resetting it back to an empty state and returning a result code
232//! Removes all instances of \p pStr (\p len is optional) from the given buffer, returning the number of entries removed
233GBL_EXPORT size_t GblStringBuffer_remove (GBL_SELF, const char* pStr, size_t len/*=0*/) GBL_NOEXCEPT;
234//! Removes the last character from the given GblStringBuffer, returning a result code
236//! Removes any trailing newline characters (`\r` and `\n`) from the given GblStringBuffer, returning a result code
238//! Removes any leading instances of \p value from the beginning of the given GblStringBuffer, returning a result code
240//! Returns any trailing instances of \p value from the end of the given GblStringBuffer, returning a result code
242//! @}
243
244/*! \name Miscellaneous
245 * \brief Methods for other utilities and string operations
246 * \relatesalso GblStringBuffer
247 * @{
248 */
249//! Changes the casing of every character within the GblStringBuffer to lowercase, returning a result code
251//! Changes the casing of every character within the GblStringBuffer to uppercase, returning a result code
253//! Reverses the order of the characters with the given GblStringBuffer, returninga result code
255//! @}
256
257/*! \name Sizing
258 * \brief Methods for managing size and capacity
259 * \relatesalso GblStringBuffer
260 * @{
261 */
262//! Ensures that there is room for \p capacity characters within the given GblStringBuffer, returning a result code
264//! Sets the length of the given GblStringBuffer to \p size, regrowing if necessary, but not shrinking, and returning a result code
266//! Resizes the length of the given GblStringBuffer to be its current length + \p delta, returning a result code
268//! Resizes the length of the given GblStringBuffer to be its current length - \p delta, returning a result code
270//! Shrinks the capacity of the given GblStringBuffer to match its length, if it doesn't already, returning a result code
272//! @}
273
275
276//! \cond
277#define GblStringBuffer_construct(...)
278 GBL_VA_OVERLOAD_CALL_ARGC(GblStringBuffer_construct, __VA_ARGS__)
279#define GblStringBuffer_construct_1(self)
280 GblStringBuffer_construct_2(self, "")
281#define GblStringBuffer_construct_2(self, str)
282 GblStringBuffer_construct_3(self, str, 0)
283#define GblStringBuffer_construct_3(self, str, len)
284 GblStringBuffer_construct_4(self, str, len, sizeof(GblStringBuffer))
285#define GblStringBuffer_construct_4(self, str, len, size)
286 GblStringBuffer_construct_5(self, str, len, size, GBL_NULL)
287#define GblStringBuffer_construct_5(self, str, len, size, ctx)
288 ((GblStringBuffer_construct(self, str, len, size, ctx)))
289
290#define GblStringBuffer_view(...)
291 GblStringBuffer_viewDefault_(__VA_ARGS__)
292#define GblStringBuffer_viewDefault_(...)
293 GblStringBuffer_viewDefault__(__VA_ARGS__, 0, 0)
294#define GblStringBuffer_viewDefault__(buffer, offset, length, ...)
295 ((GblStringBuffer_view)(buffer, offset, length))
296
297#define GblStringBuffer_set(...)
298 GblStringBuffer_setDefault_(__VA_ARGS__)
299#define GblStringBuffer_setDefault_(...)
300 GblStringBuffer_setDefault__(__VA_ARGS__, 0)
301#define GblStringBuffer_setDefault__(buffer, str, len, ...)
302 ((GblStringBuffer_set)(buffer, str, len))
303
304#define GblStringBuffer_insert(...)
305 GblStringBuffer_insertDefault_(__VA_ARGS__)
306#define GblStringBuffer_insertDefault_(...)
307 GblStringBuffer_insertDefault__(__VA_ARGS__, 0)
308#define GblStringBuffer_insertDefault__(buffer, offset, str, len, ...)
309 ((GblStringBuffer_insert)(buffer, offset, str, len))
310
311#define GblStringBuffer_append(...)
312 GblStringBuffer_appendDefault_(__VA_ARGS__)
313#define GblStringBuffer_appendDefault_(...)
314 GblStringBuffer_appendDefault__(__VA_ARGS__, 0)
315#define GblStringBuffer_appendDefault__(buffer, str, len, ...)
316 ((GblStringBuffer_append)(buffer, str, len))
317
318#define GblStringBuffer_prepend(...)
319 GblStringBuffer_prependDefault_(__VA_ARGS__)
320#define GblStringBuffer_prependDefault_(...)
321 GblStringBuffer_prependDefault__(__VA_ARGS__, 0)
322#define GblStringBuffer_prependDefault__(buffer, str, len, ...)
323 ((GblStringBuffer_prepend)(buffer, str, len))
324
325#define GblStringBuffer_overwrite(...)
326 GblStringBuffer_overwriteDefault_(__VA_ARGS__)
327#define GblStringBuffer_overwriteDefault_(...)
328 GblStringBuffer_overwriteDefault__(__VA_ARGS__, 0)
329#define GblStringBuffer_overwriteDefault__(buffer, offset, str, len, ...)
330 ((GblStringBuffer_overwrite)(buffer, offset, str, len))
331
332#define GblStringBuffer_remove(...)
333 GblStringBuffer_removeDefault_(__VA_ARGS__)
334#define GblStringBuffer_removeDefault_(...)
335 GblStringBuffer_removeDefault__(__VA_ARGS__, 0)
336#define GblStringBuffer_removeDefault__(buffer, str, len, ...)
337 ((GblStringBuffer_remove)(buffer, str, len))
338
339#define GblStringBuffer_replace(...)
340 GblStringBuffer_replaceDefault_(__VA_ARGS__)
341#define GblStringBuffer_replaceDefault_(...)
342 GblStringBuffer_replaceDefault__(__VA_ARGS__, 0, 0, 0)
343#define GblStringBuffer_replaceDefault__(buffer, substr, repl, count, substrLen, replLen, ...)
344 (GblStringBuffer_replace(buffer, substr, repl, count, substrLen, replLen))
345//! \endcond
346
347#undef GBL_SELF_TYPE
348
349#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 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.
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...
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...