include/Cnx/String.h file

This module provides string and stringview types comparable to C++ for Cnx.

MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Classes

struct CnxStringView
Cnx stringview type. A stringview is a "view" into a CnxString. It allows you to lazily inspect the contents of the string, but not modify them. It is effectively a fat pointer into the contents of the associated CnxString
struct CnxString
Cnx string type CnxString is a bounds safe, allocator aware, potentially dynamically allocated string type with significantly improved ergonomics over const char*s (aka cstrings), but maintains compatibility with them (CnxString is always null terminated). Provides similar functionality to C++'s std::string, but in C.
struct CnxStringIterator
Cnx string iterator storage type CnxStringIterator is the underlying storage type used by CnxString for its non-const iterator type (CnxRandomAccessIterator(char_ptr))
struct CnxStringConstIterator
Cnx string const iterator storage type CnxStringIterator is the underlying storage type used by CnxString for its const iterator type (CnxRandomAccessIterator(const_char_ptr))
struct CnxStringViewIterator
Cnx stringview const iterator storage type CnxStringViewIterator is the underlying storage type used by CnxStringView for its const iterator type (CnxRandomAccessIterator(const_char_ptr))
struct cnx_stringview_vtable_t
The function vector table of methods associated with CnxStringView
struct cnx_string_vtable_t
The function vector table of methods associated with CnxString

Typedefs

using cnx_stringview_vtable_t = struct cnx_stringview_vtable_t
The function vector table of methods associated with CnxStringView
using CnxStringView = struct CnxStringView
Cnx stringview type. A stringview is a "view" into a CnxString. It allows you to lazily inspect the contents of the string, but not modify them. It is effectively a fat pointer into the contents of the associated CnxString
using cnx_string_vtable_t = struct cnx_string_vtable_t
The function vector table of methods associated with CnxString
using CnxString = struct CnxString
Cnx string type CnxString is a bounds safe, allocator aware, potentially dynamically allocated string type with significantly improved ergonomics over const char*s (aka cstrings), but maintains compatibility with them (CnxString is always null terminated). Provides similar functionality to C++'s std::string, but in C.
using CnxStringIterator = struct CnxStringIterator
Cnx string iterator storage type CnxStringIterator is the underlying storage type used by CnxString for its non-const iterator type (CnxRandomAccessIterator(char_ptr))
using CnxStringConstIterator = struct CnxStringConstIterator
Cnx string const iterator storage type CnxStringIterator is the underlying storage type used by CnxString for its const iterator type (CnxRandomAccessIterator(const_char_ptr))
using CnxStringViewIterator = struct CnxStringViewIterator
Cnx stringview const iterator storage type CnxStringViewIterator is the underlying storage type used by CnxStringView for its const iterator type (CnxRandomAccessIterator(const_char_ptr))
using Ref = CnxString*(CnxString)
type alias for a reference to CnxString
using ConstRef = const CnxString*(CnxString)
type alias for a const reference to CnxString

Functions

DeclCnxIterators(Ref(CnxString))
Declares iterator types for Ref(CnxString)
DeclCnxIterators(ConstRef(CnxString))
Declares iterator types for ConstRef(CnxString)
DeclCnxIterators(Ref(CnxStringView))
Declares iterator types for Ref(CnxStringView)
DeclCnxIterators(ConstRef(CnxStringView))
Declares iterator types for ConstRef(CnxStringView)
CnxString cnx_string_new(void)
Creates a new, empty CnxString
CnxString cnx_string_new_with_allocator(CnxAllocator allocator)
Creates a new, empty CnxString that will use the given allocator.
CnxString cnx_string_new_with_capacity(usize capacity)
Creates a new CnxString with the given initial capacity.
CnxString cnx_string_new_with_capacity_with_allocator(usize capacity, CnxAllocator allocator)
Creates a new CnxString with the given initial capacity.
CnxString cnx_string_from_cstring(restrict const_cstring string, usize length) cnx_disable_if(!string
Creates a new CnxString from the given cstring
CnxString cnx_string_from_cstring_with_allocator(restrict const_cstring string, usize length, CnxAllocator allocator) cnx_disable_if(!string
Creates a new CnxString from the given cstring
CnxString cnx_string_from_wcstring(restrict const_wcstring string, usize length) cnx_disable_if(!string
Creates a new CnxString from the given wcstring
CnxString cnx_string_from_wcstring_with_allocator(restrict const_wcstring string, usize length, CnxAllocator allocator) cnx_disable_if(!string
Creates a new CnxString from the given wcstring
CnxString cnx_string_from_stringview(const CnxStringView*restrict view) cnx_disable_if(!view
Creates a new CnxString from the given CnxStringView
CnxString cnx_string_from_stringview_with_allocator(const CnxStringView*restrict view, CnxAllocator allocator) cnx_disable_if(!view
Creates a new CnxString that will use the given memory allocator, from the given CnxStringView
const_cstring cnx_string_into_cstring(const CnxString*restrict self)
Returns the cstring representation of this CnxString
const_wcstring cnx_string_into_wcstring(const CnxString*restrict self)
Returns the wcstring converted representation of this CnxString. The result will be allocated with the same allocator used by this CnxString
const_wcstring cnx_string_into_wcstring_with_allocator(const CnxString*restrict self, CnxAllocator allocator)
Returns the wcstring converted representation of this CnxString, allocated with the given allocator;.
CnxStringView cnx_string_into_stringview(const CnxString*restrict self)
Returns a CnxStringView into this CnxString
CnxString cnx_string_clone(const CnxString*restrict self)
Creates a copy of this CnxString using the same allocator.
CnxString cnx_string_clone_with_allocator(const CnxString*restrict self, CnxAllocator allocator)
Creates a copy of this CnxString using the given allocator.
void cnx_string_free(void*restrict self)
Frees the allocated memory of the string, if it is not small string optimized.
char_ptr cnx_string_at_mut(CnxString*restrict self, usize index)
Returns a pointer to the character at the given index.
const_char_ptr cnx_string_at_const(const CnxString*restrict self, usize index)
Returns a pointer to the character at the given index.
char_ptr cnx_string_front_mut(CnxString*restrict self)
Returns the character at the beginning of the string.
const_char_ptr cnx_string_front_const(const CnxString*restrict self)
Returns the character at the beginning of the string.
char_ptr cnx_string_back_mut(CnxString*restrict self)
Returns the character at the end of the string.
const_char_ptr cnx_string_back_const(const CnxString*restrict self)
Returns the character at the end of the string.
bool cnx_string_is_empty(const CnxString*restrict self)
Returns whether the string is empty or not.
bool cnx_string_is_full(const CnxString*restrict self)
Returns whether the string contains capacity number of characters.
usize cnx_string_size(const CnxString*restrict self)
Returns the current size of the string.
usize cnx_string_length(const CnxString*restrict self)
Returns the current length of the string.
usize cnx_string_max_size(void)
Returns the maximum possible size of a CnxString
usize cnx_string_capacity(const CnxString*restrict self)
Returns the current capacity of the string.
CnxString cnx_string_first(const CnxString*restrict self, usize num_chars) cnx_disable_if(num_chars
Returns the first num_chars characters in the string as a new CnxString
cstring cnx_string_first_cstring(const CnxString*restrict self, usize num_chars) cnx_disable_if(num_chars
Returns the first num_chars characters in the string as a cstring allocated with the allocator associated with self
CnxStringView cnx_string_first_stringview(const CnxString*restrict self, usize num_chars) cnx_disable_if(num_chars
Returns the first num_chars characters in the string as a CnxStringView
CnxString cnx_string_last(const CnxString*restrict self, usize num_chars) cnx_disable_if(num_chars
Returns the last num_chars characters in the string as a new CnxString
cstring cnx_string_last_cstring(const CnxString*restrict self, usize num_chars) cnx_disable_if(num_chars
Returns the last num_chars characters in the string as a cstring allocated with the allocator associated with self
CnxStringView cnx_string_last_stringview(const CnxString*restrict self, usize num_chars) cnx_disable_if(num_chars
Returns the last num_chars characters in the string as a CnxStringView
bool cnx_string_equal(const CnxString*restrict self, const CnxString*restrict to_compare) cnx_disable_if(!to_compare
Determines if the given strings are equal.
bool cnx_string_equal_cstring(const CnxString*restrict self, restrict const_cstring to_compare, usize length) cnx_disable_if(!to_compare
Determines if the given strings are equal.
bool cnx_string_equal_stringview(const CnxString*restrict self, const CnxStringView*restrict to_compare) cnx_disable_if(!to_compare
Determines if the given strings are equal.
bool cnx_string_contains(const CnxString*restrict self, const CnxString*restrict substring) cnx_disable_if(!substring
Determines if the string contains the given substring.
bool cnx_string_contains_cstring(const CnxString*restrict self, restrict const_cstring substring, usize substring_length) cnx_disable_if(!substring
Determines if the string contains the given substring.
bool cnx_string_contains_stringview(const CnxString*restrict self, const CnxStringView*restrict substring) cnx_disable_if(!substring
Determines if the string contains the given substring.
bool cnx_string_starts_with(const CnxString*restrict self, const CnxString*restrict substring) cnx_disable_if(!substring
Determines if the string begins with the given substring.
bool cnx_string_starts_with_cstring(const CnxString*restrict self, restrict const_cstring substring, usize substring_length) cnx_disable_if(!substring
Determines if the string begins with the given substring.
bool cnx_string_starts_with_stringview(const CnxString*restrict self, const CnxStringView*restrict substring) cnx_disable_if(!substring
Determines if the string begins with the given substring.
bool cnx_string_ends_with(const CnxString*restrict self, const CnxString*restrict substring) cnx_disable_if(!substring
Determines if the string ends with the given substring.
bool cnx_string_ends_with_cstring(const CnxString*restrict self, restrict const_cstring substring, usize substring_length) cnx_disable_if(!substring
Determines if the string ends with the given substring.
bool cnx_string_ends_with_stringview(const CnxString*restrict self, const CnxStringView*restrict substring) cnx_disable_if(!substring
Determines if the string ends with the given substring.
CnxOption(usize) cnx_string_find_first(const CnxString *restrict self
Returns the index of the first occurrence of the given substring, or None if the substring does not occur.
CnxString cnx_string_substring(const CnxString*restrict self, usize index, usize length)
Returns the length length substring beginning at index
CnxString cnx_string_substring_with_allocator(const CnxString*restrict self, usize index, usize length, CnxAllocator allocator)
Returns the length length substring beginning at index, allocated with the given allocator.
CnxStringView cnx_string_stringview_of(const CnxString*restrict self, usize index, usize length)
Returns a CnxStringView into self of the range [index, index + length)
CnxString cnx_string_concatenate(const CnxString*restrict left, const CnxString*restrict right) cnx_disable_if(!right
Concatenates the two strings into a new one, using the allocator associated with left, if necessary.
CnxString cnx_string_concatenate_cstring(const CnxString*restrict left, restrict const_cstring right, usize right_length) cnx_disable_if(!right
Concatenates the two strings into a new one, using the allocator associated with left, if necessary.
CnxString cnx_string_concatenate_cstrings(restrict const_cstring left, usize left_length, restrict const_cstring right, usize right_length) cnx_disable_if(!left
Concatenates the two strings into a new CnxString, using the default allocator (malloc)
CnxString cnx_string_concatenate_stringview(const CnxString*restrict left, const CnxStringView*restrict right) cnx_disable_if(!left
Concatenates the two strings into a new one, using the allocator associated with left, if necessary.
CnxString cnx_string_concatenate_stringviews(const CnxStringView*restrict left, const CnxStringView*restrict right) cnx_disable_if(!left
Concatenates the two stringviews into a new CnxString, using the default allocator (malloc)
void invalid_types_passed_to_cnx_string_concatenate(void)
This function is an __INTENTIONALLY_ undefined function so that improper use of cnx_string_concatenate (passing values of invalid type(s)) will result in a build failure.
CnxString cnx_string_concatenate_with_allocator(const CnxString*restrict left, const CnxString*restrict right, CnxAllocator allocator) cnx_disable_if(!right
Concatenates the two strings into a new one, using the given allocator.
CnxString cnx_string_concatenate_cstring_with_allocator(const CnxString*restrict left, restrict const_cstring right, usize right_length, CnxAllocator allocator) cnx_disable_if(!right
Concatenates the two strings into a new one, using the given allocator.
CnxString cnx_string_concatenate_stringview_with_allocator(const CnxString*restrict left, const CnxStringView*restrict right, CnxAllocator allocator) cnx_disable_if(!right
Concatenates the two strings into a new one, using the given allocator.
CnxString cnx_string_concatenate_cstrings_with_allocator(restrict const_cstring left, usize left_length, restrict const_cstring right, usize right_length, CnxAllocator allocator) cnx_disable_if(!left
Concatenates the two strings into a new one, using the given allocator.
CnxString cnx_string_concatenate_stringviews_with_allocator(const CnxStringView*restrict left, const CnxStringView*restrict right, CnxAllocator allocator) cnx_disable_if(!left
Concatenates the two strings into a new one, using the given allocator.
void cnx_string_fill(CnxString*restrict self, char character)
Fills the string with the given character.
void cnx_string_clear(CnxString*restrict self)
Clears the string, filling it with null.
void cnx_string_shrink_to_fit(CnxString*restrict self)
Shrinks the string so its capacity equals its size.
void cnx_string_insert(CnxString*restrict self, const CnxString*restrict to_insert, usize index) cnx_disable_if(!to_insert
Inserts the given string to_insert into self at the given index
void cnx_string_insert_cstring(CnxString*restrict self, restrict const_cstring to_insert, usize to_insert_length, usize index) cnx_disable_if(!to_insert
Inserts the given string to_insert into self at the given index
void cnx_string_insert_stringview(CnxString*restrict self, const CnxStringView*restrict to_insert, usize index) cnx_disable_if(!to_insert
Inserts the given string to_insert into self at the given index
void cnx_string_erase(CnxString*restrict self, usize index)
Erases the character at the given index from the string.
void cnx_string_erase_n(CnxString*restrict self, usize index, usize num_characters)
Erases num_character characters from the string, starting at the given index.
void cnx_string_resize(CnxString*restrict self, usize new_size)
Resizes the string to the new size, null padding or truncating if necessary.
void cnx_string_reserve(CnxString*restrict self, usize new_capacity)
Reserves additional capacity in the string This will allocate enough memory to store at least new_capacity number of characters,.
void cnx_string_push_back(CnxString*restrict self, char character)
Appends the given character to the end of the string.
void cnx_string_push_front(CnxString*restrict self, char character)
Prepends the given character to the beginning of the string.
CnxOption(char)
Removes the last character in the string and returns it.
void cnx_string_append(CnxString*restrict self, const CnxString*restrict to_append) cnx_disable_if(!to_append
Appends the given string to the end of the string.
void cnx_string_append_cstring(CnxString*restrict self, restrict const_cstring to_append, usize to_append_length) cnx_disable_if(!to_append
Appends the given string to the end of the string.
void cnx_string_append_stringview(CnxString*restrict self, const CnxStringView*restrict to_append) cnx_disable_if(!to_append
Appends the given string to the end of the string.
void cnx_string_prepend(CnxString*restrict self, const CnxString*restrict to_prepend) cnx_disable_if(!to_prepend
Prepends the given string to the beginning of the string.
void cnx_string_prepend_cstring(CnxString*restrict self, restrict const_cstring to_prepend, usize to_prepend_length) cnx_disable_if(!to_prepend
Prepends the given string to the beginning of the string.
void cnx_string_prepend_stringview(CnxString*restrict self, const CnxStringView*restrict to_prepend) cnx_disable_if(!to_prepend
Prepends the given string to the beginning of the string.
void cnx_string_replace(CnxString*restrict self, const CnxString*restrict to_replace_with, usize index) cnx_disable_if(!to_replace_with
Replaces the substring beginning at index with the given one.
void cnx_string_replace_cstring(CnxString*restrict self, restrict const_cstring to_replace_with, usize to_replace_with_length, usize index) cnx_disable_if(!to_replace_with
Replaces the substring beginning at index with the given one.
void cnx_string_replace_stringview(CnxString*restrict self, const CnxStringView*restrict to_replace_with, usize index) cnx_disable_if(!to_replace_with
Replaces the substring beginning at index with the given one.
DeclIntoCnxRandomAccessIterator(CnxString, char_ref, cnx_string_into_iter, into)
Implement the Trait CnxRandomAccessIterator for CnxStringIterator
DeclIntoCnxRandomAccessIterator(CnxString, char_ref, cnx_string_into_reverse_iter, into_reverse)
Implement the Trait CnxRandomAccessIterator for a reverse CnxStringIterator
DeclIntoCnxRandomAccessIterator(CnxString, const_char_ref, cnx_string_into_const_iter, into)
Implement the Trait CnxRandomAccessIterator for CnxStringConstIterator
DeclIntoCnxRandomAccessIterator(CnxString, const_char_ref, cnx_string_into_reverse_const_iter, into_reverse)
Implement the Trait CnxRandomAccessIterator for a reverse CnxStringConstIterator
CnxRandomAccessIteratorchar_ref cnx_string_begin(CnxString*restrict self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the beginning of the iteration (pointing at the beginning of the string)
CnxRandomAccessIteratorchar_ref cnx_string_end(CnxString*restrict self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the end of the iteration (pointing at the end of the string)
CnxRandomAccessIteratorchar_ref cnx_string_rbegin(CnxString*restrict self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the beginning of the reversed iteration (pointing at the end of the string)
CnxRandomAccessIteratorchar_ref cnx_string_rend(CnxString*restrict self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the end of the reversed iteration (pointing at the beginning of the string)
CnxRandomAccessIteratorconst_char_ref cnx_string_cbegin(const CnxString*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the beginning of the iteration (pointing at the beginning of the string)
CnxRandomAccessIteratorconst_char_ref cnx_string_cend(const CnxString*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the end of the iteration (pointing at the end of the string)
CnxRandomAccessIteratorconst_char_ref cnx_string_crbegin(const CnxString*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the beginning of the reversed iteration (pointing at the end of the string)
CnxRandomAccessIteratorconst_char_ref cnx_string_crend(const CnxString*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the end of the reversed iteration (pointing at the beginning of the string)
CnxStringView cnx_stringview_new(const CnxString*restrict string)
Returns a new CnxStringView into the given CnxString
CnxStringView cnx_stringview_from(restrict const_cstring string, usize index, usize length) cnx_disable_if(!string
Returns a new CnxStringView into the given cstring.
const_char_ptr cnx_stringview_at(const CnxStringView*restrict self, usize index)
Returns the character in the view located at the given index.
usize cnx_stringview_length(const CnxStringView*restrict self)
Returns the length of the CnxStringView
usize cnx_stringview_size(const CnxStringView*restrict self)
Returns the size of the CnxStringView
bool cnx_stringview_equal(const CnxStringView*restrict self, const CnxStringView*restrict to_compare) cnx_disable_if(!to_compare
Returns whether the given CnxStringViews are equivalent.
bool cnx_stringview_equal_string(const CnxStringView*restrict self, const CnxString*restrict to_compare) cnx_disable_if(!to_compare
Returns whether the given CnxStringViews are equivalent.
bool cnx_stringview_equal_cstring(const CnxStringView*restrict self, restrict const_cstring to_compare, usize to_compare_length) cnx_disable_if(!to_compare
Returns whether the given CnxStringView is equivalent to the given cstring
const_cstring cnx_stringview_into_cstring(const CnxStringView*restrict self)
Returns a const_cstring (const char*) representation of the CnxStringView
DeclIntoCnxRandomAccessIterator(CnxStringView, const_char_ref, cnx_stringview_into_iter, into)
Implement the Trait CnxRandomAccessIterator for CnxStringViewIterator
DeclIntoCnxRandomAccessIterator(CnxStringView, const_char_ref, cnx_stringview_into_reverse_iter, into_reverse)
Implement the Trait CnxRandomAccessIterator for CnxStringViewIterator
CnxRandomAccessIteratorconst_char_ref cnx_stringview_begin(const CnxStringView*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the beginning of the iteration (pointing at the beginning of the view)
CnxRandomAccessIteratorconst_char_ref cnx_stringview_end(const CnxStringView*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the end of the iteration (pointing at the end of the view)
CnxRandomAccessIteratorconst_char_ref cnx_stringview_rbegin(const CnxStringView*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView in reverse, at the beginning of the iteration (pointing at the end of the view)
CnxRandomAccessIteratorconst_char_ref cnx_stringview_rend(const CnxStringView*restrict self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView in reverse, at the end of the iteration (pointing at the beginning of the view)

Defines

#define CNX_STRING
CNX_STRING.
#define CNX_STRING_SIZEOF_LONG_REP
The size of the long string representation of CnxString
#define CNX_STRING_SHORT_OPTIMIZATION_ARRAY_SIZE
The number of chars in a SSOd CnxString
#define CNX_STRING_SHORT_OPTIMIZATION_CAPACITY
The number of chars in a SSOd CnxString
#define OPTION_T
Declares CnxOption(T) for CnxString
#define OPTION_T
Declares CnxOption(T) for CnxString
#define OPTION_T
Declares CnxOption(T) for CnxString
#define OPTION_T
Declares CnxOption(T) for CnxString
#define OPTION_T
Declares CnxOption(T) for CnxString
#define OPTION_T
Declares CnxOption(T) for CnxString
#define cnx_string_from(string)
Creates a new CnxString from the given string-like type.
#define cnx_string_from_with_allocator(string, allocator)
Creates a new CnxString from the given string-like type, using the given CnxAllocator for memory allocations.
#define CnxScopedString
declare a CnxString variable with this attribute to have cnx_string_free automatically called on it at scope end
#define cnx_string_concatenate_cstrings__(left, left_size, right)
Concatenates the two cstrings, left and right and returns the result as a CnxString
#define cnx_string_concatenate_stringviews__(left, right)
Concatenates the two CnxStringViews, left and right and returns the result as a CnxString
#define cnx_string_concatenate_string__(left, right)
Concatenates the given CnxString, left, with the given string of arbitrary type, right, and returns the result as a CnxString
#define cnx_string_concatenate(left, right)
Concatenates the two strings and returns the result as a new CnxString
#define cnx_string_concatenate_cstrings_with_allocator__(left, left_size, right, allocator)
Concatenates the two cstrings, left and right and returns the result as a CnxString
#define cnx_string_concatenate_stringviews_with_allocator__(left, right, allocator)
Concatenates the two CnxStringViews, left and right and returns the result as a CnxString
#define cnx_string_concatenate_string_with_allocator__(left, right, allocator)
Concatenates the given CnxString, left, with the given string of arbitrary type, right, and returns the result as a CnxString
#define cnx_string_concatenate_with_allocator(left, right, allocator)
Concatenates the two strings and returns the result as a new CnxString
#define cnx_string_into_cstring(self)
Returns the cstring representation of the given CnxString
#define cnx_string_into_wcstring(self)
Returns the wcstring representation of the given CnxString
#define cnx_string_into_wcstring_with_allocator(self, allocator)
Returns the wcstring representation of the given CnxString
#define cnx_string_into_stringview(self)
Returns a CnxStringView into self.
#define cnx_string_clone(self)
Creates a copy of the given CnxString, self, using the CnxAllocator associated with self
#define cnx_string_clone_with_allocator(self, allocator)
Creates a copy of the given CnxString, self, using the given CnxAllocator
#define cnx_string_free(self)
Cleans up the given CnxString, freeing any allocated memory.
#define cnx_string_at(self, index)
Returns a reference to the character at the given index.
#define cnx_string_front(self)
Returns a reference to the character at the beginning of the string.
#define cnx_string_back(self)
Returns a reference to the character at the end of the string.
#define cnx_string_data(self)
Returns the raw character array of the string.
#define cnx_string_is_empty(self)
Returns whether the given CnxString is empty or not.
#define cnx_string_is_full(self)
Returns whether the given CnxString is full.
#define cnx_string_size(self)
Returns the current size of the given CnxString
#define cnx_string_length(self)
Returns the current length of the given CnxString
#define cnx_string_capacity(self)
Returns the current capacity of the given CnxString
#define cnx_string_first(self, num_chars)
Returns the first num_chars characters of self as a new CnxString, using the CnxAllocator associated with self
#define cnx_string_first_cstring(self, num_chars)
Returns the first num_chars characters of self as a new cstring, using the CnxAllocator associated with self
#define cnx_string_first_stringview(self, num_chars)
Returns the first num_chars characters of self as a CnxStringView
#define cnx_string_last(self, num_chars)
Returns the last num_chars characters of self as a new CnxString, using the CnxAllocator associated with self
#define cnx_string_last_cstring(self, num_chars)
Returns the last num_chars characters of self as a new cstring, using the CnxAllocator associated with self
#define cnx_string_last_stringview(self, num_chars)
Returns the last num_chars characters of self as a CnxStringView
#define cnx_string_equal(self, to_compare)
Determines if this string and the given one are equal.
#define cnx_string_contains(self, substring)
Determines whether the string contains the given substring.
#define cnx_string_starts_with(self, substring)
Determines whether the string starts with the given substring.
#define cnx_string_ends_with(self, substring)
Determines whether the string ends with the given substring.
#define cnx_string_find_first(self, substring)
Finds the first occurrence of the given substring in self, if any.
#define cnx_string_find_last(self, substring)
Finds the last occurrence of the given substring in self, if any.
#define cnx_string_substring(self, index, length)
Returns the substring of self starting at index with length length as a CnxString, using the CnxAllocator associated with self
#define cnx_string_substring_with_allocator(self, index, length, allocator)
Returns the substring of self starting at index with length length as a CnxString, associating the given CnxAllocator with the substring.
#define cnx_string_stringview_of(self, index, length)
Returns a CnxStringView into self beginning at index with length length
#define cnx_string_fill(self, character)
Fills the given CnxString with the given character.
#define cnx_string_clear(self)
Clears the given CnxString
#define cnx_string_shrink_to_fit(self)
Shrinks the capacity of the given CnxString to its size.
#define cnx_string_insert(self, to_insert, index)
Inserts to_insert into self at the given index.
#define cnx_string_erase(self, index)
Erases the character at the given index from self
#define cnx_string_erase_n(self, index, num_characters)
Erases num_characters characters from self, beginning at index
#define cnx_string_resize(self, new_size)
Resizes the given CnxString to the given new_size, filling the characters in the expanded size with null.
#define cnx_string_reserve(self, new_capacity)
Allocates memory such that at least new_capacity number of characters can be stored in the given CnxString
#define cnx_string_push_back(self, character)
Pushes the given character onto the end of the given CnxString
#define cnx_string_push_front(self, character)
Pushes the given character onto the beginning of the given CnxString
#define cnx_string_pop_back(self)
Removes the last character in self if cnx_string_size(self) > 0, and returns it.
#define cnx_string_pop_front(self)
Removes the first character in self if cnx_string_size(self) > 0, and returns it.
#define cnx_string_append(self, to_append)
Appends to_append to the end of self
#define cnx_string_prepend(self, to_prepend)
Prepends to_prepend to the beginning of self
#define cnx_string_replace(self, to_replace_with, index)
Replaces the contents of self with to_replace_with, beginning at the given index.
#define cnx_string_begin(self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the beginning of the iteration (pointing at the beginning of the string)
#define cnx_string_end(self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the end of the iteration (pointing at the end of the string)
#define cnx_string_rbegin(self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the beginning of the reversed iteration (pointing at the end of the string)
#define cnx_string_rend(self)
Returns a CnxRandomAccessIterator(char_ref) into the given CnxString, at the end of the reversed iteration (pointing at the beginning of the string)
#define cnx_string_cbegin(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the beginning of the iteration (pointing at the beginning of the string)
#define cnx_string_cend(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the end of the iteration (pointing at the end of the string)
#define cnx_string_crbegin(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the beginning of the reversed iteration (pointing at the end of the string)
#define cnx_string_crend(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxString, at the end of the reversed iteration (pointing at the beginning of the string)
#define cnx_stringview_at(self, index)
Returns a const reference to the character at index in the given CnxStringView
#define cnx_stringview_length(self)
Returns the current length of the given CnxStringView
#define cnx_stringview_size(self)
Returns the current size of the given CnxStringView
#define cnx_stringview_equal(self, to_compare)
Returns whether the given CnxStringViews are equivalent.
#define cnx_stringview_into_cstring(self)
Returns the cstring view of the given CnxStringView
#define cnx_stringview_begin(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the beginning of the iteration (pointing at the beginning of the view)
#define cnx_stringview_end(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the end of the iteration (pointing at the end of the view)
#define cnx_stringview_rbegin(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the beginning of the reversed iteration (pointing at the end of the view)
#define cnx_stringview_rend(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the end of the reversed iteration (pointing at the beginning of the view)
#define cnx_stringview_cbegin(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the beginning of the iteration (pointing at the beginning of the view)
#define cnx_stringview_cend(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the end of the iteration (pointing at the end of the view)
#define cnx_stringview_crbegin(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the beginning of the reversed iteration (pointing at the end of the view)
#define cnx_stringview_crend(self)
Returns a CnxRandomAccessIterator(const_char_ref) into the given CnxStringView, at the end of the reversed iteration (pointing at the beginning of the view)

Typedef documentation

typedef CnxString*Ref(CnxString)

type alias for a reference to CnxString

type alias for a reference to CnxStringView

typedef const CnxString*ConstRef(CnxString)

type alias for a const reference to CnxString

type alias for a const reference to CnxStringView

Define documentation

#define cnx_string_concatenate_cstrings__(left, left_size, right)

Concatenates the two cstrings, left and right and returns the result as a CnxString

Parameters
left - The left-side string of the concatenation
left_size - The size of left_size
right - The right-side string of the concatenation. Its size will be inferred
Returns The concatenated result as a CnxString

#define cnx_string_concatenate_stringviews__(left, right)

Concatenates the two CnxStringViews, left and right and returns the result as a CnxString

Parameters
left - The left-side string of the concatenation
right - The right-side string of the concatenation
Returns The concatenated result as a CnxString

#define cnx_string_concatenate_string__(left, right)

Concatenates the given CnxString, left, with the given string of arbitrary type, right, and returns the result as a CnxString

Parameters
left - The left-side string of the concatenation
right - The right-side string of the concatenation
Returns The concatenated result as a CnxString

#define cnx_string_concatenate_cstrings_with_allocator__(left, left_size, right, allocator)

Concatenates the two cstrings, left and right and returns the result as a CnxString

Parameters
left - The left-side string of the concatenation
left_size - The size of left_size
right - The right-side string of the concatenation. Its size will be inferred
allocator - The CnxAllocator to use for memory allocation
Returns The concatenated result as a CnxString

#define cnx_string_concatenate_stringviews_with_allocator__(left, right, allocator)

Concatenates the two CnxStringViews, left and right and returns the result as a CnxString

Parameters
left - The left-side string of the concatenation
right - The right-side string of the concatenation
allocator - The CnxAllocator to use for memory allocation
Returns The concatenated result as a CnxString

#define cnx_string_concatenate_string_with_allocator__(left, right, allocator)

Concatenates the given CnxString, left, with the given string of arbitrary type, right, and returns the result as a CnxString

Parameters
left - The left-side string of the concatenation
right - The right-side string of the concatenation
allocator - The CnxAllocator to use for memory allocation
Returns The concatenated result as a CnxString