nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
nros::StringView Struct Reference

#include <span.hpp>

Public Member Functions

constexpr const charbegin () const
 Iterator to the first byte.
 
constexpr const chardata () const
 Pointer to the underlying bytes.
 
constexpr bool empty () const
 True if the view contains zero bytes.
 
constexpr const charend () const
 Iterator past the last byte.
 
bool equals (const char *cstr) const
 True if cstr (null-terminated) has the same length and bytes.
 
constexpr char operator[] (size_t i) const
 Byte access; no bounds check.
 
constexpr size_t size () const
 Number of bytes.
 

Public Attributes

size_t len
 Number of bytes in the view.
 
const charptr
 Pointer to the first byte. Not null-terminated.
 

Detailed Description

Non-owning view over a UTF-8 string (not null-terminated).

Same semantics as std::string_view but requires only C++14. The data pointer is valid only for the lifetime of the source buffer.

Member Function Documentation

◆ begin()

constexpr const char * nros::StringView::begin ( ) const
inlineconstexpr

Iterator to the first byte.

◆ data()

constexpr const char * nros::StringView::data ( ) const
inlineconstexpr

Pointer to the underlying bytes.

◆ empty()

constexpr bool nros::StringView::empty ( ) const
inlineconstexpr

True if the view contains zero bytes.

◆ end()

constexpr const char * nros::StringView::end ( ) const
inlineconstexpr

Iterator past the last byte.

◆ equals()

bool nros::StringView::equals ( const char cstr) const
inline

True if cstr (null-terminated) has the same length and bytes.

◆ operator[]()

constexpr char nros::StringView::operator[] ( size_t  i) const
inlineconstexpr

Byte access; no bounds check.

◆ size()

constexpr size_t nros::StringView::size ( ) const
inlineconstexpr

Number of bytes.

Member Data Documentation

◆ len

size_t nros::StringView::len

Number of bytes in the view.

◆ ptr

const char* nros::StringView::ptr

Pointer to the first byte. Not null-terminated.


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