Zserio C++ runtime library  1.2.0
Built for Zserio 2.16.0
zserio::BasicStringView< CharT, Traits > Class Template Reference

#include <StringView.h>

Public Types

using traits_type = Traits
 
using value_type = CharT
 
using pointer = CharT *
 
using const_pointer = const CharT *
 
using reference = CharT &
 
using const_reference = const CharT &
 
using const_iterator = const_pointer
 
using iterator = const_iterator
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 
using reverse_iterator = const_reverse_iterator
 
using size_type = size_t
 
using difference_type = ptrdiff_t
 

Public Member Functions

constexpr BasicStringView () noexcept=default
 
 BasicStringView (const const_pointer str) noexcept
 
constexpr BasicStringView (const const_pointer str, const size_type count) noexcept
 
template<typename ALLOC >
constexpr BasicStringView (const std::basic_string< CharT, Traits, ALLOC > &str) noexcept
 
constexpr const_iterator begin () const noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr const_iterator cend () const noexcept
 
constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator rend () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
constexpr const_reference operator[] (const size_type pos) const noexcept
 
const_reference at (const size_type pos) const
 
constexpr const_reference front () const noexcept
 
constexpr const_reference back () const noexcept
 
constexpr const_pointer data () const noexcept
 
constexpr size_type size () const noexcept
 
constexpr size_type length () const noexcept
 
constexpr size_type max_size () const noexcept
 
constexpr bool empty () const noexcept
 
void remove_prefix (size_type n)
 
void remove_suffix (size_type n)
 
void swap (BasicStringView &other) noexcept
 
size_type copy (CharT *dest, size_type count, size_type pos=0) const
 
BasicStringView substr (size_type pos=0, size_type count=npos) const
 
int compare (BasicStringView other) const noexcept
 
int compare (size_type pos1, size_type count1, BasicStringView other) const
 
int compare (size_type pos1, size_type count1, BasicStringView other, size_type pos2, size_type count2) const
 
int compare (const CharT *str) const
 
int compare (size_type pos1, size_type count1, const CharT *str) const
 
int compare (size_type pos1, size_type count1, const CharT *str, size_type count2) const
 
size_type find (BasicStringView str, size_type pos=0) const noexcept
 
size_type find (CharT character, size_type pos=0) const noexcept
 
size_type find (const CharT *str, size_type pos, size_type count) const
 
size_type find (const CharT *str, size_type pos=0) const
 
size_type rfind (BasicStringView str, size_type pos=npos) const noexcept
 
size_type rfind (CharT character, size_type pos=npos) const noexcept
 
size_type rfind (const CharT *str, size_type pos, size_type count) const
 
size_type rfind (const CharT *str, size_type pos=npos) const
 
size_type find_first_of (BasicStringView str, size_type pos=0) const noexcept
 
size_type find_first_of (CharT character, size_type pos=0) const noexcept
 
size_type find_first_of (const CharT *str, size_type pos, size_type count) const
 
size_type find_first_of (const CharT *str, size_type pos=0) const
 
size_type find_last_of (BasicStringView str, size_type pos=npos) const noexcept
 
size_type find_last_of (CharT character, size_type pos=npos) const noexcept
 
size_type find_last_of (const CharT *str, size_type pos, size_type count) const
 
size_type find_last_of (const CharT *str, size_type pos=npos) const
 
size_type find_first_not_of (BasicStringView str, size_type pos=0) const noexcept
 
size_type find_first_not_of (CharT character, size_type pos=0) const noexcept
 
size_type find_first_not_of (const CharT *str, size_type pos, size_type count) const
 
size_type find_first_not_of (const CharT *str, size_type pos=0) const
 
size_type find_last_not_of (BasicStringView str, size_type pos=npos) const noexcept
 
size_type find_last_not_of (CharT character, size_type pos=npos) const noexcept
 
size_type find_last_not_of (const CharT *str, size_type pos, size_type count) const
 
size_type find_last_not_of (const CharT *str, size_type pos=npos) const
 
 ~BasicStringView ()=default
 
 BasicStringView (const BasicStringView &) noexcept=default
 
BasicStringViewoperator= (const BasicStringView &) noexcept=default
 
 BasicStringView (BasicStringView &&) noexcept=default
 
BasicStringViewoperator= (BasicStringView &&) noexcept=default
 

Static Public Attributes

static constexpr const size_type npos = static_cast<size_type>(-1)
 

Detailed Description

template<typename CharT, typename Traits = std::char_traits<CharT>>
class zserio::BasicStringView< CharT, Traits >

Non-owning constant view to a string. The user of this class is responsible of making sure, that the referenced string is valid as long as the view is alive. Inspired by C++17 std::basic_string_view.

Definition at line 23 of file StringView.h.

Member Typedef Documentation

◆ const_iterator

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::const_iterator = const_pointer

Definition at line 32 of file StringView.h.

◆ const_pointer

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::const_pointer = const CharT*

Definition at line 29 of file StringView.h.

◆ const_reference

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::const_reference = const CharT&

Definition at line 31 of file StringView.h.

◆ const_reverse_iterator

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::const_reverse_iterator = std::reverse_iterator<const_iterator>

Definition at line 34 of file StringView.h.

◆ difference_type

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::difference_type = ptrdiff_t

Definition at line 37 of file StringView.h.

◆ iterator

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::iterator = const_iterator

Definition at line 33 of file StringView.h.

◆ pointer

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::pointer = CharT*

Definition at line 28 of file StringView.h.

◆ reference

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::reference = CharT&

Definition at line 30 of file StringView.h.

◆ reverse_iterator

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::reverse_iterator = const_reverse_iterator

Definition at line 35 of file StringView.h.

◆ size_type

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::size_type = size_t

Definition at line 36 of file StringView.h.

◆ traits_type

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::traits_type = Traits

Definition at line 26 of file StringView.h.

◆ value_type

template<typename CharT , typename Traits = std::char_traits<CharT>>
using zserio::BasicStringView< CharT, Traits >::value_type = CharT

Definition at line 27 of file StringView.h.

Constructor & Destructor Documentation

◆ BasicStringView() [1/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr zserio::BasicStringView< CharT, Traits >::BasicStringView ( )
constexprdefaultnoexcept

Constructor. Initializes empty view.

◆ BasicStringView() [2/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
zserio::BasicStringView< CharT, Traits >::BasicStringView ( const const_pointer  str)
inlinenoexcept

Constructor. Initializes string view to given null-terminated string.

Parameters
strInput null-terminated string.

Definition at line 54 of file StringView.h.

◆ BasicStringView() [3/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr zserio::BasicStringView< CharT, Traits >::BasicStringView ( const const_pointer  str,
const size_type  count 
)
inlineconstexprnoexcept

Constructor. Initializes string view to given string with given length.

Parameters
strInput string.
countLength of the view. Shall not be longer than the input string.

Definition at line 65 of file StringView.h.

◆ BasicStringView() [4/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
template<typename ALLOC >
constexpr zserio::BasicStringView< CharT, Traits >::BasicStringView ( const std::basic_string< CharT, Traits, ALLOC > &  str)
inlineconstexprnoexcept

Constructor. Initializes string view to given std::basic_string

Parameters
strInput string.

Definition at line 76 of file StringView.h.

◆ ~BasicStringView()

template<typename CharT , typename Traits = std::char_traits<CharT>>
zserio::BasicStringView< CharT, Traits >::~BasicStringView ( )
default

Method generated by default.

◆ BasicStringView() [5/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
zserio::BasicStringView< CharT, Traits >::BasicStringView ( const BasicStringView< CharT, Traits > &  )
defaultnoexcept

Method generated by default.

◆ BasicStringView() [6/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
zserio::BasicStringView< CharT, Traits >::BasicStringView ( BasicStringView< CharT, Traits > &&  )
defaultnoexcept

Method generated by default.

Member Function Documentation

◆ at()

template<typename CharT , typename Traits = std::char_traits<CharT>>
const_reference zserio::BasicStringView< CharT, Traits >::at ( const size_type  pos) const
inline

Element access operator. Returns reference to the element of the referenced string at given index.

Parameters
posIndex of the element to access.
Returns
Reference to the string element at given index.
Exceptions
CppRuntimeExceptionif pos is not less than size().

Definition at line 195 of file StringView.h.

◆ back()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reference zserio::BasicStringView< CharT, Traits >::back ( ) const
inlineconstexprnoexcept

Get reference to the last element of the string. The string shall not be empty.

Returns
Reference to the last element of the string.

Definition at line 220 of file StringView.h.

◆ begin()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator zserio::BasicStringView< CharT, Traits >::begin ( ) const
inlineconstexprnoexcept

Begin iteration.

Returns
Iterator to the beginning of the referenced string.

Definition at line 101 of file StringView.h.

◆ cbegin()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator zserio::BasicStringView< CharT, Traits >::cbegin ( ) const
inlineconstexprnoexcept

Begin iteration.

Returns
Iterator to the beginning of the referenced string.

Definition at line 111 of file StringView.h.

◆ cend()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator zserio::BasicStringView< CharT, Traits >::cend ( ) const
inlineconstexprnoexcept

End iteration.

Returns
Iterator one-past-end of the referenced string.

Definition at line 131 of file StringView.h.

◆ compare() [1/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int zserio::BasicStringView< CharT, Traits >::compare ( BasicStringView< CharT, Traits >  other) const
inlinenoexcept

Compare this string view to other.

Parameters
otherSecond string view.
Returns
<0, if this view is considered less than the other, ==0, if both views are same, >0, if this view is considered greater than the other.

Definition at line 356 of file StringView.h.

◆ compare() [2/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int zserio::BasicStringView< CharT, Traits >::compare ( const CharT *  str) const
inline

Compare this string view to other.

Parameters
strString to compare with.
Returns
<0, if this view is considered less than the other, ==0, if both views are same, >0, if this view is considered greater than the other.

Definition at line 417 of file StringView.h.

◆ compare() [3/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int zserio::BasicStringView< CharT, Traits >::compare ( size_type  pos1,
size_type  count1,
BasicStringView< CharT, Traits >  other 
) const
inline

Compare this string view to other.

Parameters
pos1Start position in this view.
count1Number of elements in the view.
otherSecond string view.
Returns
<0, if this view is considered less than the other, ==0, if both views are same, >0, if this view is considered greater than the other.

Definition at line 389 of file StringView.h.

◆ compare() [4/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int zserio::BasicStringView< CharT, Traits >::compare ( size_type  pos1,
size_type  count1,
BasicStringView< CharT, Traits >  other,
size_type  pos2,
size_type  count2 
) const
inline

Compare this string view to other.

Parameters
pos1Start position in this view.
count1Number of elements in the view.
otherSecond string view.
pos2Start position in the other view.
count2Number of element in the other view.
Returns
<0, if this view is considered less than the other, ==0, if both views are same, >0, if this view is considered greater than the other.

Definition at line 405 of file StringView.h.

◆ compare() [5/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int zserio::BasicStringView< CharT, Traits >::compare ( size_type  pos1,
size_type  count1,
const CharT *  str 
) const
inline

Compare this string view to other.

Parameters
pos1Start position in this view.
count1Number of elements in the view.
strString to compare with.
Returns
<0, if this view is considered less than the other, ==0, if both views are same, >0, if this view is considered greater than the other.

Definition at line 431 of file StringView.h.

◆ compare() [6/6]

template<typename CharT , typename Traits = std::char_traits<CharT>>
int zserio::BasicStringView< CharT, Traits >::compare ( size_type  pos1,
size_type  count1,
const CharT *  str,
size_type  count2 
) const
inline

Compare this string view to other.

Parameters
pos1Start position in this view.
count1Number of elements in the view.
strString to compare with.
count2Number of element in the str.
Returns
<0, if this view is considered less than the other, ==0, if both views are same, >0, if this view is considered greater than the other.

Definition at line 446 of file StringView.h.

◆ copy()

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::copy ( CharT *  dest,
size_type  count,
size_type  pos = 0 
) const
inline

Copy the specified amount of elements from the string view to given buffer.

Parameters
destBuffer where the substring should be copied.
countNumber of elements to copy.
posOffset in the string view, where the copy should begin.
Returns
Number of elements actually copied.
Exceptions
CppRuntimeExceptionif pos is > size().

Definition at line 317 of file StringView.h.

◆ crbegin()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator zserio::BasicStringView< CharT, Traits >::crbegin ( ) const
inlineconstexprnoexcept

Begin reverse iteration.

Returns
Reverse iterator to the end of the referenced string.

Definition at line 151 of file StringView.h.

◆ crend()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator zserio::BasicStringView< CharT, Traits >::crend ( ) const
inlineconstexprnoexcept

End reverse iteration.

Returns
Reverse iterator one-before-beginning of the referenced string.

Definition at line 171 of file StringView.h.

◆ data()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_pointer zserio::BasicStringView< CharT, Traits >::data ( ) const
inlineconstexprnoexcept

Get pointer to the beginning of the referenced string.

Returns
Pointer to the beginning of the referenced string.

Definition at line 230 of file StringView.h.

◆ empty()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr bool zserio::BasicStringView< CharT, Traits >::empty ( ) const
inlineconstexprnoexcept

Check if the string is empty.

Returns
True if the string is empty, false otherwise.

Definition at line 270 of file StringView.h.

◆ end()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_iterator zserio::BasicStringView< CharT, Traits >::end ( ) const
inlineconstexprnoexcept

End iteration.

Returns
Iterator one-past-end of the referenced string.

Definition at line 121 of file StringView.h.

◆ find() [1/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find ( BasicStringView< CharT, Traits >  str,
size_type  pos = 0 
) const
inlinenoexcept

Find position of given string view in this string view.

Parameters
strString to search.
posPosition where the start the search.
Returns
Index of the found string or npos if the string was not found.

Definition at line 458 of file StringView.h.

◆ find() [2/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find ( CharT  character,
size_type  pos = 0 
) const
inlinenoexcept

Find position of given char in this string view.

Parameters
characterChar to search.
posPosition where the start the search.
Returns
Index of the found char or npos if the string was not found.

Definition at line 497 of file StringView.h.

◆ find() [3/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find ( const CharT *  str,
size_type  pos,
size_type  count 
) const
inline

Find position of given string in this string view.

Parameters
strString to search.
posPosition where the start the search.
countLength of str.
Returns
Index of the found string or npos if the string was not found.

Definition at line 510 of file StringView.h.

◆ find() [4/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find ( const CharT *  str,
size_type  pos = 0 
) const
inline

Find position of given null-terminated string in this string view.

Parameters
strString to search.
posPosition where the start the search.
Returns
Index of the found string or npos if the string was not found.

Definition at line 522 of file StringView.h.

◆ find_first_not_of() [1/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_not_of ( BasicStringView< CharT, Traits >  str,
size_type  pos = 0 
) const
inlinenoexcept

Finds the first character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 719 of file StringView.h.

◆ find_first_not_of() [2/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_not_of ( CharT  character,
size_type  pos = 0 
) const
inlinenoexcept

Finds the first character not equal to the given character.

Parameters
characterCharacter to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 744 of file StringView.h.

◆ find_first_not_of() [3/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_not_of ( const CharT *  str,
size_type  pos,
size_type  count 
) const
inline

Finds the first character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
countNumber of characters in str.
Returns
Found position or npos if no such character was found.

Definition at line 757 of file StringView.h.

◆ find_first_not_of() [4/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_not_of ( const CharT *  str,
size_type  pos = 0 
) const
inline

Finds the first character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 769 of file StringView.h.

◆ find_first_of() [1/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_of ( BasicStringView< CharT, Traits >  str,
size_type  pos = 0 
) const
inlinenoexcept

Find the position of the first character equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 595 of file StringView.h.

◆ find_first_of() [2/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_of ( CharT  character,
size_type  pos = 0 
) const
inlinenoexcept

Find the position of the first character equal to the given character.

Parameters
characterCharacter to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 620 of file StringView.h.

◆ find_first_of() [3/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_of ( const CharT *  str,
size_type  pos,
size_type  count 
) const
inline

Find the position of the first character equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
countNumber of character in str.
Returns
Found position or npos if no such character was found.

Definition at line 633 of file StringView.h.

◆ find_first_of() [4/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_first_of ( const CharT *  str,
size_type  pos = 0 
) const
inline

Find the position of the first character equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 645 of file StringView.h.

◆ find_last_not_of() [1/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_not_of ( BasicStringView< CharT, Traits >  str,
size_type  pos = npos 
) const
inlinenoexcept

Find the last character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 781 of file StringView.h.

◆ find_last_not_of() [2/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_not_of ( CharT  character,
size_type  pos = npos 
) const
inlinenoexcept

Find the last character not equal to the given character.

Parameters
characterCharacter to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 806 of file StringView.h.

◆ find_last_not_of() [3/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_not_of ( const CharT *  str,
size_type  pos,
size_type  count 
) const
inline

Find the last character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
countNumber of characters in str.
Returns
Found position or npos if no such character was found.

Definition at line 819 of file StringView.h.

◆ find_last_not_of() [4/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_not_of ( const CharT *  str,
size_type  pos = npos 
) const
inline

Find the last character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 831 of file StringView.h.

◆ find_last_of() [1/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_of ( BasicStringView< CharT, Traits >  str,
size_type  pos = npos 
) const
inlinenoexcept

Find the last character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 657 of file StringView.h.

◆ find_last_of() [2/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_of ( CharT  character,
size_type  pos = npos 
) const
inlinenoexcept

Find the last character not equal to the given character.

Parameters
characterCharacter to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 682 of file StringView.h.

◆ find_last_of() [3/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_of ( const CharT *  str,
size_type  pos,
size_type  count 
) const
inline

Find the last character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
countNumber of characters in str.
Returns
Found position or npos if no such character was found.

Definition at line 695 of file StringView.h.

◆ find_last_of() [4/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::find_last_of ( const CharT *  str,
size_type  pos = npos 
) const
inline

Find the last character not equal to any of the characters in the given character sequence.

Parameters
strSequence to search.
posPosition where to start the search.
Returns
Found position or npos if no such character was found.

Definition at line 707 of file StringView.h.

◆ front()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reference zserio::BasicStringView< CharT, Traits >::front ( ) const
inlineconstexprnoexcept

Get reference to the first element of the string. The string shall not be empty.

Returns
Reference to the first element of the string.

Definition at line 210 of file StringView.h.

◆ length()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type zserio::BasicStringView< CharT, Traits >::length ( ) const
inlineconstexprnoexcept

Get referenced string length.

Returns
The string length.

Definition at line 250 of file StringView.h.

◆ max_size()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type zserio::BasicStringView< CharT, Traits >::max_size ( ) const
inlineconstexprnoexcept

Get max. allowed string length.

Returns
Max. allowed string length.

Definition at line 260 of file StringView.h.

◆ operator=() [1/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
BasicStringView& zserio::BasicStringView< CharT, Traits >::operator= ( BasicStringView< CharT, Traits > &&  )
defaultnoexcept

Method generated by default.

◆ operator=() [2/2]

template<typename CharT , typename Traits = std::char_traits<CharT>>
BasicStringView& zserio::BasicStringView< CharT, Traits >::operator= ( const BasicStringView< CharT, Traits > &  )
defaultnoexcept

Method generated by default.

◆ operator[]()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reference zserio::BasicStringView< CharT, Traits >::operator[] ( const size_type  pos) const
inlineconstexprnoexcept

Element access operator. Returns reference to the element of the referenced string at given index.

Parameters
posIndex of the element to access. Shall be less than size().
Returns
Reference to the string element at given index.

Definition at line 182 of file StringView.h.

◆ rbegin()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator zserio::BasicStringView< CharT, Traits >::rbegin ( ) const
inlineconstexprnoexcept

Begin reverse iteration.

Returns
Reverse iterator to the end of the referenced string.

Definition at line 141 of file StringView.h.

◆ remove_prefix()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void zserio::BasicStringView< CharT, Traits >::remove_prefix ( size_type  n)
inline

Modify the string view so that it skips specified amount of elements at the beginning.

Parameters
nNumber of elements to skip. Shall not be greater than size().

Definition at line 280 of file StringView.h.

◆ remove_suffix()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void zserio::BasicStringView< CharT, Traits >::remove_suffix ( size_type  n)
inline

Modify the string view so that it skips specified amount of elements at the end.

Parameters
nNumber of elements to skip. Shall not be greater than size().

Definition at line 291 of file StringView.h.

◆ rend()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr const_reverse_iterator zserio::BasicStringView< CharT, Traits >::rend ( ) const
inlineconstexprnoexcept

End reverse iteration.

Returns
Reverse iterator one-before-beginning of the referenced string.

Definition at line 161 of file StringView.h.

◆ rfind() [1/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::rfind ( BasicStringView< CharT, Traits >  str,
size_type  pos = npos 
) const
inlinenoexcept

Find position of given string view in this string view, starting from the view end.

Parameters
strString to search.
posPosition where the start the search.
Returns
Index of the found string or npos if the string was not found.

Definition at line 534 of file StringView.h.

◆ rfind() [2/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::rfind ( CharT  character,
size_type  pos = npos 
) const
inlinenoexcept

Find position of given char in this string view, starting from the view end.

Parameters
characterChar to search.
posPosition where the start the search.
Returns
Index of the found char or npos if the string was not found.

Definition at line 559 of file StringView.h.

◆ rfind() [3/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::rfind ( const CharT *  str,
size_type  pos,
size_type  count 
) const
inline

Find position of given null-terminated string in this string view, starting from the view end.

Parameters
strString to search.
posPosition where the start the search.
Returns
Index of the found string or npos if the string was not found.

Definition at line 571 of file StringView.h.

◆ rfind() [4/4]

template<typename CharT , typename Traits = std::char_traits<CharT>>
size_type zserio::BasicStringView< CharT, Traits >::rfind ( const CharT *  str,
size_type  pos = npos 
) const
inline

Find position of given null-terminated string in this string view, starting from the view end.

Parameters
strString to search.
posPosition where the start the search.
Returns
Index of the found string or npos if the string was not found.

Definition at line 583 of file StringView.h.

◆ size()

template<typename CharT , typename Traits = std::char_traits<CharT>>
constexpr size_type zserio::BasicStringView< CharT, Traits >::size ( ) const
inlineconstexprnoexcept

Get referenced string length.

Returns
The string length.

Definition at line 240 of file StringView.h.

◆ substr()

template<typename CharT , typename Traits = std::char_traits<CharT>>
BasicStringView zserio::BasicStringView< CharT, Traits >::substr ( size_type  pos = 0,
size_type  count = npos 
) const
inline

Calculate string sub-view.

Parameters
posPosition in this view, where the sub-view should start.
countNumber of element in the sub-view.
Returns
Calculated sub-view.
Exceptions
CppRuntimeExceptionif pos is > size().

Definition at line 338 of file StringView.h.

◆ swap()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void zserio::BasicStringView< CharT, Traits >::swap ( BasicStringView< CharT, Traits > &  other)
inlinenoexcept

Swap the content with another string view.

Parameters
otherAnother string view

Definition at line 301 of file StringView.h.

Member Data Documentation

◆ npos

template<typename CharT , class Traits >
constexpr std::size_t const zserio::BasicStringView< CharT, Traits >::npos = static_cast<size_type>(-1)
staticconstexpr

Constant used to indicate end of view or "not a position", depending on context.

Definition at line 42 of file StringView.h.


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