zmqpp
4.1.2
C++ bindings for 0mq (libzmq)
|
a zmq message with optional multipart support More...
#include <message.hpp>
Public Types | |
typedef std::function< void(void *)> | release_function |
callback to release user allocated data. More... | |
Public Member Functions | |
message () | |
~message () | |
template<typename T , typename ... Args> | |
message (T const &part, Args &&...args) | |
size_t | parts () const |
size_t | size (size_t const part) const |
std::string | get (size_t const part) const |
void | get (int8_t &integer, size_t const part) const |
void | get (int16_t &integer, size_t const part) const |
void | get (int32_t &integer, size_t const part) const |
void | get (int64_t &integer, size_t const part) const |
void | get (signal &sig, size_t const part) const |
void | get (uint8_t &unsigned_integer, size_t const part) const |
void | get (uint16_t &unsigned_integer, size_t const part) const |
void | get (uint32_t &unsigned_integer, size_t const part) const |
void | get (uint64_t &unsigned_integer, size_t const part) const |
void | get (float &floating_point, size_t const part) const |
void | get (double &double_precision, size_t const part) const |
void | get (bool &boolean, size_t const part) const |
void | get (std::string &string, size_t const part) const |
template<typename Type > | |
Type | get (size_t const part) const |
template<int part = 0, typename T , typename ... Args> | |
void | extract (T &nextpart, Args &...args) const |
template<int part = 0, typename T > | |
void | extract (T &nextpart) const |
template<typename Type > | |
void | get (Type *&value, size_t const part) const |
template<typename Type > | |
void | get (Type **value, size_t const part) const |
void | move (void *part, size_t const size, release_function const &release) |
template<typename Object > | |
void | move (Object *part) |
template<typename Type , typename ... Args> | |
void | add (Type const &part, Args &&...args) |
template<typename Type > | |
void | add (Type const part) |
template<typename Type > | |
void | add_raw (Type *part, size_t const data_size) |
template<typename Type > | |
ZMQPP_DEPRECATED ("Use add_nocopy() or add_nocopy_const() instead.") void add_const(Type *part | |
template<typename Type > | |
void | add_nocopy (Type *part, size_t const data_size, zmq_free_fn *ffn=nullptr, void *hint=nullptr) |
Add a no-copy frame. More... | |
template<typename Type > | |
void | add_nocopy_const (const Type *part, size_t const data_size, zmq_free_fn *ffn=nullptr, void *hint=nullptr) |
Add a no-copy frame where pointed-to data are const. More... | |
void | reset_read_cursor () |
template<typename Type > | |
message & | operator>> (Type &value) |
message & | operator<< (int8_t const integer) |
message & | operator<< (int16_t const integer) |
message & | operator<< (int32_t const integer) |
message & | operator<< (int64_t const integer) |
message & | operator<< (signal const sig) |
message & | operator<< (uint8_t const unsigned_integer) |
message & | operator<< (uint16_t const unsigned_integer) |
message & | operator<< (uint32_t const unsigned_integer) |
message & | operator<< (uint64_t const unsigned_integer) |
message & | operator<< (float const floating_point) |
message & | operator<< (double const double_precision) |
message & | operator<< (bool const boolean) |
message & | operator<< (char const *c_string) |
message & | operator<< (std::string const &string) |
void | push_front (void const *part, size_t const size) |
void | push_front (int8_t const integer) |
void | push_front (int16_t const integer) |
void | push_front (int32_t const integer) |
void | push_front (int64_t const integer) |
void | push_front (signal const sig) |
void | push_front (uint8_t const unsigned_integer) |
void | push_front (uint16_t const unsigned_integer) |
void | push_front (uint32_t const unsigned_integer) |
void | push_front (uint64_t const unsigned_integer) |
void | push_front (float const floating_point) |
void | push_front (double const double_precision) |
void | push_front (bool const boolean) |
void | push_front (char const *c_string) |
void | push_front (std::string const &string) |
void | pop_front () |
void | push_back (void const *part, size_t const data_size) |
template<typename Type > | |
void | push_back (Type const part) |
void | pop_back () |
void | remove (size_t const part) |
message (message &&source) NOEXCEPT | |
message & | operator= (message &&source) NOEXCEPT |
message | copy () const |
void | copy (message const &source) |
void | sent (size_t const part) |
void const * | raw_data (size_t const part=0) const |
zmq_msg_t & | raw_msg (size_t const part=0) |
zmq_msg_t & | raw_new_msg () |
zmq_msg_t & | raw_new_msg (size_t const reserve_data_size) |
bool | is_signal () const |
Check if the message is a signal. More... | |
size_t | read_cursor () const NOEXCEPT |
Gets the read cursor. More... | |
size_t | remaining () const NOEXCEPT |
Gets the remaining number of parts in the message. More... | |
size_t | next () NOEXCEPT |
Moves the read cursor to the next element. More... | |
Public Attributes | |
size_t const | data_size |
Private Types | |
typedef std::vector< frame > | parts_type |
Private Member Functions | |
message (message const &) NOEXCEPT ZMQPP_EXPLICITLY_DELETED | |
message & | operator= (message const &) NOEXCEPT ZMQPP_EXPLICITLY_DELETED |
Static Private Member Functions | |
static void | release_callback (void *data, void *hint) |
template<typename Object > | |
static void | deleter_callback (void *data) |
Private Attributes | |
parts_type | _parts |
size_t | _read_cursor |
a zmq message with optional multipart support
A zmq message is made up of one or more parts which are sent together to the target endpoints. zmq guarantees either the whole message or none of the message will be delivered.
|
private |
typedef std::function<void (void*)> zmqpp::message::release_function |
callback to release user allocated data.
The release function will be called on any void* moved part. It must be thread safe to the extent that the callback may occur on one of the context threads.
The function called will be passed a single variable which is the pointer to the memory allocated.
zmqpp::message::message | ( | ) |
zmqpp::message::~message | ( | ) |
|
inline |
zmqpp::message::message | ( | message && | source | ) |
|
private |
|
inline |
|
inline |
|
inline |
Add a no-copy frame.
This means that neither zmqpp nor libzmq will make a copy of the data. The pointed-to data must remain valid for the lifetime of the underlying zmq_msg_t. Note that you cannot always know about this lifetime, so be careful.
part | The pointed-to data that will be send in the message. |
data_size | The number of byte pointed-to by "part". |
ffn | The free function called by libzmq when it doesn't need your buffer anymore. It defaults to nullptr, meaning your data will not be freed. |
hint | A hint to help your free function do its job. |
move()
does. While move()
provide a safe (wrt to type) deleter (at the cost of 1 memory allocation) add_nocopy let you pass the low-level callback that libzmq will invoke.
|
inline |
Add a no-copy frame where pointed-to data are const.
This means that neither zmqpp nor libzmq will make a copy of the data. The pointed-to data must remain valid for the lifetime of the underlying zmq_msg_t. Note that you cannot always know about this lifetime, so be careful.
part | The pointed-to data that will be send in the message. |
data_size | The number of byte pointed-to by "part". |
ffn | The free function called by libzmq when it doesn't need your buffer anymore. It defaults to nullptr, meaning your data will not be freed. |
hint | A hint to help your free function do its job. |
|
inline |
message zmqpp::message::copy | ( | ) | const |
void zmqpp::message::copy | ( | message const & | source | ) |
|
inlinestaticprivate |
|
inline |
|
inline |
std::string zmqpp::message::get | ( | size_t const | part | ) | const |
void zmqpp::message::get | ( | int8_t & | integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | int16_t & | integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | int32_t & | integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | int64_t & | integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | signal & | sig, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | uint8_t & | unsigned_integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | uint16_t & | unsigned_integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | uint32_t & | unsigned_integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | uint64_t & | unsigned_integer, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | float & | floating_point, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | double & | double_precision, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | bool & | boolean, |
size_t const | part | ||
) | const |
void zmqpp::message::get | ( | std::string & | string, |
size_t const | part | ||
) | const |
|
inline |
|
inline |
|
inline |
bool zmqpp::message::is_signal | ( | ) | const |
Check if the message is a signal.
If the message has 1 part, has the correct size and if the 7 first bytes match the signal header we consider the message a signal.
void zmqpp::message::move | ( | void * | part, |
size_t const | size, | ||
release_function const & | release | ||
) |
|
inline |
|
inline |
Moves the read cursor to the next element.
message & zmqpp::message::operator<< | ( | int8_t const | integer | ) |
message & zmqpp::message::operator<< | ( | int16_t const | integer | ) |
message & zmqpp::message::operator<< | ( | int32_t const | integer | ) |
message & zmqpp::message::operator<< | ( | int64_t const | integer | ) |
message & zmqpp::message::operator<< | ( | uint8_t const | unsigned_integer | ) |
message & zmqpp::message::operator<< | ( | uint16_t const | unsigned_integer | ) |
message & zmqpp::message::operator<< | ( | uint32_t const | unsigned_integer | ) |
message & zmqpp::message::operator<< | ( | uint64_t const | unsigned_integer | ) |
message & zmqpp::message::operator<< | ( | float const | floating_point | ) |
message & zmqpp::message::operator<< | ( | double const | double_precision | ) |
message & zmqpp::message::operator<< | ( | bool const | boolean | ) |
message & zmqpp::message::operator<< | ( | char const * | c_string | ) |
message & zmqpp::message::operator<< | ( | std::string const & | string | ) |
|
inline |
size_t zmqpp::message::parts | ( | ) | const |
void zmqpp::message::pop_back | ( | ) |
void zmqpp::message::pop_front | ( | ) |
|
inline |
|
inline |
void zmqpp::message::push_front | ( | void const * | part, |
size_t const | size | ||
) |
void zmqpp::message::push_front | ( | int8_t const | integer | ) |
void zmqpp::message::push_front | ( | int16_t const | integer | ) |
void zmqpp::message::push_front | ( | int32_t const | integer | ) |
void zmqpp::message::push_front | ( | int64_t const | integer | ) |
void zmqpp::message::push_front | ( | signal const | sig | ) |
void zmqpp::message::push_front | ( | uint8_t const | unsigned_integer | ) |
void zmqpp::message::push_front | ( | uint16_t const | unsigned_integer | ) |
void zmqpp::message::push_front | ( | uint32_t const | unsigned_integer | ) |
void zmqpp::message::push_front | ( | uint64_t const | unsigned_integer | ) |
void zmqpp::message::push_front | ( | float const | floating_point | ) |
void zmqpp::message::push_front | ( | double const | double_precision | ) |
void zmqpp::message::push_front | ( | bool const | boolean | ) |
void zmqpp::message::push_front | ( | char const * | c_string | ) |
void zmqpp::message::push_front | ( | std::string const & | string | ) |
void const * zmqpp::message::raw_data | ( | size_t const | part = 0 | ) | const |
zmq_msg_t & zmqpp::message::raw_msg | ( | size_t const | part = 0 | ) |
zmq_msg_t & zmqpp::message::raw_new_msg | ( | ) |
zmq_msg_t & zmqpp::message::raw_new_msg | ( | size_t const | reserve_data_size | ) |
|
inline |
Gets the read cursor.
For using get_raw() with stream-style reading.
|
staticprivate |
|
inline |
Gets the remaining number of parts in the message.
void zmqpp::message::remove | ( | size_t const | part | ) |
void zmqpp::message::reset_read_cursor | ( | ) |
void zmqpp::message::sent | ( | size_t const | part | ) |
size_t zmqpp::message::size | ( | size_t const | part | ) | const |
zmqpp::message::ZMQPP_DEPRECATED | ( | "Use add_nocopy() or add_nocopy_const() instead." | ) |
|
private |
|
private |
size_t const zmqpp::message::data_size |