file
String.hThis 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 associatedCnxString
- struct CnxString
- Cnx string type
CnxString
is a bounds safe, allocator aware, potentially dynamically allocated string type with significantly improved ergonomics overconst char*
s (akacstring
s), but maintains compatibility with them (CnxString
is always null terminated). Provides similar functionality to C++'sstd::string
, but in C. - struct CnxStringIterator
- Cnx string iterator storage type
CnxStringIterator
is the underlying storage type used byCnxString
for its non-const iterator type (CnxRandomAccessIterator(char_
)ptr) - struct CnxStringConstIterator
- Cnx string const iterator storage type
CnxStringIterator
is the underlying storage type used byCnxString
for its const iterator type (CnxRandomAccessIterator(const_
)char_ ptr) - struct CnxStringViewIterator
- Cnx stringview const iterator storage type
CnxStringViewIterator
is the underlying storage type used byCnxStringView
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 associatedCnxString
-
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 overconst char*
s (akacstring
s), but maintains compatibility with them (CnxString
is always null terminated). Provides similar functionality to C++'sstd::string
, but in C. - using CnxStringIterator = struct CnxStringIterator
- Cnx string iterator storage type
CnxStringIterator
is the underlying storage type used byCnxString
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 byCnxString
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 byCnxStringView
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 givencstring
-
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 givencstring
-
CnxString cnx_string_from_wcstring(restrict const_
wcstring string, usize length) cnx_disable_if(!string - Creates a new
CnxString
from the givenwcstring
-
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 givenwcstring
- CnxString cnx_string_from_stringview(const CnxStringView*restrict view) cnx_disable_if(!view
- Creates a new
CnxString
from the givenCnxStringView
- 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 givenCnxStringView
-
const_
cstring cnx_string_into_cstring(const CnxString*restrict self) - Returns the
cstring
representation of thisCnxString
-
const_
wcstring cnx_string_into_wcstring(const CnxString*restrict self) - Returns the
wcstring
converted representation of thisCnxString
. The result will be allocated with the same allocator used by thisCnxString
-
const_
wcstring cnx_string_into_wcstring_with_allocator(const CnxString*restrict self, CnxAllocator allocator) - Returns the
wcstring
converted representation of thisCnxString
, allocated with the given allocator;. - CnxStringView cnx_string_into_stringview(const CnxString*restrict self)
- Returns a
CnxStringView
into thisCnxString
- 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 newCnxString
- 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 acstring
allocated with the allocator associated withself
- 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 aCnxStringView
- 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 newCnxString
- 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 acstring
allocated with the allocator associated withself
- 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 aCnxStringView
- 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 atindex
- CnxString cnx_string_substring_with_allocator(const CnxString*restrict self, usize index, usize length, CnxAllocator allocator)
- Returns the length
length
substring beginning atindex
, allocated with the given allocator. - CnxStringView cnx_string_stringview_of(const CnxString*restrict self, usize index, usize length)
- Returns a
CnxStringView
intoself
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
intoself
at the givenindex
-
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
intoself
at the givenindex
- 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
intoself
at the givenindex
- 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
forCnxStringIterator
- DeclIntoCnxRandomAccessIterator(CnxString, char_ref, cnx_string_into_reverse_iter, into_reverse)
- Implement the Trait
CnxRandomAccessIterator
for a reverseCnxStringIterator
- DeclIntoCnxRandomAccessIterator(CnxString, const_char_ref, cnx_string_into_const_iter, into)
- Implement the Trait
CnxRandomAccessIterator
forCnxStringConstIterator
- DeclIntoCnxRandomAccessIterator(CnxString, const_char_ref, cnx_string_into_reverse_const_iter, into_reverse)
- Implement the Trait
CnxRandomAccessIterator
for a reverseCnxStringConstIterator
- CnxRandomAccessIteratorchar_ref cnx_string_begin(CnxString*restrict self)
- Returns a
CnxRandomAccessIterator(char_
into the givenref) 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_
into the givenref) 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_
into the givenref) 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_
into the givenref) 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_
into the givenchar_ ref) 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_
into the givenchar_ ref) 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_
into the givenchar_ ref) 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_
into the givenchar_ ref) 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 givenCnxString
-
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
CnxStringView
s 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
CnxStringView
s 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 givencstring
-
const_
cstring cnx_stringview_into_cstring(const CnxStringView*restrict self) - Returns a
const_cstring
(const char*
) representation of theCnxStringView
- DeclIntoCnxRandomAccessIterator(CnxStringView, const_char_ref, cnx_stringview_into_iter, into)
- Implement the Trait
CnxRandomAccessIterator
forCnxStringViewIterator
- DeclIntoCnxRandomAccessIterator(CnxStringView, const_char_ref, cnx_stringview_into_reverse_iter, into_reverse)
- Implement the Trait
CnxRandomAccessIterator
forCnxStringViewIterator
- CnxRandomAccessIteratorconst_char_ref cnx_stringview_begin(const CnxStringView*restrict self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) 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_
into the givenchar_ ref) 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_
into the givenchar_ ref) 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_
into the givenchar_ ref) 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
char
s in a SSOdCnxString
- #define CNX_STRING_SHORT_OPTIMIZATION_CAPACITY
- The number of
char
s in a SSOdCnxString
- #define OPTION_T
- Declares
CnxOption(T)
forCnxString
- #define OPTION_T
- Declares
CnxOption(T)
forCnxString
- #define OPTION_T
- Declares
CnxOption(T)
forCnxString
- #define OPTION_T
- Declares
CnxOption(T)
forCnxString
- #define OPTION_T
- Declares
CnxOption(T)
forCnxString
- #define OPTION_T
- Declares
CnxOption(T)
forCnxString
- #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 givenCnxAllocator
for memory allocations. - #define CnxScopedString
- declare a
CnxString
variable with this attribute to havecnx_string_free
automatically called on it at scope end - #define cnx_string_concatenate_cstrings__(left, left_size, right)
- Concatenates the two
cstring
s,left
andright
and returns the result as aCnxString
- #define cnx_string_concatenate_stringviews__(left, right)
- Concatenates the two
CnxStringView
s,left
andright
and returns the result as aCnxString
- #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 aCnxString
- #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
cstring
s,left
andright
and returns the result as aCnxString
- #define cnx_string_concatenate_stringviews_with_allocator__(left, right, allocator)
- Concatenates the two
CnxStringView
s,left
andright
and returns the result as aCnxString
- #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 aCnxString
- #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 givenCnxString
- #define cnx_string_into_wcstring(self)
- Returns the
wcstring
representation of the givenCnxString
- #define cnx_string_into_wcstring_with_allocator(self, allocator)
- Returns the
wcstring
representation of the givenCnxString
- #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 theCnxAllocator
associated withself
- #define cnx_string_clone_with_allocator(self, allocator)
- Creates a copy of the given
CnxString
,self
, using the givenCnxAllocator
- #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 ofself
as a newCnxString
, using theCnxAllocator
associated withself
- #define cnx_string_first_cstring(self, num_chars)
- Returns the first
num_chars
characters ofself
as a newcstring
, using theCnxAllocator
associated withself
- #define cnx_string_first_stringview(self, num_chars)
- Returns the first
num_chars
characters ofself
as aCnxStringView
- #define cnx_string_last(self, num_chars)
- Returns the last
num_chars
characters ofself
as a newCnxString
, using theCnxAllocator
associated withself
- #define cnx_string_last_cstring(self, num_chars)
- Returns the last
num_chars
characters ofself
as a newcstring
, using theCnxAllocator
associated withself
- #define cnx_string_last_stringview(self, num_chars)
- Returns the last
num_chars
characters ofself
as aCnxStringView
- #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 atindex
with lengthlength
as aCnxString
, using theCnxAllocator
associated withself
- #define cnx_string_substring_with_allocator(self, index, length, allocator)
- Returns the substring of
self
starting atindex
with lengthlength
as aCnxString
, associating the givenCnxAllocator
with the substring. - #define cnx_string_stringview_of(self, index, length)
- Returns a
CnxStringView
intoself
beginning atindex
with lengthlength
- #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
intoself
at the given index. - #define cnx_string_erase(self, index)
- Erases the character at the given
index
fromself
- #define cnx_string_erase_n(self, index, num_characters)
- Erases
num_characters
characters fromself
, beginning atindex
- #define cnx_string_resize(self, new_size)
- Resizes the given
CnxString
to the givennew_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 givenCnxString
- #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
ifcnx_
, and returns it.string_ size(self) > 0 - #define cnx_string_pop_front(self)
- Removes the first character in
self
ifcnx_
, and returns it.string_ size(self) > 0 - #define cnx_string_append(self, to_append)
- Appends
to_append
to the end ofself
- #define cnx_string_prepend(self, to_prepend)
- Prepends
to_prepend
to the beginning ofself
- #define cnx_string_replace(self, to_replace_with, index)
- Replaces the contents of
self
withto_replace_with
, beginning at the given index. - #define cnx_string_begin(self)
- Returns a
CnxRandomAccessIterator(char_
into the givenref) CnxString
, at the beginning of the iteration (pointing at the beginning of the string) - #define cnx_string_end(self)
- Returns a
CnxRandomAccessIterator(char_
into the givenref) CnxString
, at the end of the iteration (pointing at the end of the string) - #define cnx_string_rbegin(self)
- Returns a
CnxRandomAccessIterator(char_
into the givenref) CnxString
, at the beginning of the reversed iteration (pointing at the end of the string) - #define cnx_string_rend(self)
- Returns a
CnxRandomAccessIterator(char_
into the givenref) CnxString
, at the end of the reversed iteration (pointing at the beginning of the string) - #define cnx_string_cbegin(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxString
, at the beginning of the iteration (pointing at the beginning of the string) - #define cnx_string_cend(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxString
, at the end of the iteration (pointing at the end of the string) - #define cnx_string_crbegin(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxString
, at the beginning of the reversed iteration (pointing at the end of the string) - #define cnx_string_crend(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) 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 givenCnxStringView
- #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
CnxStringView
s are equivalent. - #define cnx_stringview_into_cstring(self)
- Returns the
cstring
view of the givenCnxStringView
- #define cnx_stringview_begin(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the beginning of the iteration (pointing at the beginning of the view) - #define cnx_stringview_end(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the end of the iteration (pointing at the end of the view) - #define cnx_stringview_rbegin(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the beginning of the reversed iteration (pointing at the end of the view) - #define cnx_stringview_rend(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the end of the reversed iteration (pointing at the beginning of the view) - #define cnx_stringview_cbegin(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the beginning of the iteration (pointing at the beginning of the view) - #define cnx_stringview_cend(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the end of the iteration (pointing at the end of the view) - #define cnx_stringview_crbegin(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) CnxStringView
, at the beginning of the reversed iteration (pointing at the end of the view) - #define cnx_stringview_crend(self)
- Returns a
CnxRandomAccessIterator(const_
into the givenchar_ ref) 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 OPTION_T
Declares CnxOption(T)
for CnxString
Declares CnxOption(T)
for ConstRef(CnxStringView)
Declares CnxOption(T)
for Ref(CnxStringView)
Declares CnxOption(T)
for CnxStringView
Declares CnxOption(T)
for ConstRef(CnxString)
Declares CnxOption(T)
for Ref(CnxString)
#define OPTION_T
Declares CnxOption(T)
for CnxString
Declares CnxOption(T)
for ConstRef(CnxStringView)
Declares CnxOption(T)
for Ref(CnxStringView)
Declares CnxOption(T)
for CnxStringView
Declares CnxOption(T)
for ConstRef(CnxString)
Declares CnxOption(T)
for Ref(CnxString)
#define OPTION_T
Declares CnxOption(T)
for CnxString
Declares CnxOption(T)
for ConstRef(CnxStringView)
Declares CnxOption(T)
for Ref(CnxStringView)
Declares CnxOption(T)
for CnxStringView
Declares CnxOption(T)
for ConstRef(CnxString)
Declares CnxOption(T)
for Ref(CnxString)
#define OPTION_T
Declares CnxOption(T)
for CnxString
Declares CnxOption(T)
for ConstRef(CnxStringView)
Declares CnxOption(T)
for Ref(CnxStringView)
Declares CnxOption(T)
for CnxStringView
Declares CnxOption(T)
for ConstRef(CnxString)
Declares CnxOption(T)
for Ref(CnxString)
#define OPTION_T
Declares CnxOption(T)
for CnxString
Declares CnxOption(T)
for ConstRef(CnxStringView)
Declares CnxOption(T)
for Ref(CnxStringView)
Declares CnxOption(T)
for CnxStringView
Declares CnxOption(T)
for ConstRef(CnxString)
Declares CnxOption(T)
for Ref(CnxString)
#define OPTION_T
Declares CnxOption(T)
for CnxString
Declares CnxOption(T)
for ConstRef(CnxStringView)
Declares CnxOption(T)
for Ref(CnxStringView)
Declares CnxOption(T)
for CnxStringView
Declares CnxOption(T)
for ConstRef(CnxString)
Declares CnxOption(T)
for Ref(CnxString)
#define cnx_string_concatenate_cstrings__(left, left_size, right)
Concatenates the two cstring
s, 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 CnxStringView
s, 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 cstring
s, 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 CnxStringView
s, 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 |