Templated class for read only access to a string.
More...
|
| CsBasicStringView () = default |
|
| CsBasicStringView (const S &str) |
|
| CsBasicStringView (const_iterator begin, const_iterator end) |
|
value_type | at (size_type index) const |
|
value_type | back () const |
|
iterator | begin () |
|
const_iterator | begin () const |
|
const_iterator | cbegin () const |
|
const_iterator | cend () const |
|
int | compare (CsBasicStringView< S > str) const |
|
const_iterator | constBegin () const |
|
const_iterator | constEnd () const |
|
const_reverse_iterator | crbegin () const |
|
const_reverse_iterator | crend () const |
|
bool | empty () const |
|
iterator | end () |
|
const_iterator | end () const |
|
bool | endsWith (CsBasicStringView< S > str) const |
|
const_iterator | find_fast (const char (&str)[N]) const |
|
const_iterator | find_fast (const char (&str)[N], const_iterator iter_begin) const |
|
const_iterator | find_fast (const char (&str)[N], const_iterator iter_begin, size_type size) const |
|
template<typename T, typename = typename std::enable_if<std::is_same<T, const char *>::value || std::is_same<T, char *>::value>::type> |
const_iterator | find_fast (const T &str) const |
|
template<typename T, typename = typename std::enable_if<std::is_same<T, const char *>::value || std::is_same<T, char *>::value>::type> |
const_iterator | find_fast (const T &str, const_iterator iter_begin) const |
|
template<typename T, typename = typename std::enable_if<std::is_same<T, const char *>::value || std::is_same<T, char *>::value>::type> |
const_iterator | find_fast (const T &str, const_iterator iter_begin, size_type size) const |
|
const_iterator | find_fast (CsBasicStringView< S > str) const |
|
const_iterator | find_fast (CsBasicStringView< S > str, const_iterator iter_begin) const |
|
const_iterator | find_fast (value_type c) const |
|
const_iterator | find_fast (value_type c, const_iterator iter_begin) const |
|
value_type | front () const |
|
size_type | length () const |
|
CsBasicStringView< S > & | operator= (const CsBasicStringView< S > &str) = default |
|
CsBasicStringView< S > & | operator= (CsBasicStringView< S > &&str) = default |
|
value_type | operator[] (size_type index) const |
|
reverse_iterator | rbegin () |
|
const_reverse_iterator | rbegin () const |
|
CsBasicStringView< S > | remove_prefix (size_type size) const |
|
CsBasicStringView< S > | remove_suffix (size_type size) const |
|
reverse_iterator | rend () |
|
const_reverse_iterator | rend () const |
|
const_iterator | rfind_fast (CsBasicStringView< S > str) const |
|
const_iterator | rfind_fast (CsBasicStringView< S > str, const_iterator iter_end) const |
|
size_type | size () const |
|
bool | startsWith (CsBasicStringView< S > str) const |
|
CsBasicStringView< S > | substr (size_type indexStart=0, size_type size=npos) const |
|
void | swap (CsBasicStringView< S > &str) |
|
|
These are not member functions
|
bool | operator!= (CsBasicStringView< S > &str1, CsBasicStringView< S > &str2) |
|
bool | operator< (CsBasicStringView< S > &str1, CsBasicStringView< S > &str2) |
|
bool | operator<= (CsBasicStringView< S > &str1, CsBasicStringView< S > &str2) |
|
bool | operator== (CsBasicStringView< S > &str1, CsBasicStringView< S > &str2) |
|
bool | operator> (CsBasicStringView< S > &str1, CsBasicStringView< S > &str2) |
|
bool | operator>= (CsBasicStringView< S > &str1, CsBasicStringView< S > &str2) |
|
template<typename S>
class CsString::CsBasicStringView< S >
The CsBasicStringView class is a templated class which provides read only access to a CsBasicString. The template parameter indicates the string data type which is passed to the CsBasicStringView template.
A CsBasicStringView is a view of a particular type of string. The encoding is defined by the type of string. For example, a CsBasicStringView<CsBasicString<utf8>> is a view of a CsBasicString<utf8>.
The following typedefs are provided for convenience.
For additional information about CsBasicString refer to Why CsString was Created.
For information about character encoding, code points, and Unicode refer to String Terminology.
Provides an STL style const iterator for string view.
Provides an STL style const reverse iterator for string view.
Provides an STL style const iterator for string view.
Provides an STL style non-const reverse iterator for string view.
Typedef for an integer type representing sizes in a string view.
template<typename S>
CsString::CsBasicStringView< S >::CsBasicStringView |
( |
| ) |
|
|
inlinedefault |
Constructs an empty CsBasicStringView.
template<typename S>
CsString::CsBasicStringView< S >::CsBasicStringView |
( |
const S & |
str | ) |
|
|
inline |
Constructs a CsBasicStringView from the string str.
Constructs a CsBasicStringView using the specified iterator range.
Returns the code point at position index in this CsBasicStringView. The behavior of this method is undefined if index is negative or if index is equal to or greater than the size() of the string view.
- See also
- operator[]()
template<typename S>
CsChar CsBasicStringView::back |
( |
| ) |
const |
Returns the last code point in this CsBasicStringView. The behavior of this method is undefined if the string view is empty.
- See also
- front()
template<typename S>
iterator CsString::CsBasicStringView< S >::begin |
( |
| ) |
|
|
inline |
Returns an iterator to the first code point of this CsBasicStringView.
Returns a const iterator to the first code point of this CsBasicStringView.
Returns a const iterator to the first code point of this CsBasicStringView.
Returns a const iterator to the element after the last code point of this CsBasicStringView.
template<typename S>
int CsString::CsBasicStringView< S >::compare |
( |
CsBasicStringView<S> |
str | ) |
const |
Lexically compares this string with the string view str.
- Returns -1 if this string is less than str
- Returns 0 if this string is equal to str
- Returns 1 if this string is greater than str
Returns a const iterator to the first code point of this CsBasicStringView.
Returns a const iterator to the element after the last code point of this CsBasicStringView.
Returns a const iterator to the last code point of this CsBasicStringView.
Returns a const iterator to the element before the first code point of this CsBasicStringView.
template<typename S>
bool CsBasicStringView::empty |
( |
| ) |
const |
Returns true if this CsBasicStringView is empty.
template<typename S>
iterator CsString::CsBasicStringView< S >::end |
( |
| ) |
|
|
inline |
Returns a iterator to the element after the last code point of this CsBasicStringView.
Returns a const iterator to the element after the last code point of this CsBasicStringView
template<typename S>
bool CsBasicStringView::endsWith |
( |
CsBasicStringView<S> |
str | ) |
const |
Returns true if this string view ends with the string view str, otherwise returns false.
- See also
- startsWith()
template<typename S>
const_iterator CsString::CsBasicStringView< S >::find_fast |
( |
const char (& |
str)[N] | ) |
const |
Find the specified string literal str in this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string if no match is found.
Find the specified string literal str in this CsBasicStringView. Begin searching from iter_begin in this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
Find the specified string literal str in this CsBasicStringView. Begin searching from iter_begin in this CsBasicStringView. Only the first size number of code points of str are searched.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
template<typename S>
template<typename T, typename = typename std::enable_if<std::is_same<T, const char *>::value || std::is_same<T, char *>::value>::type>
const_iterator CsString::CsBasicStringView< S >::find_fast |
( |
const T & |
str | ) |
const |
Find the specified C style string str in this CsBasicStringView.
This method is only permitted if CS_STRING_ALLOW_UNSAFE is defined.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
template<typename S>
template<typename T, typename = typename std::enable_if<std::is_same<T, const char *>::value || std::is_same<T, char *>::value>::type>
Find the specified C style string str in this CsBasicStringView. Begin searching from iter_begin in this CsBasicStringView.
This method is only permitted if CS_STRING_ALLOW_UNSAFE is defined.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
template<typename S>
template<typename T, typename = typename std::enable_if<std::is_same<T, const char *>::value || std::is_same<T, char *>::value>::type>
Find the specified C style string str in this CsBasicStringView. Begin searching from iter_begin in this CsBasicStringView. Only the first size number of code points of str are searched.
This method is only permitted if CS_STRING_ALLOW_UNSAFE is defined.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
template<typename S>
const_iterator CsString::CsBasicStringView< S >::find_fast |
( |
CsBasicStringView<S> |
str | ) |
const |
Find the specified CsBasicStringView str in this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
Find the specified CsBasicStringView str in this CsBasicStringView. Begin searching from iter_begin in this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
template<typename S>
const_iterator CsString::CsBasicStringView< S >::find_fast |
( |
value_type |
c | ) |
const |
Find the specified CsChar c in this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
Find the specified CsChar c in this CsBasicStringView. Begin searching from iter_begin in this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
Returns the first code point in this CsBasicStringView. The behavior of this method is undefined if the string view is empty.
- See also
- back()
template<typename S>
size_type CsBasicStringView::length |
( |
| ) |
const |
Returns the number of code points in this CsBasicStringView. Returns the same result as size().
template<typename S>
CsBasicStringView< S > & CsString::CsBasicStringView< S >::operator= |
( |
const CsBasicStringView<S> & |
str | ) |
|
|
inlinedefault |
Assigns the string view str to this CsBasicStringView.
Returns a reference to this CsBasicStringView.
template<typename S>
CsBasicStringView< S > & CsString::CsBasicStringView< S >::operator= |
( |
CsBasicStringView<S> && |
str | ) |
|
|
inlinedefault |
Move assigns the string view str to this CsBasicStringView.
Returns a reference to this CsBasicStringView.
Returns the code point at position index in this CsBasicStringView. The behavior of this method is undefined if index is negative or if index is equal to or greater than the size() of the string view.
- See also
- at()
Returns a iterator to the last code point of this CsBasicStringView.
Returns a const iterator to the last code point of this CsBasicStringView.
template<typename S>
CsBasicStringView CsBasicStringView::remove_prefix |
( |
size_type |
size | ) |
const |
Moves the start of CsBasicStringView forward by size code points.
template<typename S>
CsBasicStringView CsBasicStringView::remove_suffix |
( |
size_type |
size | ) |
const |
Moves the end of CsBasicStringView backward by size code points.
Returns a iterator to the element before the first code point of this CsBasicStringView.
Returns a const iterator to the element before the first code point of this CsBasicStringView.
template<typename S>
const_iterator CsString::CsBasicStringView< S >::rfind_fast |
( |
CsBasicStringView<S> |
str | ) |
const |
Find the specified CsBasicStringView str in this CsBasicStringView, searching is from the end towards the beginning of this CsBasicStringView.
Returns an iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
Find the specified CsBasicStringView str in this CsBasicStringView. Begin searching from iter_begin, searching is from the end towards the beginning of this CsBasicStringView.
Returns and iterator to the first code point of the match. Returns an iterator to the end of the string view if no match is found.
Returns the number of code points in this CsBasicStringView. Returns the same result as length().
template<typename S>
bool CsBasicStringView::startsWith |
( |
CsBasicStringView<S> |
str | ) |
const |
Returns true if this string view starts with the string view str, otherwise returns false.
- See also
- endsWith()
template<typename S>
CsBasicStringView CsBasicStringView::substr |
( |
size_type |
indexStart = 0 , |
|
|
size_type |
size = npos |
|
) |
| const |
Returns a string view containing the code points starting at the specified indexStart position for size number of code points.
Returns an empty string view if the indexStart exceeds the length of the string view. If there are less than size code points available in the string view, starting at the given indexStart, or if size is equal to npos, the method returns all of the code points available from the specified indexStart to the end of the string view.
template<typename S>
void CsBasicStringView::swap |
( |
CsBasicStringView<S> & |
str | ) |
|
Swaps the string view str with this CsBasicStringView.
bool operator!= |
( |
CsBasicStringView< S > & |
str1, |
|
|
CsBasicStringView< S > & |
str2 |
|
) |
| |
|
related |
Returns true if string view str1 is lexically not equal to string view str2.
- See also
- compare()
bool operator< |
( |
CsBasicStringView< S > & |
str1, |
|
|
CsBasicStringView< S > & |
str2 |
|
) |
| |
|
related |
Returns true if string view str1 is lexically less than string view str2.
- See also
- compare()
bool operator<= |
( |
CsBasicStringView< S > & |
str1, |
|
|
CsBasicStringView< S > & |
str2 |
|
) |
| |
|
related |
Returns true if string view str1 is lexically less than or equal to string view str2.
- See also
- compare()
bool operator== |
( |
CsBasicStringView< S > & |
str1, |
|
|
CsBasicStringView< S > & |
str2 |
|
) |
| |
|
related |
Returns true if string view str1 is lexically equal to string view str2.
- See also
- compare()
bool operator> |
( |
CsBasicStringView< S > & |
str1, |
|
|
CsBasicStringView< S > & |
str2 |
|
) |
| |
|
related |
Returns true if string view str1 is lexically greater than string view str2.
- See also
- compare()
bool operator>= |
( |
CsBasicStringView< S > & |
str1, |
|
|
CsBasicStringView< S > & |
str2 |
|
) |
| |
|
related |
Returns true if string view str1 is lexically greater than or equal to string view str2.
- See also
- compare()