Views » CnxStringView module

A CnxStringView is a "view" into a CnxString. It allows you to lazily inspect the contents of its associated string, but not modify them. It is effectively a fat reference to the contents of its associated string.

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 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))

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 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))

Functions

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
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_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 struct cnx_stringview_vtable_t cnx_stringview_vtable_t

The function vector table of methods associated with CnxStringView

typedef struct CnxStringView 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

typedef struct CnxStringViewIterator 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))

Function documentation

CnxStringView cnx_stringview_new(const CnxString*restrict string)

Returns a new CnxStringView into the given CnxString

Parameters
string - The CnxString to get the view of
Returns a CnxStringView into the given string

CnxStringView cnx_stringview_from(restrict const_cstring string, usize index, usize length) cnx_disable_if(!string

Returns a new CnxStringView into the given cstring.

Parameters
string - The cstring to get the view of
index - The index to begin the view at
length - The length of the view
Returns a CnxStringView into the given string

const_char_ptr cnx_stringview_at(const CnxStringView*restrict self, usize index)

Returns the character in the view located at the given index.

Parameters
self - The CnxStringView to retrieve a character from
index - The index of the character to get
Returns the character at index

usize cnx_stringview_length(const CnxStringView*restrict self)

Returns the length of the CnxStringView

Parameters
self - The CnxStringView to get the length of
Returns the length of the stringview

usize cnx_stringview_size(const CnxStringView*restrict self)

Returns the size of the CnxStringView

Parameters
self - The CnxStringView to get the size of
Returns the size of the stringview

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.

Parameters
self - The first CnxStringView to compare
to_compare - The CnxStringView to compare to
Returns whether the stringviews are equal

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.

Parameters
self - The first CnxStringView to compare
to_compare - The CnxStringView to compare to
Returns whether the stringviews are equal

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

Parameters
self - The first CnxStringView to compare
to_compare - The cstring to compare to
to_compare_length - The length of the cstring
Returns whether self is equalivalent to the given cstring

const_cstring cnx_stringview_into_cstring(const CnxStringView*restrict self)

Returns a const_cstring (const char*) representation of the CnxStringView

Parameters
self - The CnxStringView to get the const_cstring representation of
Returns the const_cstring representation of the stringview

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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator at the beginning of the reverse 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator at the end of the reverse iteration (pointing at the beginning of the view)

Define documentation

#define cnx_stringview_at(self, index)

Returns a const reference to the character at index in the given CnxStringView

Parameters
self - The CnxStringView to get a character from
index - The index of the desired character in self
Returns a const reference to the character at index in `self

#define cnx_stringview_length(self)

Returns the current length of the given CnxStringView

Parameters
self - The CnxStringView to get the length of
Returns the length of self

#define cnx_stringview_size(self)

Returns the current size of the given CnxStringView

Parameters
self - The CnxStringView to get the size of
Returns the size of self

#define cnx_stringview_equal(self, to_compare)

Returns whether the given CnxStringViews are equivalent.

Parameters
self - The first CnxStringView to compare
to_compare - The CnxStringView to compare to
Returns whether the stringviews are equal

#define cnx_stringview_into_cstring(self)

Returns the cstring view of the given CnxStringView

Parameters
self - The CnxStringView to get the cstring view of
Returns self as a cstring

#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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator 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)

Parameters
self - The CnxStringView to get an iterator into
Returns an iterator at the end of the reversed iteration (pointing at the beginning of the view)