fennec
Loading...
Searching...
No Matches
fennec::_wstring< AllocT >

Struct for wrapping c-style strings. More...

#include <wstring.h>

Detailed Description

template<typename AllocT>
struct fennec::_wstring< AllocT >

behaviour guarantees that the underlying string is null-terminated

Public Member Functions

constexpr _wstring ()
 Default Constructor, initializes empty string.
 
constexpr _wstring (size_t n, wchar_t c='\0')
 Sized Constructor, initializes a null-terminated string of size n with ‘'c’...`.
 
template<size_t n>
constexpr _wstring (const wchar_t(&str)[n])
 Buffer Constructor, wraps the provided C-Style string, appending a null-terminator if not present.
 
constexpr _wstring (const wchar_t *buf, size_t n)
 Buffer Constructor, wraps the provided C-Style string, appending a null-terminator if not present.
 
constexpr _wstring (const _wstring &str)=default
 String Copy Constructor.
 
constexpr _wstring (_wstring &&str) noexcept=default
 String Move Constructor.
 
constexpr ~_wstring ()=default
 Destructor, cleans up underlying allocation.
 
constexpr size_t size () const
 
constexpr size_t capacity () const
 
constexpr wchar_t & operator[] (size_t i)
 Array Access Operator.
 
constexpr const wchar_t & operator[] (size_t i) const
 Const-Array Access Operator.
 
constexpr size_t length () const
 
constexpr int compare (const wcstring &str, size_t i=0, size_t n=npos) const
 String Comparison.
 
constexpr int compare (const _wstring &str, size_t i=0, size_t n=npos) const
 String Comparison.
 
constexpr bool contains (char c, size_t i=0) const
 Check if the string contains a character.
 
constexpr size_t find (wchar_t c, size_t i=0) const
 Finds the index of the first occurrence of c in the string.
 
constexpr size_t find (const _wstring &str, size_t i=0) const
 Finds the index of the first occurrence of str in the string.
 
constexpr size_t find (const wcstring &str, size_t i=0) const
 Finds the index of the first occurrence of str in the string.
 
constexpr size_t rfind (wchar_t c, size_t i=npos) const
 Finds the index of the last occurrence of c in the string.
 
constexpr size_t rfind (const wcstring &str, size_t i=npos) const
 Finds the index of the last occurrence of str in the string.
 
constexpr size_t rfind (const string &str, size_t i=npos) const
 Finds the index of the last occurrence of str in the string.
 
constexpr _wstring substring (size_t i, size_t n=npos) const
 Retrieve a substring of a string.
 

Constructor & Destructor Documentation

◆ _wstring() [1/5]

template<typename AllocT >
constexpr fennec::_wstring< AllocT >::_wstring ( size_t  n,
wchar_t  c = '\0' 
)
inlineconstexpr
Parameters
nthe number of wchar_tacters
cthe wchar_tacter to fill with

adds additional wchar_tacter for null termination.

◆ _wstring() [2/5]

template<typename AllocT >
template<size_t n>
constexpr fennec::_wstring< AllocT >::_wstring ( const wchar_t(&)  str[n])
inlineexplicitconstexpr
Parameters
strthe buffer to wrap
Template Parameters
nthe number of wchar_tacters in the buffer including the null-terminator, if present

◆ _wstring() [3/5]

template<typename AllocT >
constexpr fennec::_wstring< AllocT >::_wstring ( const wchar_t *  buf,
size_t  n 
)
inlineconstexpr
Parameters
strthe buffer to wrap
nthe number of wchar_tacters in the buffer including the null-terminator, if present

◆ _wstring() [4/5]

template<typename AllocT >
constexpr fennec::_wstring< AllocT >::_wstring ( const _wstring< AllocT > &  str)
constexprdefault
Parameters
strthe string to copy

◆ _wstring() [5/5]

template<typename AllocT >
constexpr fennec::_wstring< AllocT >::_wstring ( _wstring< AllocT > &&  str)
constexprdefaultnoexcept
Parameters
strthe string to take ownership of

Member Function Documentation

◆ size()

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::size ( ) const
inlineconstexpr
Returns
The size of the string excluding null terminator

◆ capacity()

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::capacity ( ) const
inlineconstexpr
Returns
The size of the string including null terminator

◆ operator[]() [1/2]

template<typename AllocT >
constexpr wchar_t & fennec::_wstring< AllocT >::operator[] ( size_t  i)
inlineconstexpr
Parameters
ithe index to access
Returns
a reference to the wchar_tacter

◆ operator[]() [2/2]

template<typename AllocT >
constexpr const wchar_t & fennec::_wstring< AllocT >::operator[] ( size_t  i) const
inlineconstexpr
Parameters
ithe index to access
Returns
a copy of the wchar_tacter

◆ length()

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::length ( ) const
inlineconstexpr
Returns
The length of the string to the first null-terminator

◆ compare() [1/2]

template<typename AllocT >
constexpr int fennec::_wstring< AllocT >::compare ( const wcstring str,
size_t  i = 0,
size_t  n = npos 
) const
inlineconstexpr
Parameters
ostrthe string to compare against
Returns
Zero if both strings are equal, otherwise a negative value if lhs appears before rhs according to the current locale, otherwise a positive value.

◆ compare() [2/2]

template<typename AllocT >
constexpr int fennec::_wstring< AllocT >::compare ( const _wstring< AllocT > &  str,
size_t  i = 0,
size_t  n = npos 
) const
inlineconstexpr
Parameters
ostrthe string to compare against
Returns
Zero if both strings are equal, otherwise a negative value if lhs appears before rhs according to the current locale, otherwise a positive value.

◆ contains()

template<typename AllocT >
constexpr bool fennec::_wstring< AllocT >::contains ( char  c,
size_t  i = 0 
) const
inlineconstexpr
Parameters
c
i
Returns

◆ find() [1/3]

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::find ( wchar_t  c,
size_t  i = 0 
) const
inlineconstexpr
Parameters
cthe wchar_tacter to find
Returns
The index of c if it occurs in the string, otherwise returns size()

◆ find() [2/3]

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::find ( const _wstring< AllocT > &  str,
size_t  i = 0 
) const
inlineconstexpr
Parameters
strthe string to find
Returns
The index of str if it occurs in the string, otherwise returns size()

◆ find() [3/3]

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::find ( const wcstring str,
size_t  i = 0 
) const
inlineconstexpr
Parameters
strthe string to find
Returns
The index of str if it occurs in the string, otherwise returns size()

◆ rfind() [1/3]

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::rfind ( wchar_t  c,
size_t  i = npos 
) const
inlineconstexpr
Parameters
cthe string to find
ithe index to start at
Returns
The index of c if it occurs in the string, otherwise returns size()

◆ rfind() [2/3]

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::rfind ( const wcstring str,
size_t  i = npos 
) const
inlineconstexpr
Parameters
strthe string to find
ithe index to start at
Returns
The index of str if it occurs in the string, otherwise returns size()

◆ rfind() [3/3]

template<typename AllocT >
constexpr size_t fennec::_wstring< AllocT >::rfind ( const string str,
size_t  i = npos 
) const
inlineconstexpr
Parameters
strthe string to find
ithe index to start at
Returns
The index of str if it occurs in the string, otherwise returns size()

◆ substring()

template<typename AllocT >
constexpr _wstring fennec::_wstring< AllocT >::substring ( size_t  i,
size_t  n = npos 
) const
inlineconstexpr
Parameters
ithe start index
nthe number of wchar_tacters
Returns

The documentation for this struct was generated from the following file: