mirror of
https://github.com/zeromq/cppzmq.git
synced 2025-05-18 12:34:59 +02:00
New fill constructor for message_t
New fill constructor: message_t(const void *data, size_t size). Constructs a new message of the given size and copies the data to the message body. In addition a new rebuild() function that does the same for an already constructed object
This commit is contained in:
parent
18b5870caa
commit
fdd9d2d5f0
19
zmq.hpp
19
zmq.hpp
@ -227,6 +227,14 @@ namespace zmq
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline message_t (const void *data_, size_t size_)
|
||||||
|
{
|
||||||
|
int rc = zmq_msg_init_size (&msg, size_);
|
||||||
|
if (rc != 0)
|
||||||
|
throw error_t ();
|
||||||
|
memcpy(data(), data_, size_);
|
||||||
|
}
|
||||||
|
|
||||||
inline message_t (void *data_, size_t size_, free_fn *ffn_,
|
inline message_t (void *data_, size_t size_, free_fn *ffn_,
|
||||||
void *hint_ = NULL)
|
void *hint_ = NULL)
|
||||||
{
|
{
|
||||||
@ -276,6 +284,17 @@ namespace zmq
|
|||||||
throw error_t ();
|
throw error_t ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void rebuild (const void *data_, size_t size_)
|
||||||
|
{
|
||||||
|
int rc = zmq_msg_close (&msg);
|
||||||
|
if (rc != 0)
|
||||||
|
throw error_t ();
|
||||||
|
rc = zmq_msg_init_size (&msg, size_);
|
||||||
|
if (rc != 0)
|
||||||
|
throw error_t ();
|
||||||
|
memcpy(data(), data_, size_);
|
||||||
|
}
|
||||||
|
|
||||||
inline void rebuild (void *data_, size_t size_, free_fn *ffn_,
|
inline void rebuild (void *data_, size_t size_, free_fn *ffn_,
|
||||||
void *hint_ = NULL)
|
void *hint_ = NULL)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user