2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
43#ifndef GIMBAL_STRING_REF_H
44#define GIMBAL_STRING_REF_H
48#define GBL_SELF_TYPE GblStringRef
53
54
55
56
57
58
59
60
64
65
66
78
79
80
98
99
100
112#define GblStringRef_create(...)
113 GblStringRef_createDefault_
(__VA_ARGS__)
114#define GblStringRef_createDefault_(...)
115 GblStringRef_createDefault__
(__VA_ARGS__, 0
, NULL
)
116#define GblStringRef_createDefault__(str, len, ctx, ...)
117 ((GblStringRef_create
)(str, len, ctx))
119#define GblStringRef_view(...)
120 GblStringRef_viewDefault_
(__VA_ARGS__)
121#define GblStringRef_viewDefault_(...)
122 GblStringRef_viewDefault__
(__VA_ARGS__, 0
, 0
)
123#define GblStringRef_viewDefault__(ref, offset, len, ...)
124 ((GblStringRef_view
)(ref, offset, len))
size_t GblStringRef_length(const GblStringRef *pSelf)
Returns the cached length of the given GblStringRef.
GblStringRef * GblStringRef_create(const char *pString, size_t len, GblContext *pCtx)
Creates and returns a reference containing pString, with optional length and context.
GblBool GblStringRef_blank(const GblStringRef *pSelf)
Returns whether the given GblStringRef is blank, containing only NULL or spacing characters.
GblBool GblStringRef_valid(const GblStringRef *pSelf)
Returns whether the given GblStringRef is valid (not NULL)
GblBool GblStringRef_empty(const GblStringRef *pSelf)
Returns whether the given GblStringRef is empty, with nothing but a NULL terminator.
char GblStringRef_at(const GblStringRef *pSelf, size_t idx)
Returns the character located at position idx, raising an error upon out-of-range.
GblContext * GblStringRef_context(const GblStringRef *pSelf)
Returns the GblContext that was created with the given GblStringRef.
GblRefCount GblStringRef_refCount(const GblStringRef *pSelf)
Returns the number of active references remaining to the given GblStringRef.
GblStringView GblStringRef_view(const GblStringRef *pSelf, size_t offset, size_t len)
Returns a GblStringView containing the character window given by offset and len.
GblRefCount GblStringRef_unref(const GblStringRef *pRef)
Releases a reference to pRef, freeing the allocation if it was the last, returning the new refCount.
GblHash GblStringRef_hash(const GblStringRef *pSelf)
Calculates and returns the 32-bit hash value associated with the givne GblStringRef.
GblStringRef * GblStringRef_ref(const GblStringRef *pRef)
Returns a new reference to pRef, incrementing its internal reference count rather than actually copyi...
uint32_t GblHash
Type representing a calculated numeric hash across the codebase.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
const char GblStringRef
Reference-counted, const char*-compatible string type.