25#ifndef NROS_RCLCPP_SPAN_HPP
26#define NROS_RCLCPP_SPAN_HPP
39template <
typename T>
struct Span {
46 constexpr const T*
data()
const {
return ptr; }
48 constexpr size_t size()
const {
return len; }
50 constexpr bool empty()
const {
return len == 0; }
70 constexpr const char*
data()
const {
return ptr; }
72 constexpr size_t size()
const {
return len; }
74 constexpr bool empty()
const {
return len == 0; }
78 constexpr const char*
begin()
const {
return ptr; }
80 constexpr const char*
end()
const {
return ptr +
len; }
112 unsigned char tmp[
sizeof(
T)];
113#if defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && \
114 __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
115 for (
size_t b = 0;
b <
sizeof(
T); ++
b)
118 for (
size_t b = 0;
b <
sizeof(
T); ++
b)
Definition client.hpp:129
T operator[](size_t i) const
Definition span.hpp:110
constexpr size_t size() const
Number of elements.
Definition span.hpp:104
constexpr bool empty() const
True if the view contains zero elements.
Definition span.hpp:106
const uint8_t * bytes
Pointer to the first element's little-endian bytes. Borrowed.
Definition span.hpp:99
size_t count
Number of elements.
Definition span.hpp:101
constexpr const T * data() const
Pointer to the underlying storage.
Definition span.hpp:46
constexpr bool empty() const
True if the view contains zero elements.
Definition span.hpp:50
constexpr size_t size() const
Number of elements (alias for len).
Definition span.hpp:48
constexpr const T * begin() const
Iterator to the first element.
Definition span.hpp:54
const T * ptr
Pointer to the first element. Borrowed — caller-owned storage.
Definition span.hpp:41
constexpr const T * end() const
Iterator past the last element.
Definition span.hpp:56
constexpr const T & operator[](size_t i) const
Element access; no bounds check.
Definition span.hpp:52
size_t len
Number of elements in the view.
Definition span.hpp:43
constexpr size_t size() const
Number of bytes.
Definition span.hpp:72
bool equals(const char *cstr) const
True if cstr (null-terminated) has the same length and bytes.
Definition span.hpp:83
constexpr const char * end() const
Iterator past the last byte.
Definition span.hpp:80
constexpr char operator[](size_t i) const
Byte access; no bounds check.
Definition span.hpp:76
const char * ptr
Pointer to the first byte. Not null-terminated.
Definition span.hpp:65
constexpr const char * data() const
Pointer to the underlying bytes.
Definition span.hpp:70
constexpr const char * begin() const
Iterator to the first byte.
Definition span.hpp:78
constexpr bool empty() const
True if the view contains zero bytes.
Definition span.hpp:74
size_t len
Number of bytes in the view.
Definition span.hpp:67