tdslite latest
C++ API reference
Loading...
Searching...
No Matches
tdsl::string_view Struct Reference

String view. More...

#include <tdslite/util/tdsl_string_view.hpp>

Public Types

using base_type = tdsl::char_view
 
using element_type = T
 
using value_type = typename traits::remove_cv< T >::type
 
using size_type = tdsl::size_t
 
using ssize_type = tdsl::ssize_t
 
using pointer = T *
 
using const_pointer = const T *
 
using reference = T &
 
using const_reference = const T &
 
using iterator = pointer
 
using const_iterator = const_pointer
 
using self_type = span< element_type >
 

Public Member Functions

 string_view (const base_type &other) noexcept
 
 string_view (base_type &&other) noexcept
 
 string_view () noexcept
 
template<tdsl::uint32_t N>
 string_view (const char(&str)[N]) noexcept
 
constexpr span () noexcept=default
 Default c-tor.
 
constexpr span (const self_type &other) noexcept
 Copy c-tor.
 
constexpr span (self_type &&other) noexcept
 Move c-tor.
 
constexpr span (element_type *elem, size_type elem_count) noexcept
 Construct a new span object.
 
constexpr span (element_type *begin, element_type *end) noexcept
 Construct a new span object from explicit begin and end parameters.
 
template<size_type N>
constexpr span (element_type(&buffer)[N]) noexcept
 Construct a new span object from a fixed-size array.
 
constexpr bool operator== (const self_type &other) const noexcept
 Equality comparison operator.
 
constexpr auto size_bytes () const noexcept -> size_type
 Get the amount of the bytes in the span.
 
constexpr auto size () const noexcept -> size_type
 Get the amount of the elements in the span.
 
constexpr auto ssize () const noexcept -> ssize_type
 Get the amount of the elements in the span.
 
constexpr auto data () const noexcept -> pointer
 Data pointer.
 
constexpr auto begin () const noexcept -> iterator
 Iterator interface begin() function.
 
constexpr auto end () const noexcept -> iterator
 Iterator interface end() function.
 
constexpr auto cbegin () const noexcept -> const_iterator
 Iterator interface begin() function.
 
constexpr auto cend () const noexcept -> const_iterator
 Iterator interface end() function.
 
auto operator[] (size_type index) const noexcept -> reference
 Subscript operator.
 
 operator bool () const noexcept
 Make span boolable, so it can be used expressions like: span<int> span_v; ... if(span_v){ ..do stuff.
 
template<typename Q , traits::enable_when::integral< Q > = true>
constexpr auto rebind_cast () const noexcept -> span< const Q >
 Cast span to another span with new element type.
 

Protected Attributes

size_type element_count {0}
 Size of the span (in element count)
 

Detailed Description

String view.

If given character array is nul-terminated, the span will omit the nul terminator from span range.

Member Typedef Documentation

◆ base_type

◆ element_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::element_type = T
inherited

◆ value_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::value_type = typename traits::remove_cv<T>::type
inherited

◆ size_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::size_type = tdsl::size_t
inherited

◆ ssize_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::ssize_type = tdsl::ssize_t
inherited

◆ pointer

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::pointer = T *
inherited

◆ const_pointer

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::const_pointer = const T *
inherited

◆ reference

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::reference = T &
inherited

◆ const_reference

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::const_reference = const T &
inherited

◆ iterator

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::iterator = pointer
inherited

◆ const_iterator

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::const_iterator = const_pointer
inherited

◆ self_type

template<typename T = const tdsl::uint8_t>
using tdsl::span< T >::self_type = span<element_type>
inherited

Constructor & Destructor Documentation

◆ string_view() [1/4]

tdsl::string_view::string_view ( const base_type &  other)
inlinenoexcept

◆ string_view() [2/4]

tdsl::string_view::string_view ( base_type &&  other)
inlinenoexcept

◆ string_view() [3/4]

tdsl::string_view::string_view ( )
inlinenoexcept

◆ string_view() [4/4]

template<tdsl::uint32_t N>
tdsl::string_view::string_view ( const char(&)  str[N])
inlinenoexcept

Member Function Documentation

◆ span() [1/6]

constexpr tdsl::span< T >::span ( )
inlineconstexprdefaultnoexcept

Default c-tor.

◆ span() [2/6]

constexpr tdsl::span< T >::span ( const self_type &  other)
inlineconstexprnoexcept

Copy c-tor.

◆ span() [3/6]

constexpr tdsl::span< T >::span ( self_type &&  other)
inlineconstexprnoexcept

Move c-tor.

◆ span() [4/6]

constexpr tdsl::span< T >::span ( element_type *  elem,
size_type  elem_count 
)
inlineexplicitconstexprnoexcept

Construct a new span object.

Parameters
[in]elemPointer to the starting element
[in]elem_countElement count

◆ span() [5/6]

constexpr tdsl::span< T >::span ( element_type *  begin,
element_type *  end 
)
inlineexplicitconstexprnoexcept

Construct a new span object from explicit begin and end parameters.

Parameters
[in]beginStart of the span.
[in]endEnd of the span. Must be greater than begin
Note
end must point to one past last element
start must be always lesser than end
end must be always greater than start

◆ span() [6/6]

template<size_type N>
constexpr tdsl::span< T >::span ( element_type(&)  buffer[N])
inlineconstexprnoexcept

Construct a new span object from a fixed-size array.

Template Parameters
NAuto-deduced length of the array
Parameters
[in]bufferFixed-size buffer

◆ operator==()

template<typename T = const tdsl::uint8_t>
constexpr bool tdsl::span< T >::operator== ( const self_type &  other) const
inlineconstexprnoexceptinherited

Equality comparison operator.

Two spans are considered equal if they point to same memory

Parameters
[in]otherSpan to compare against
Returns
true Spans are equal
false otherwise

◆ size_bytes()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::size_bytes ( ) const -> size_type
inlineconstexprnoexceptinherited

Get the amount of the bytes in the span.

Returns
size_type Amount of the bytes in the span

◆ size()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::size ( ) const -> size_type
inlineconstexprnoexceptinherited

Get the amount of the elements in the span.

Returns
size_type Amount of the element in the span

◆ ssize()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::ssize ( ) const -> ssize_type
inlineconstexprnoexceptinherited

Get the amount of the elements in the span.

Returns
size_type Amount of the element in the span

◆ data()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::data ( ) const -> pointer
inlineconstexprnoexceptinherited

Data pointer.

Returns
T* Pointer to the beginning of the span

◆ begin()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::begin ( ) const -> iterator
inlineconstexprnoexceptinherited

Iterator interface begin() function.

Returns
T* Pointer to the beginning of the span

◆ end()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::end ( ) const -> iterator
inlineconstexprnoexceptinherited

Iterator interface end() function.

Returns
T* Pointer to the one past last element of the span

◆ cbegin()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::cbegin ( ) const -> const_iterator
inlineconstexprnoexceptinherited

Iterator interface begin() function.

Returns
T* Pointer to the beginning of the span

◆ cend()

template<typename T = const tdsl::uint8_t>
constexpr auto tdsl::span< T >::cend ( ) const -> const_iterator
inlineconstexprnoexceptinherited

Iterator interface end() function.

Returns
T* Pointer to the one past last element of the span

◆ operator[]()

template<typename T = const tdsl::uint8_t>
auto tdsl::span< T >::operator[] ( size_type  index) const -> reference
inlinenoexceptinherited

Subscript operator.

Parameters
[in]indexElement to access
Returns
reference Reference to the element

◆ operator bool()

template<typename T = const tdsl::uint8_t>
tdsl::span< T >::operator bool ( ) const
inlinenoexceptinherited

Make span boolable, so it can be used expressions like: span<int> span_v; ... if(span_v){ ..do stuff.

}

Returns
true if data is not nullptr and size is greater than zero
false otherwise

◆ rebind_cast()

template<typename T = const tdsl::uint8_t>
template<typename Q , traits::enable_when::integral< Q > = true>
constexpr auto tdsl::span< T >::rebind_cast ( ) const -> span<const Q>
inlineconstexprnoexceptinherited

Cast span to another span with new element type.

Template Parameters
QNew element type
Returns
span<const Q> New span
Note
If the original span's size_bytes() is not a multiple of sizeof(Q), the element count of the resulting span will be rounded down.

Member Data Documentation

◆ element_count

template<typename T = const tdsl::uint8_t>
size_type tdsl::span< T >::element_count {0}
protectedinherited

Size of the span (in element count)


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