Generic types
The classes representing data buffers, data encoding, timestamp, etc. There types are frequently used by other parts of the API.
-
class BytesView : public zenohcxx::Copyable<::z_bytes_t>
Represents non-owned read only array of bytes.
Constructors
-
inline BytesView(nullptr_t)
Constructs an uninitialized instance.
-
inline BytesView(const void *s, size_t _len)
Constructs an instance from an array of bytes
- Parameters:
s – the array of bytes
_len – the length of the array
-
inline BytesView(const char *s)
Constructs an instance from a null-terminated string
- Parameters:
s – the null-terminated string
-
template<typename T>
inline BytesView(const std::vector<T> &v) Constructs an instance from a
std::vector
of typeT
- Parameters:
v – the
std::vector
of typeT
-
inline BytesView(const std::string_view &s)
Constructs an instance from a
std::string_view
- Parameters:
s – the
std::string_view
-
inline BytesView(const std::string &s)
Constructs an instance from a
std::string
- Parameters:
s – the
std::string
Operators
-
inline std::string_view as_string_view() const
Returns a
std::string_view
representation of the array of bytes- Returns:
a
std::string_view
representation of the array of bytes
-
inline BytesView(nullptr_t)
-
class Str : public zenohcxx::Owned<::z_owned_str_t>
Owned string returned from zenoh. It is automatically freed when the object is destroyed.
Methods
-
inline const char *c_str() const
Get the string value.
- Returns:
const char*
null-terminated string pointer
Operators
-
inline operator const char*() const
Get the string value.
- Returns:
const char*
null-terminated string pointer
-
inline bool operator==(const std::string_view &s) const
Equality operator.
- Parameters:
s – the
std::string_view
to compare with- Returns:
true if the two strings are equal
-
inline bool operator==(const char *s) const
Equality operator.
- Parameters:
s – the null-terminated string to compare with
- Returns:
true if the two strings are equal
-
inline const char *c_str() const
-
struct StrArrayView : public zenoh::_StrArrayView<::z_str_array_t>
Represents non-owned read only array of
char*
Impmemented in a templatezenoh::_StrArrayView
to handle with different const definitions in::z_str_array_t
struct in zenoh-pico and zenoh-c
-
template<typename Z_STR_ARRAY_T>
struct _StrArrayView : public zenohcxx::Copyable<Z_STR_ARRAY_T> Constructors
-
inline _StrArrayView()
Constructs an uninitialized instance.
-
inline _StrArrayView(const std::vector<const char*> &v)
Constructs an instance from a
std::vector
ofconst char*
- Parameters:
v – the
std::vector
ofconst char*
-
inline _StrArrayView(const char **v, size_t len)
Constructs an instance from an array of
const char*
- Parameters:
v – the array of
const char*
len – the length of the array
-
inline _StrArrayView(const char *const *v, size_t len)
Constructs an instance from an constant array of
const char*
- Parameters:
v – the array of
const char*
len – the length of the array
Operators
-
inline const char *operator[](size_t pos) const
Operator to access an element of the array by index
- Parameters:
pos – the index of the element
- Returns:
the element at the given index
Methods
-
inline size_t get_len() const
Returns the length of the array
- Returns:
the length of the array
-
inline _StrArrayView()
-
struct Encoding : public zenohcxx::Copyable<::z_encoding_t>
The encoding of a payload, in a MIME-like format.
For wire and matching efficiency, common MIME types are represented using an integer as “prefix”, and a “suffix” may be used to either provide more detail, or in combination with the Z_ENCODING_PREFIX_EMPTY value of
zenoh::EncodingPrefix
to write arbitrary MIME types.Constructors
-
inline Encoding()
Default encoding.
-
inline Encoding(EncodingPrefix _prefix)
Encoding with a prefix.
-
inline Encoding(EncodingPrefix _prefix, const char *_suffix)
Encoding with a prefix and a suffix.
Methods
-
inline Encoding &set_prefix(EncodingPrefix _prefix)
Set the prefix for the encoding.
- Parameters:
_prefix – value of
zenoh::EncodingPrefix
type- Returns:
Reference to the
Encoding
object
-
inline Encoding &set_suffix(const zenoh::BytesView &_suffix)
Set the suffix for the encoding.
- Parameters:
_suffix –
zenoh::BytesView
representing the suffix- Returns:
Reference to the
Encoding
object
-
inline EncodingPrefix get_prefix() const
Get the prefix of the encoding.
- Returns:
value of
zenoh::EncodingPrefix
type
-
inline const zenoh::BytesView &get_suffix() const
Get the suffix of the encoding.
- Returns:
zenoh::BytesView
representing the suffix
-
inline Encoding()
-
struct Id : public zenohcxx::Copyable<::z_id_t>
Represents a Zenoh ID. In general, valid Zenoh IDs are LSB-first 128bit unsigned and non-zero integers.
See also: operator<<(std::ostream& os, const z::Id& id)
Methods
-
inline bool is_some() const
Checks if the ID is valid
- Returns:
true if the ID is valid
-
inline bool is_some() const
-
std::ostream &zenoh::operator<<(std::ostream &os, const zenoh::Id &id)
Output operator for Id.
- Parameters:
os – the output stream
id – reference to the Id
- Returns:
the output stream
-
struct Value : public zenohcxx::Copyable<::z_value_t>
A zenoh value. Contans refrence to data and it’s encoding.
Constructors
-
inline Value(const zenoh::BytesView &payload, const zenoh::Encoding &encoding)
Create a new value with the given payload and encoding.
-
inline Value(const zenoh::BytesView &payload)
Create a new value with the default encoding.
- Parameters:
payload –
BytesView
object
-
inline Value(const char *payload)
Create a new value from null-terminated string with the default encoding.
- Parameters:
payload – null-terminated string
Methods
-
inline const zenoh::BytesView &get_payload() const
The payload of this value.
- Returns:
BytesView
object
-
inline Value &set_payload(const zenoh::BytesView &_payload)
Set payload of this value.
- Parameters:
_payload –
BytesView
object- Returns:
referencew the value itself
-
inline const zenoh::Encoding &get_encoding() const
The encoding of this value.
- Returns:
Encoding
object
-
inline Value &set_encoding(const zenoh::Encoding &_encoding)
Set encoding of this value.
- Parameters:
_encoding –
Encoding
object- Returns:
referencew the value itself
-
inline std::string_view as_string_view() const
The payload of this value as a
std::string_view
- Returns:
std::string_view
object
-
inline Value(const zenoh::BytesView &payload, const zenoh::Encoding &encoding)