Bifrost SDK
Bifrost SDK documentation
Amino::StringView Class Reference

String view class (similar to std::string_view). More...

#include <StringView.h>

Inheritance diagram for Amino::StringView:
Amino::StringLiteral

Public Member Functions

constexpr StringView () noexcept=default
 Default constructor (empty string view) More...
 
 StringView (std::nullptr_t)=delete
 Constructing a StringView from a nullptr_t is not allowed. More...
 
constexpr StringView (char const *data, size_t size) noexcept
 Constructs a string view with the given data and size. More...
 
template<typename R , enable_if_explicitly_constructible< R > * = nullptr>
AMINO_INTERNAL_FORCEINLINE constexpr StringView (R &&r)
 StringView can be explicitly constructed from types from which std::string_view can explicitly be constructed. More...
 
template<typename R , enable_if_implicitly_constructible< R > * = nullptr>
AMINO_INTERNAL_FORCEINLINE constexpr StringView (R &&r)
 StringView can be implicitly constructed from types from which std::string_view can implicitly be constructed. More...
 
AMINO_INTERNAL_FORCEINLINE constexpr operator std::string_view () const noexcept
 std::string_view conversions More...
 
constexpr char const * data () const noexcept
 Get the string view data. More...
 
constexpr size_t size () const noexcept
 Get the size of the string view. More...
 
constexpr size_t length () const noexcept
 Get the size of the string view. More...
 
constexpr bool empty () const noexcept
 Returns whether the string view is empty or not. More...
 
constexpr char front () const noexcept
 Get the first character in the string view. More...
 
constexpr char back () const noexcept
 Get the last character in the string view. More...
 
constexpr char operator[] (size_t idx) const noexcept
 Get the character at the given index in the string view. More...
 
constexpr char const * cbegin () const noexcept
 Get an iterator to the beginning of the string view. More...
 
constexpr char const * begin () const noexcept
 Get an iterator to the beginning of the string view. More...
 
constexpr char const * cend () const noexcept
 Get an iterator to the end of the string view. More...
 
constexpr char const * end () const noexcept
 Get an iterator to the end of the string view. More...
 
constexpr bool operator== (StringView o) const noexcept
 Comparison operators. More...
 
constexpr bool operator< (StringView o) const noexcept
 Comparison operators. More...
 
constexpr bool operator> (StringView o) const noexcept
 Comparison operators. More...
 
constexpr bool operator!= (StringView o) const noexcept
 Comparison operators. More...
 
constexpr bool operator<= (StringView o) const noexcept
 Comparison operators. More...
 
constexpr bool operator>= (StringView o) const noexcept
 Comparison operators. More...
 

Detailed Description

String view class (similar to std::string_view).

Definition at line 42 of file StringView.h.

Constructor & Destructor Documentation

◆ StringView() [1/5]

constexpr Amino::StringView::StringView ( )
constexprdefaultnoexcept

Default constructor (empty string view)

◆ StringView() [2/5]

Amino::StringView::StringView ( std::nullptr_t  )
delete

Constructing a StringView from a nullptr_t is not allowed.

◆ StringView() [3/5]

constexpr Amino::StringView::StringView ( char const *  data,
size_t  size 
)
inlineconstexprnoexcept

Constructs a string view with the given data and size.

Definition at line 81 of file StringView.h.

◆ StringView() [4/5]

template<typename R , enable_if_explicitly_constructible< R > * = nullptr>
AMINO_INTERNAL_FORCEINLINE constexpr Amino::StringView::StringView ( R &&  r)
inlineexplicitconstexpr

StringView can be explicitly constructed from types from which std::string_view can explicitly be constructed.

Definition at line 87 of file StringView.h.

◆ StringView() [5/5]

template<typename R , enable_if_implicitly_constructible< R > * = nullptr>
AMINO_INTERNAL_FORCEINLINE constexpr Amino::StringView::StringView ( R &&  r)
inlineconstexpr

StringView can be implicitly constructed from types from which std::string_view can implicitly be constructed.

Note
The only exception is for raw c-strings from which the size must be obtained at runtime. In this case, the explicit constructor must be used.

Definition at line 98 of file StringView.h.

Member Function Documentation

◆ back()

constexpr char Amino::StringView::back ( ) const
inlineconstexprnoexcept

Get the last character in the string view.

Precondition
The string view must not be empty.

Definition at line 140 of file StringView.h.

◆ begin()

constexpr char const * Amino::StringView::begin ( ) const
inlineconstexprnoexcept

Get an iterator to the beginning of the string view.

Definition at line 125 of file StringView.h.

References cbegin().

◆ cbegin()

constexpr char const * Amino::StringView::cbegin ( ) const
inlineconstexprnoexcept

Get an iterator to the beginning of the string view.

Definition at line 124 of file StringView.h.

Referenced by begin().

◆ cend()

constexpr char const * Amino::StringView::cend ( ) const
inlineconstexprnoexcept

Get an iterator to the end of the string view.

Definition at line 130 of file StringView.h.

Referenced by end().

◆ data()

constexpr char const * Amino::StringView::data ( ) const
inlineconstexprnoexcept

Get the string view data.

Definition at line 109 of file StringView.h.

Referenced by operator std::string_view(), and Amino::MessageClass::operator==().

◆ empty()

constexpr bool Amino::StringView::empty ( ) const
inlineconstexprnoexcept

Returns whether the string view is empty or not.

Definition at line 120 of file StringView.h.

◆ end()

constexpr char const * Amino::StringView::end ( ) const
inlineconstexprnoexcept

Get an iterator to the end of the string view.

Definition at line 131 of file StringView.h.

References cend().

◆ front()

constexpr char Amino::StringView::front ( ) const
inlineconstexprnoexcept

Get the first character in the string view.

Precondition
The string view must not be empty.

Definition at line 136 of file StringView.h.

◆ length()

constexpr size_t Amino::StringView::length ( ) const
inlineconstexprnoexcept

Get the size of the string view.

Warning
Remember that a string view may not be null-terminated.

Definition at line 117 of file StringView.h.

References size().

◆ operator std::string_view()

AMINO_INTERNAL_FORCEINLINE constexpr Amino::StringView::operator std::string_view ( ) const
inlineconstexprnoexcept

std::string_view conversions

Definition at line 103 of file StringView.h.

References data(), and size().

◆ operator!=()

constexpr bool Amino::StringView::operator!= ( StringView  o) const
inlineconstexprnoexcept

Comparison operators.

Definition at line 157 of file StringView.h.

◆ operator<()

constexpr bool Amino::StringView::operator< ( StringView  o) const
inlineconstexprnoexcept

Comparison operators.

Definition at line 151 of file StringView.h.

◆ operator<=()

constexpr bool Amino::StringView::operator<= ( StringView  o) const
inlineconstexprnoexcept

Comparison operators.

Definition at line 160 of file StringView.h.

◆ operator==()

constexpr bool Amino::StringView::operator== ( StringView  o) const
inlineconstexprnoexcept

Comparison operators.

Definition at line 148 of file StringView.h.

References size().

◆ operator>()

constexpr bool Amino::StringView::operator> ( StringView  o) const
inlineconstexprnoexcept

Comparison operators.

Definition at line 154 of file StringView.h.

◆ operator>=()

constexpr bool Amino::StringView::operator>= ( StringView  o) const
inlineconstexprnoexcept

Comparison operators.

Definition at line 163 of file StringView.h.

◆ operator[]()

constexpr char Amino::StringView::operator[] ( size_t  idx) const
inlineconstexprnoexcept

Get the character at the given index in the string view.

Precondition
idx < size()

Definition at line 144 of file StringView.h.

◆ size()

constexpr size_t Amino::StringView::size ( ) const
inlineconstexprnoexcept

Get the size of the string view.

Warning
Remember that a string view may not be null-terminated.

Definition at line 114 of file StringView.h.

Referenced by length(), operator std::string_view(), and operator==().