ZYCORE_EXPORTZyanStatusZyanStringAppend(ZyanString*destination,constZyanStringView*source)
Appends the content of the source string to the end of the destination string.
Parametersdestination The destination string.
source The source string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringAppendEx(ZyanString*destination,constZyanStringView*source,ZyanUSizesource_index,ZyanUSizecount)
Appends count characters of the source string to the end of the destination string.
Parametersdestination The destination string.
source The source string.
source_index The index of the first character to be appended from the source string.
count The number of chars to append from the source string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringClear(ZyanString*string)
Erases the given string.
Parametersstring A pointer to the ZyanString instance.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringCompare(constZyanStringView*s1,constZyanStringView*s2,ZyanI32*result)
Compares two strings.
Parameterss1 The first string
s2 The second string.
result Receives the comparison result.
Values:
- `result < 0` -> The first character that does not match has a lower value
in `s1` than in `s2`.
- `result == 0` -> The contents of both strings are equal.
- `result > 0` -> The first character that does not match has a greater value
in `s1` than in `s2`.
Returns
ZYAN_STATUS_TRUE, if the strings are equal, ZYAN_STATUS_FALSE, if not, or another zyan status code,
if an error occurred.
ZYCORE_EXPORTZyanStatusZyanStringCompareI(constZyanStringView*s1,constZyanStringView*s2,ZyanI32*result)
Performs a case-insensitive comparison of two strings.
Parameterss1 The first string
s2 The second string.
result Receives the comparison result.
Values:
- `result < 0` -> The first character that does not match has a lower value
in `s1` than in `s2`.
- `result == 0` -> The contents of both strings are equal.
- `result > 0` -> The first character that does not match has a greater value
in `s1` than in `s2`.
Returns
ZYAN_STATUS_TRUE, if the strings are equal, ZYAN_STATUS_FALSE, if not, or another zyan status code,
if an error occurred.
ZYCORE_EXPORTZYAN_REQUIRES_LIBCZyanStatusZyanStringConcat(ZyanString*destination,constZyanStringView*s1,constZyanStringView*s2,ZyanUSizecapacity)
Initializes a new ZyanString instance by concatenating two existing strings.
Parametersdestination A pointer to the (uninitialized) destination ZyanString instance.
This function will fail, if the destination `ZyanString` instance equals
one of the source strings.
s1 A pointer to the first source string.
s2 A pointer to the second source string.
capacity The initial capacity (number of characters).
This value is automatically adjusted to the combined size of the source
strings, if a smaller value was passed.
Returns
A zyan status code.
The behavior of this function is undefined, if s1 or s2 are views into the destination string or
destination points to an already initialized ZyanString instance.
The memory for the string is dynamically allocated by the default allocator using the default growth
factor and the default shrink threshold.
The allocated buffer will be at least one character larger than the given capacity, to reserve space for
the terminating '\0'.
Finalization with ZyanStringDestroy is required for all strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringConcatCustomBuffer(ZyanString*destination,constZyanStringView*s1,constZyanStringView*s2,char*buffer,ZyanUSizecapacity)
Initializes a new ZyanString instance by concatenating two existing strings and configures it to use a
custom user defined buffer with a fixed size.
Parametersdestination A pointer to the (uninitialized) destination ZyanString instance.
This function will fail, if the destination `ZyanString` instance equals
one of the source strings.
s1 A pointer to the first source string.
s2 A pointer to the second source string.
buffer A pointer to the buffer that is used as storage for the string.
capacity The maximum capacity (number of characters) of the buffer.
This function will fail, if the capacity of the buffer is less or equal to
the combined size of the source strings.
Returns
A zyan status code.
The behavior of this function is undefined, if s1 or s2 are views into the destination string or
destination points to an already initialized ZyanString instance.
Finalization is not required for strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringConcatEx(ZyanString*destination,constZyanStringView*s1,constZyanStringView*s2,ZyanUSizecapacity,ZyanAllocator*allocator,ZyanU8growth_factor,ZyanU8shrink_threshold)
Initializes a new ZyanString instance by concatenating two existing strings and sets a custom allocator
and memory allocation/deallocation parameters.
Parametersdestination A pointer to the (uninitialized) destination ZyanString instance.
This function will fail, if the destination `ZyanString` instance
equals one of the source strings.
s1 A pointer to the first source string.
s2 A pointer to the second source string.
capacity The initial capacity (number of characters).
This value is automatically adjusted to the combined size of the
source strings, if a smaller value was passed.
allocator A pointer to a ZyanAllocator instance.
growth_factor The growth factor.
shrink_threshold The shrink threshold.
Returns
A zyan status code.
The behavior of this function is undefined, if s1 or s2 are views into the destination string or
destination points to an already initialized ZyanString instance.
A growth factor of 1 disables overallocation and a shrink threshold of 0 disables dynamic shrinking.
The allocated buffer will be at least one character larger than the given capacity, to reserve space for
the terminating '\0'.
Finalization with ZyanStringDestroy is required for all strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringDelete(ZyanString*string,ZyanUSizeindex,ZyanUSizecount)
Deletes characters from the given string, starting at index.
Parametersstring A pointer to the ZyanString instance.
index The index of the first character to delete.
count The number of characters to delete.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringDestroy(ZyanString*string)
Destroys the given ZyanString instance.
Parametersstring A pointer to the ZyanString instance.
Returns
A zyan status code.
ZYCORE_EXPORTZYAN_REQUIRES_LIBCZyanStatusZyanStringDuplicate(ZyanString*destination,constZyanStringView*source,ZyanUSizecapacity)
Initializes a new ZyanString instance by duplicating an existing string.
Parametersdestination A pointer to the (uninitialized) destination ZyanString instance.
source A pointer to the source string.
capacity The initial capacity (number of characters).
This value is automatically adjusted to the size of the source string, if
a smaller value was passed.
Returns
A zyan status code.
The behavior of this function is undefined, if source is a view into the destination string or
destination points to an already initialized ZyanString instance.
The memory for the string is dynamically allocated by the default allocator using the default growth
factor and the default shrink threshold.
The allocated buffer will be at least one character larger than the given capacity, to reserve space for
the terminating '\0'.
Finalization with ZyanStringDestroy is required for all strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringDuplicateCustomBuffer(ZyanString*destination,constZyanStringView*source,char*buffer,ZyanUSizecapacity)
Initializes a new ZyanString instance by duplicating an existing string and configures it to use a custom
user defined buffer with a fixed size.
Parametersdestination A pointer to the (uninitialized) destination ZyanString instance.
source A pointer to the source string.
buffer A pointer to the buffer that is used as storage for the string.
capacity The maximum capacity (number of characters) of the buffer, including the terminating '\0'.
This function will fail, if the capacity of the buffer is less or equal to the size of the source string.
Returns
A zyan status code.
The behavior of this function is undefined, if source is a view into the destination string or
destination points to an already initialized ZyanString instance.
Finalization is not required for strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringDuplicateEx(ZyanString*destination,constZyanStringView*source,ZyanUSizecapacity,ZyanAllocator*allocator,ZyanU8growth_factor,ZyanU8shrink_threshold)
Initializes a new ZyanString instance by duplicating an existing string and sets a custom allocator and
memory allocation/deallocation parameters.
Parametersdestination A pointer to the (uninitialized) destination ZyanString instance.
source A pointer to the source string.
capacity The initial capacity (number of characters).
This value is automatically adjusted to the size of the source
string, if a smaller value was passed.
allocator A pointer to a ZyanAllocator instance.
growth_factor The growth factor.
shrink_threshold The shrink threshold.
Returns
A zyan status code.
The behavior of this function is undefined, if source is a view into the destination string or
destination points to an already initialized ZyanString instance.
A growth factor of 1 disables overallocation and a shrink threshold of 0 disables dynamic shrinking.
The allocated buffer will be at least one character larger than the given capacity, to reserve space for
the terminating '\0'.
Finalization with ZyanStringDestroy is required for all strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringGetCapacity(constZyanString*string,ZyanUSize*capacity)
Returns the current capacity of the string.
Parametersstring A pointer to the ZyanString instance.
capacity Receives the size of the string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringGetChar(constZyanStringView*string,ZyanUSizeindex,char*value)
Returns the character at the given index.
Parametersstring A pointer to the ZyanStringView instance.
index The character index.
value Receives the desired character of the string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringGetCharMutable(ZyanString*string,ZyanUSizeindex,char**value)
Returns a pointer to the character at the given index.
Parametersstring A pointer to the ZyanString instance.
index The character index.
value Receives a pointer to the desired character in the string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringGetData(constZyanString*string,constchar**value)
Returns the C-style string of the given ZyanString instance.
Parametersstring A pointer to the ZyanString instance.
value Receives a pointer to the C-style string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringGetSize(constZyanString*string,ZyanUSize*size)
Returns the current size (number of characters) of the string (excluding the terminating zero character).
Parametersstring A pointer to the ZyanString instance.
size Receives the size (number of characters) of the string.
Returns
A zyan status code.
ZYCORE_EXPORTZYAN_REQUIRES_LIBCZyanStatusZyanStringInit(ZyanString*string,ZyanUSizecapacity)
Initializes the given ZyanString instance.
Parametersstring A pointer to the ZyanString instance.
capacity The initial capacity (number of characters).
Returns
A zyan status code.
The memory for the string is dynamically allocated by the default allocator using the default growth
factor and the default shrink threshold.
The allocated buffer will be at least one character larger than the given capacity, to reserve space for
the terminating '\0'.
Finalization with ZyanStringDestroy is required for all strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringInitCustomBuffer(ZyanString*string,char*buffer,ZyanUSizecapacity)
Initializes the given ZyanString instance and configures it to use a custom user defined buffer with a
fixed size.
Parametersstring A pointer to the ZyanString instance.
buffer A pointer to the buffer that is used as storage for the string.
capacity The maximum capacity (number of characters) of the buffer, including the terminating '\0'.
Returns
A zyan status code.
Finalization is not required for strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringInitEx(ZyanString*string,ZyanUSizecapacity,ZyanAllocator*allocator,ZyanU8growth_factor,ZyanU8shrink_threshold)
Initializes the given ZyanString instance and sets a custom allocator and memory allocation/deallocation
parameters.
Parametersstring A pointer to the ZyanString instance.
capacity The initial capacity (number of characters).
allocator A pointer to a ZyanAllocator instance.
growth_factor The growth factor.
shrink_threshold The shrink threshold.
Returns
A zyan status code.
A growth factor of 1 disables overallocation and a shrink threshold of 0 disables dynamic shrinking.
The allocated buffer will be at least one character larger than the given capacity, to reserve space for
the terminating '\0'.
Finalization with ZyanStringDestroy is required for all strings created by this function.
ZYCORE_EXPORTZyanStatusZyanStringInsert(ZyanString*destination,ZyanUSizeindex,constZyanStringView*source)
Inserts the content of the source string in the destination string at the given index.
Parametersdestination The destination string.
index The insert index.
source The source string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringInsertEx(ZyanString*destination,ZyanUSizedestination_index,constZyanStringView*source,ZyanUSizesource_index,ZyanUSizecount)
Inserts count characters of the source string in the destination string at the given index.
Parametersdestination The destination string.
destination_index The insert index.
source The source string.
source_index The index of the first character to be inserted from the source string.
count The number of chars to insert from the source string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringLPos(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index)
Searches for the first occurrence of needle in the given haystack starting from the left.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occured.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringLPosEx(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index,ZyanUSizeindex,ZyanUSizecount)
Searches for the first occurrence of needle in the given haystack starting from the left.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
index The start index.
count The maximum number of characters to iterate, beginning from the start index.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occured.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringLPosI(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index)
Performs a case-insensitive search for the first occurrence of needle in the given haystack starting from
the left.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occured.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringLPosIEx(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index,ZyanUSizeindex,ZyanUSizecount)
Performs a case-insensitive search for the first occurrence of needle in the given haystack starting from
the left.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
index The start index.
count The maximum number of characters to iterate, beginning from the start index.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occurred.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringReserve(ZyanString*string,ZyanUSizecapacity)
Changes the capacity of the given ZyanString instance.
Parametersstring A pointer to the ZyanString instance.
capacity The new minimum capacity of the string.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringResize(ZyanString*string,ZyanUSizesize)
Resizes the given ZyanString instance.
Parametersstring A pointer to the ZyanString instance.
size The new size of the string.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringRPos(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index)
Searches for the first occurrence of needle in the given haystack starting from the right.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occurred.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringRPosEx(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index,ZyanUSizeindex,ZyanUSizecount)
Searches for the first occurrence of needle in the given haystack starting from the right.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
index The start index.
count The maximum number of characters to iterate, beginning from the start index.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occurred.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringRPosI(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index)
Performs a case-insensitive search for the first occurrence of needle in the given haystack starting from
the right.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occurred.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringRPosIEx(constZyanStringView*haystack,constZyanStringView*needle,ZyanISize*found_index,ZyanUSizeindex,ZyanUSizecount)
Performs a case-insensitive search for the first occurrence of needle in the given haystack starting from
the right.
Parametershaystack The string to search in.
needle The sub-string to search for.
found_index A pointer to a variable that receives the index of the first occurrence of needle.
index The start index.
count The maximum number of characters to iterate, beginning from the start index.
Returns
ZYAN_STATUS_TRUE, if the needle was found, ZYAN_STATUS_FALSE, if not, or another zyan status code, if
an error occurred.
The found_index is set to -1, if the needle was not found.
ZYCORE_EXPORTZyanStatusZyanStringSetChar(ZyanString*string,ZyanUSizeindex,charvalue)
Assigns a new value to the character at the given index.
Parametersstring A pointer to the ZyanString instance.
index The character index.
value The character to assign.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringShrinkToFit(ZyanString*string)
Shrinks the capacity of the given string to match it's size.
Parametersstring A pointer to the ZyanString instance.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringToLowerCase(ZyanString*string)
Converts the given string to lowercase letters.
Parametersstring A pointer to the ZyanString instance.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringToLowerCaseEx(ZyanString*string,ZyanUSizeindex,ZyanUSizecount)
Converts count characters of the given string to lowercase letters.
Parametersstring A pointer to the ZyanString instance.
index The start index.
count The number of characters to convert, beginning from the start index.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringToUpperCase(ZyanString*string)
Converts the given string to uppercase letters.
Parametersstring A pointer to the ZyanString instance.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringToUpperCaseEx(ZyanString*string,ZyanUSizeindex,ZyanUSizecount)
Converts count characters of the given string to uppercase letters.
Parametersstring A pointer to the ZyanString instance.
index The start index.
count The number of characters to convert, beginning from the start index.
Returns
A zyan status code.
This function will fail, if the ZYAN_STRING_IS_IMMUTABLE flag is set for the specified ZyanString
instance.
ZYCORE_EXPORTZyanStatusZyanStringTruncate(ZyanString*string,ZyanUSizeindex)
Deletes all remaining characters from the given string, starting at index.
Parametersstring A pointer to the ZyanString instance.
index The index of the first character to delete.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringViewGetData(constZyanStringView*view,constchar**buffer)
Returns the C-style string of the given ZyanString instance.
Warning
The string is not guaranteed to be null terminated!
Parametersview A pointer to the ZyanStringView instance.
buffer Receives a pointer to the C-style string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringViewGetSize(constZyanStringView*view,ZyanUSize*size)
Returns the size (number of characters) of the view.
Parametersview A pointer to the ZyanStringView instance.
size Receives the size (number of characters) of the view.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringViewInsideBuffer(ZyanStringView*view,constchar*string)
Returns a view inside a null-terminated C-style string.
Parametersview A pointer to the ZyanStringView instance.
string The C-style string.
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringViewInsideBufferEx(ZyanStringView*view,constchar*buffer,ZyanUSizelength)
Returns a view inside a character buffer with custom length.
Parametersview A pointer to the ZyanStringView instance.
buffer A pointer to the buffer containing the string characters.
length The length of the string (number of characters).
Returns
A zyan status code.
ZYCORE_EXPORTZyanStatusZyanStringViewInsideView(ZyanStringView*view,constZyanStringView*source)
Returns a view inside an existing view/string.
Parametersview A pointer to the ZyanStringView instance.
source A pointer to the source string.
Returns
A zyan status code.
The ZYAN_STRING_TO_VEW macro can be used to pass any ZyanString instance as value for the source string.
ZYCORE_EXPORTZyanStatusZyanStringViewInsideViewEx(ZyanStringView*view,constZyanStringView*source,ZyanUSizeindex,ZyanUSizecount)
Returns a view inside an existing view/string starting from the given index.
Parametersview A pointer to the ZyanStringView instance.
source A pointer to the source string.
index The start index.
count The number of characters.
Returns
A zyan status code.
The ZYAN_STRING_TO_VEW macro can be used to pass any ZyanString instance as value for the source string.