nros C++ API
Lightweight ROS 2 client for embedded real-time systems (C++ headers)
Loading...
Searching...
No Matches
rclcpp::StringView Struct Reference

#include <span.hpp>

Public Member Functions

constexpr const char * begin () const
 Iterator to the first byte.
constexpr const char * data () const
 Pointer to the underlying bytes.
constexpr bool empty () const
 True if the view contains zero bytes.
constexpr const char * end () 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 char * ptr
 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, without needing C++17's <string_view>. The data pointer is valid only for the lifetime of the source buffer.

Member Function Documentation

◆ begin()

const char * rclcpp::StringView::begin ( ) const
inlineconstexpr

Iterator to the first byte.

◆ data()

const char * rclcpp::StringView::data ( ) const
inlineconstexpr

Pointer to the underlying bytes.

◆ empty()

bool rclcpp::StringView::empty ( ) const
inlineconstexpr

True if the view contains zero bytes.

◆ end()

const char * rclcpp::StringView::end ( ) const
inlineconstexpr

Iterator past the last byte.

◆ equals()

bool rclcpp::StringView::equals ( const char * cstr) const
inline

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

◆ operator[]()

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

Byte access; no bounds check.

◆ size()

size_t rclcpp::StringView::size ( ) const
inlineconstexpr

Number of bytes.

Member Data Documentation

◆ len

size_t rclcpp::StringView::len

Number of bytes in the view.

◆ ptr

const char* rclcpp::StringView::ptr

Pointer to the first byte. Not null-terminated.


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