Stefan Scholz / ETL
Embed: (wiki syntax)

« Back to documentation index

basic_string_view< T, TTraits > Class Template Reference

basic_string_view< T, TTraits > Class Template Reference

String view. More...

#include <string_view.h>

Public Member Functions

 basic_string_view ()
 Default constructor.
 basic_string_view (const T *begin_)
 Construct from T*.
 basic_string_view (const T *begin_, const T *end_)
 Construct from pointer range.
template<typename TSize , typename TDummy = typename etl::enable_if<etl::is_integral<TSize>::value, void>::type>
 basic_string_view (const T *begin_, TSize size_)
 Construct from iterator/size.
 basic_string_view (const basic_string_view &other)
 Copy constructor.
const_reference front () const
 Returns a const reference to the first element.
const_reference back () const
 Returns a const reference to the last element.
const_pointer data () const
 Returns a const pointer to the first element of the internal storage.
const_iterator begin () const
 Returns a const iterator to the beginning of the array.
const_iterator cbegin () const
 Returns a const iterator to the beginning of the array.
const_iterator end () const
 Returns a const iterator to the end of the array.
const_reverse_iterator rbegin () const
 Returns a const reverse iterator to the reverse beginning of the array.
const_reverse_iterator crbegin () const
 Returns a const reverse iterator to the reverse beginning of the array.
const_reverse_iterator rend () const
 Returns a const reverse iterator to the end of the array.
const_reverse_iterator crend () const
 Returns a const reverse iterator to the end of the array.
bool empty () const
 Returns true if the array size is zero.
size_t size () const
 Returns the size of the array.
size_t length () const
 Returns the size of the array.
size_t max_size () const
 Returns the maximum possible size of the array.
etl::basic_string_view< T,
TTraits > & 
operator= (const etl::basic_string_view< T, TTraits > &other)
 Assign from a view.
template<typename TIterator , typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
void assign (TIterator begin_, TIterator end_)
 Assign from iterators.
template<typename TIterator , typename TSize , typename TDummy = typename etl::enable_if<etl::is_random_iterator<TIterator>::value, void>::type>
void assign (TIterator begin_, TSize size_)
 Assign from iterator and size.
const_reference operator[] (size_t i) const
 Returns a const reference to the indexed value.
const_reference at (size_t i) const
 Returns a const reference to the indexed value.
void swap (basic_string_view &other)
 Swaps with another basic_string_view.
size_type copy (T *destination, size_type count, size_type position=0) const
 Copies characters.
basic_string_view substr (size_type position=0, size_type count=npos) const
 Returns a substring.
void remove_prefix (size_type n)
 Shrinks the view by moving its start forward.
void remove_suffix (size_type n)
 Shrinks the view by moving its end backward.
int compare (basic_string_view< T, TTraits > view) const
 Compares two views.
bool starts_with (etl::basic_string_view< T, TTraits > view) const
 Checks if the string view starts with the given prefix.
bool ends_with (etl::basic_string_view< T, TTraits > view) const
 Checks if the string view ends with the given suffix.
size_type find (etl::basic_string_view< T, TTraits > view, size_type position=0) const
 Find characters in the view.
size_type rfind (etl::basic_string_view< T, TTraits > view, size_type position=npos) const
 Find the last occurrence of a substring.
size_type find_first_of (etl::basic_string_view< T, TTraits > view, size_type position=0) const
 Find first occurrence of characters.
size_type find_last_of (etl::basic_string_view< T, TTraits > view, size_type position=npos) const
 Find last occurrence of characters.
size_type find_first_not_of (etl::basic_string_view< T, TTraits > view, size_type position=0) const
 Find first absence of characters.
size_type find_last_not_of (etl::basic_string_view< T, TTraits > view, size_type position=npos) const
 Find last absence of characters.

Friends

bool operator== (const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
 Equality for array views.
bool operator!= (const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
 Inequality for array views.
bool operator< (const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
 Less-than for array views.
bool operator> (const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
 Greater-than for array views.
bool operator<= (const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
 Less-than-equal for array views.
bool operator>= (const etl::basic_string_view< T, TTraits > &lhs, const etl::basic_string_view< T, TTraits > &rhs)
 Greater-than-equal for array views.

Detailed Description

template<typename T, typename TTraits = etl::char_traits<T>>
class etl::basic_string_view< T, TTraits >

String view.

Definition at line 104 of file string_view.h.


Constructor & Destructor Documentation

Default constructor.

Definition at line 124 of file string_view.h.

basic_string_view ( const T *  begin_ )

Construct from T*.

Definition at line 133 of file string_view.h.

basic_string_view ( const T *  begin_,
const T *  end_ 
)

Construct from pointer range.

Definition at line 142 of file string_view.h.

basic_string_view ( const T *  begin_,
TSize  size_ 
)

Construct from iterator/size.

Definition at line 152 of file string_view.h.

basic_string_view ( const basic_string_view< T, TTraits > &  other )

Copy constructor.

Definition at line 161 of file string_view.h.


Member Function Documentation

void assign ( TIterator  begin_,
TIterator  end_ 
)

Assign from iterators.

Definition at line 306 of file string_view.h.

void assign ( TIterator  begin_,
TSize  size_ 
)

Assign from iterator and size.

Definition at line 318 of file string_view.h.

const_reference at ( size_t  i ) const

Returns a const reference to the indexed value.

Definition at line 335 of file string_view.h.

const_reference back (  ) const

Returns a const reference to the last element.

Definition at line 178 of file string_view.h.

const_iterator begin (  ) const

Returns a const iterator to the beginning of the array.

Definition at line 194 of file string_view.h.

const_iterator cbegin (  ) const

Returns a const iterator to the beginning of the array.

Definition at line 202 of file string_view.h.

int compare ( basic_string_view< T, TTraits >  view ) const

Compares two views.

Definition at line 404 of file string_view.h.

size_type copy ( T *  destination,
size_type  count,
size_type  position = 0 
) const

Copies characters.

Definition at line 354 of file string_view.h.

const_reverse_iterator crbegin (  ) const

Returns a const reverse iterator to the reverse beginning of the array.

Definition at line 234 of file string_view.h.

const_reverse_iterator crend (  ) const

Returns a const reverse iterator to the end of the array.

Definition at line 250 of file string_view.h.

const_pointer data (  ) const

Returns a const pointer to the first element of the internal storage.

Definition at line 186 of file string_view.h.

bool empty (  ) const

Returns true if the array size is zero.

Definition at line 262 of file string_view.h.

const_iterator end (  ) const

Returns a const iterator to the end of the array.

Definition at line 210 of file string_view.h.

bool ends_with ( etl::basic_string_view< T, TTraits >  view ) const

Checks if the string view ends with the given suffix.

Definition at line 461 of file string_view.h.

size_type find ( etl::basic_string_view< T, TTraits >  view,
size_type  position = 0 
) const

Find characters in the view.

Definition at line 484 of file string_view.h.

size_type find_first_not_of ( etl::basic_string_view< T, TTraits >  view,
size_type  position = 0 
) const

Find first absence of characters.

Definition at line 652 of file string_view.h.

size_type find_first_of ( etl::basic_string_view< T, TTraits >  view,
size_type  position = 0 
) const

Find first occurrence of characters.

Definition at line 563 of file string_view.h.

size_type find_last_not_of ( etl::basic_string_view< T, TTraits >  view,
size_type  position = npos 
) const

Find last absence of characters.

Definition at line 700 of file string_view.h.

size_type find_last_of ( etl::basic_string_view< T, TTraits >  view,
size_type  position = npos 
) const

Find last occurrence of characters.

Definition at line 604 of file string_view.h.

const_reference front (  ) const

Returns a const reference to the first element.

Definition at line 170 of file string_view.h.

size_t length (  ) const

Returns the size of the array.

Definition at line 278 of file string_view.h.

size_t max_size (  ) const

Returns the maximum possible size of the array.

Definition at line 286 of file string_view.h.

etl::basic_string_view<T, TTraits>& operator= ( const etl::basic_string_view< T, TTraits > &  other )

Assign from a view.

Definition at line 294 of file string_view.h.

const_reference operator[] ( size_t  i ) const

Returns a const reference to the indexed value.

Definition at line 327 of file string_view.h.

const_reverse_iterator rbegin (  ) const

Returns a const reverse iterator to the reverse beginning of the array.

Definition at line 226 of file string_view.h.

void remove_prefix ( size_type  n )

Shrinks the view by moving its start forward.

Definition at line 388 of file string_view.h.

void remove_suffix ( size_type  n )

Shrinks the view by moving its end backward.

Definition at line 396 of file string_view.h.

const_reverse_iterator rend (  ) const

Returns a const reverse iterator to the end of the array.

Definition at line 242 of file string_view.h.

size_type rfind ( etl::basic_string_view< T, TTraits >  view,
size_type  position = npos 
) const

Find the last occurrence of a substring.

Definition at line 521 of file string_view.h.

size_t size (  ) const

Returns the size of the array.

Definition at line 270 of file string_view.h.

bool starts_with ( etl::basic_string_view< T, TTraits >  view ) const

Checks if the string view starts with the given prefix.

Definition at line 439 of file string_view.h.

basic_string_view substr ( size_type  position = 0,
size_type  count = npos 
) const

Returns a substring.

Definition at line 371 of file string_view.h.

void swap ( basic_string_view< T, TTraits > &  other )

Swaps with another basic_string_view.

Definition at line 345 of file string_view.h.


Friends And Related Function Documentation

bool operator!= ( const etl::basic_string_view< T, TTraits > &  lhs,
const etl::basic_string_view< T, TTraits > &  rhs 
) [friend]

Inequality for array views.

Definition at line 764 of file string_view.h.

bool operator< ( const etl::basic_string_view< T, TTraits > &  lhs,
const etl::basic_string_view< T, TTraits > &  rhs 
) [friend]

Less-than for array views.

Definition at line 772 of file string_view.h.

bool operator<= ( const etl::basic_string_view< T, TTraits > &  lhs,
const etl::basic_string_view< T, TTraits > &  rhs 
) [friend]

Less-than-equal for array views.

Definition at line 788 of file string_view.h.

bool operator== ( const etl::basic_string_view< T, TTraits > &  lhs,
const etl::basic_string_view< T, TTraits > &  rhs 
) [friend]

Equality for array views.

Definition at line 755 of file string_view.h.

bool operator> ( const etl::basic_string_view< T, TTraits > &  lhs,
const etl::basic_string_view< T, TTraits > &  rhs 
) [friend]

Greater-than for array views.

Definition at line 780 of file string_view.h.

bool operator>= ( const etl::basic_string_view< T, TTraits > &  lhs,
const etl::basic_string_view< T, TTraits > &  rhs 
) [friend]

Greater-than-equal for array views.

Definition at line 796 of file string_view.h.