Overview Tutorial API reference Examples Build Download ZmqMessage 0.1 - 21 Oct 2011

ZmqMessage Namespace Reference

Main namespace for ZmqMessage library. More...


Classes

class  DefaultExceptionTemplate
struct  RawMessage
 Describes memory region with raw data. More...
class  SimpleRouting
 Simple (not-X) Routing policy. More...
class  XRouting
 X routing policy. More...
class  Multipart
 Basic holder of message parts. More...
class  Incoming
 Incoming multipart ZMQ message. More...
struct  OutOptions
 Options for outgoing message. More...
class  Sink
 Base class for Outgoing message, does not depend on Routing policy. More...
class  Outgoing
 Represents outgoing message to be sent. More...

Namespaces

namespace  Private
 For internal usage to determine the proper way to pass a particular data type.

Typedefs

typedef zmq::error_t ZmqErrorType
typedef std::vector< zmq::message_t * > MsgPtrVec

Functions

void throw_zmq_error (const char *err)
void send (zmq::socket_t &sock, Multipart &multipart, bool nonblock) throw (ZmqErrorType)
SinkNullMessage (Sink &out)
 Null (empty) message marker to send.
SinkFlush (Sink &out)
 Manipulator to flush outgoing message.
time_t get_time (zmq::message_t &message)
void init_msg (const void *t, size_t sz, zmq::message_t &msg)
bool has_more (zmq::socket_t &sock)
int relay_raw (zmq::socket_t &src, zmq::socket_t &dst, bool check_first_part)
template<typename RoutingPolicy>
Incoming< RoutingPolicy > & Skip (Incoming< RoutingPolicy > &in)
 Skip current message part in incoming message.
template<typename StreamAlike>
StreamAlike & Binary (StreamAlike &out)
 Manipulator to switch to binary mode.
template<typename StreamAlike>
StreamAlike & Text (StreamAlike &out)
 Manipulator to switch to text mode (default).
template<typename T>
void get_bin (zmq::message_t &message, T &t)
template<typename T>
get_bin (zmq::message_t &message)
template<typename T>
get (zmq::message_t &message, typename Private::EnableIf< Private::IsStr< T >::value >::type *=0)
template<typename T>
get (zmq::message_t &message, typename Private::DisableIf< Private::IsStr< T >::value >::type *=0, typename Private::DisableIf< Private::IsRaw< T >::value >::type *=0)
template<typename T>
get (zmq::message_t &message, typename Private::DisableIf< Private::IsStr< T >::value >::type *=0, typename Private::EnableIf< Private::IsRaw< T >::value >::type *=0)
template<typename T>
void get (zmq::message_t &message, T &t, typename Private::EnableIf< Private::IsStr< T >::value >::type *=0)
template<typename T>
void get (zmq::message_t &message, T &t, typename Private::DisableIf< Private::IsStr< T >::value >::type *=0, typename Private::DisableIf< Private::IsRaw< T >::value >::type *=0)
template<typename T>
void get (zmq::message_t &message, T &t, typename Private::DisableIf< Private::IsStr< T >::value >::type *=0, typename Private::EnableIf< Private::IsRaw< T >::value >::type *=0)
template<typename T>
get (zmq::message_t &message, bool binary_mode)
template<typename T>
void get (zmq::message_t &message, T &t, bool binary_mode)
RawMessage get_raw (zmq::message_t &message)
template<typename T>
get_string (zmq::message_t &message)
template<typename T>
get_string (zmq::message_t &message, size_t limit)
int msgcmp (zmq::message_t &message, const char *str, size_t len)
int msgcmp (zmq::message_t &message, const char *str)
template<typename T>
int msgcmp (zmq::message_t &message, const T &str, typename Private::EnableIf< Private::IsStr< T >::value >::type *=0)
template<class T>
void init_msg (const T &t, zmq::message_t &msg, typename Private::EnableIf< Private::IsStr< T >::value >::type *=0)
template<class T>
void init_msg (const T &t, zmq::message_t &msg, typename Private::DisableIf< Private::IsStr< T >::value >::type *=0, typename Private::DisableIf< Private::IsRaw< T >::value >::type *=0)
template<class T>
void init_msg (const T &t, zmq::message_t &msg, typename Private::DisableIf< Private::IsStr< T >::value >::type *=0, typename Private::EnableIf< Private::IsRaw< T >::value >::type *=0)
void init_msg (const char *t, zmq::message_t &msg)
template<class T>
void init_msg_bin (const T &t, zmq::message_t &msg)
template<class T>
void init_msg (const T &t, zmq::message_t &msg, bool binary_mode)
void throw_zmq_exception (const zmq::error_t &e) throw (ZmqErrorType)
void recv_msg (zmq::socket_t &sock, zmq::message_t &msg, int flags=0) throw (ZmqErrorType)
bool try_recv_msg (zmq::socket_t &sock, zmq::message_t &msg, int flags=ZMQ_NOBLOCK) throw (ZmqErrorType)
void send_msg (zmq::socket_t &sock, zmq::message_t &msg, int flags) throw (ZmqErrorType)
void copy_msg (zmq::message_t &target, zmq::message_t &source) throw (ZmqErrorType)


Detailed Description

Main namespace for ZmqMessage library.

Typedef Documentation

typedef zmq::error_t ZmqMessage::ZmqErrorType

typedef std::vector<zmq::message_t*> ZmqMessage::MsgPtrVec

Vector of pointers to message parts.


Function Documentation

void ZmqMessage::throw_zmq_error ( const char *  err  )  [inline]

void ZmqMessage::send ( zmq::socket_t &  sock,
Multipart &  multipart,
bool  nonblock 
) throw (ZmqErrorType)

Send given message to destination socket

Examples:
zasync.cpp, and zqueue.cpp.

Sink & ZmqMessage::NullMessage ( Sink &  out  ) 

Null (empty) message marker to send.

When passed to Outgoing (operator <<) creates null (empty) message part

Sink & ZmqMessage::Flush ( Sink &  out  ) 

Manipulator to flush outgoing message.

Manipulator to finally flush (send/enqueue) the outgoing message.

Examples:
zasync.cpp, zbisort.cpp, and zqueue.cpp.

time_t ZmqMessage::get_time ( zmq::message_t &  message  ) 

Get timestamp from TEXT message, converting ASCII string to unsigned long

void ZmqMessage::init_msg ( const void *  t,
size_t  sz,
zmq::message_t &  msg 
)

Initialize zmq message with copy of given data (binary). (created duplicate of buffer will be owned by zmq message and will be destroyed by it).

bool ZmqMessage::has_more ( zmq::socket_t &  sock  ) 

Does specified socket has more messages to receive

int ZmqMessage::relay_raw ( zmq::socket_t &  src,
zmq::socket_t &  dst,
bool  check_first_part = true 
)

Relays all pending messages (until no more) from src to dst

Parameters:
src source socket
dst destination socket
check_first_part true to check if we have more parts even for 1st part
Returns:
number of relayed parts
Examples:
zbisort.cpp.

template<typename RoutingPolicy>
Incoming<RoutingPolicy>& ZmqMessage::Skip ( Incoming< RoutingPolicy > &  in  ) 

Skip current message part in incoming message.

When passed to Incoming (operator >>) just skips current message and moves receive pointer to next one. Also, usual checking that current part exists is performed.

template<typename StreamAlike>
StreamAlike& ZmqMessage::Binary ( StreamAlike &  out  ) 

Manipulator to switch to binary mode.

Manipulator to turn off conversion to/from text sending/receiving See modes

Examples:
zserialize.cpp.

template<typename StreamAlike>
StreamAlike& ZmqMessage::Text ( StreamAlike &  out  ) 

Manipulator to switch to text mode (default).

Manipulator to turn on conversion to/from text sending/receiving. See modes

Examples:
zserialize.cpp.

template<typename T>
void ZmqMessage::get_bin ( zmq::message_t &  message,
T &  t 
) [inline]

Put binary message contents into existing variable. For binary messages containing elementary types or properly aligned PODs

Parameters:
message zmq message
t will contain the COPY of message contents

template<typename T>
T ZmqMessage::get_bin ( zmq::message_t &  message  )  [inline]

Return variable with binary message contents. For binary messages containing elementary types or properly aligned PODs

Parameters:
message zmq message

template<typename T>
T ZmqMessage::get ( zmq::message_t &  message,
typename Private::EnableIf< Private::IsStr< T >::value >::type *  = 0 
) [inline]

Get message contents For string-like types. Message should contain characters, possibly not null-terminated.

Parameters:
message zmq message T class supporting string operations (
See also:
Private::IsStr)

template<typename T>
T ZmqMessage::get ( zmq::message_t &  message,
typename Private::DisableIf< Private::IsStr< T >::value >::type *  = 0,
typename Private::DisableIf< Private::IsRaw< T >::value >::type *  = 0 
) [inline]

Get message contents. For non-string types. Message content converted to T as character stream or binary data. It's written to stream and read as type T. ex. if T is int: "678" -> 678.

Parameters:
message zmq message
Returns:
the converted content

template<typename T>
T ZmqMessage::get ( zmq::message_t &  message,
typename Private::DisableIf< Private::IsStr< T >::value >::type *  = 0,
typename Private::EnableIf< Private::IsRaw< T >::value >::type *  = 0 
) [inline]

Get message contents. For types explicitly marked as raw (containing raw_mark typedef)

Parameters:
message zmq message T containing raw_mark typedef (
See also:
Private::IsRaw)

template<typename T>
void ZmqMessage::get ( zmq::message_t &  message,
T &  t,
typename Private::EnableIf< Private::IsStr< T >::value >::type *  = 0 
) [inline]

Get message contents into existing variable. For string-like types. Message should contain characters, possibly not null-terminated.

Parameters:
message zmq message T class supporting string operations (
See also:
Private::IsStr)

template<typename T>
void ZmqMessage::get ( zmq::message_t &  message,
T &  t,
typename Private::DisableIf< Private::IsStr< T >::value >::type *  = 0,
typename Private::DisableIf< Private::IsRaw< T >::value >::type *  = 0 
) [inline]

Get message contents into existing variable. For non-string types. Message content converted to T as character stream or binary data. It's written to stream and read as type T. ex. if T is int: "678" -> 678.

Parameters:
message zmq message
Returns:
the converted content

template<typename T>
void ZmqMessage::get ( zmq::message_t &  message,
T &  t,
typename Private::DisableIf< Private::IsStr< T >::value >::type *  = 0,
typename Private::EnableIf< Private::IsRaw< T >::value >::type *  = 0 
) [inline]

Get message contents into existing variable. For types explicitly marked as raw (containing raw_mark typedef)

Parameters:
message zmq message T containing raw_mark typedef (
See also:
Private::IsRaw)

template<typename T>
T ZmqMessage::get ( zmq::message_t &  message,
bool  binary_mode 
) [inline]

Get message contents, treating it either as binary data or character stream (as determined by binary_mode parameter).

template<typename T>
void ZmqMessage::get ( zmq::message_t &  message,
T &  t,
bool  binary_mode 
) [inline]

Get message contents into existing variable, treating it either as binary data or character stream (as determined by binary_mode parameter).

RawMessage ZmqMessage::get_raw ( zmq::message_t &  message  )  [inline]

Return memory region as RawMessage. No copying takes place.

template<typename T>
ZMQMESSAGE_STRING_CLASS ZmqMessage::get_string ( zmq::message_t &  message  )  [inline]

Extract string class from text message (possibly not zero-terminated)

template<typename T>
ZMQMESSAGE_STRING_CLASS ZmqMessage::get_string ( zmq::message_t &  message,
size_t  limit 
) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Extract up to limit characters from text message (possibly not zero-terminated)

int ZmqMessage::msgcmp ( zmq::message_t &  message,
const char *  str,
size_t  len 
) [inline]

Compare message contents to specified memory region.

Returns:
like memcmp

int ZmqMessage::msgcmp ( zmq::message_t &  message,
const char *  str 
) [inline]

Compare message contents to specified zero-terminated C string.

Returns:
like memcmp

template<typename T>
int ZmqMessage::msgcmp ( zmq::message_t &  message,
const T &  str,
typename Private::EnableIf< Private::IsStr< T >::value >::type *  = 0 
) [inline]

Compare message contents to specified string.

Returns:
like memcmp

template<class T>
void ZmqMessage::init_msg ( const T &  t,
zmq::message_t &  msg,
typename Private::EnableIf< Private::IsStr< T >::value >::type *  = 0 
) [inline]

Initialize zmq message by string object. No null terminator (if any) appended to message.

template<class T>
void ZmqMessage::init_msg ( const T &  t,
zmq::message_t &  msg,
typename Private::DisableIf< Private::IsStr< T >::value >::type *  = 0,
typename Private::DisableIf< Private::IsRaw< T >::value >::type *  = 0 
) [inline]

template<class T>
void ZmqMessage::init_msg ( const T &  t,
zmq::message_t &  msg,
typename Private::DisableIf< Private::IsStr< T >::value >::type *  = 0,
typename Private::EnableIf< Private::IsRaw< T >::value >::type *  = 0 
) [inline]

void ZmqMessage::init_msg ( const char *  t,
zmq::message_t &  msg 
) [inline]

Initialize zmq message with zero-terminated string

template<class T>
void ZmqMessage::init_msg_bin ( const T &  t,
zmq::message_t &  msg 
) [inline]

Initialize zmq message with variable treated as binary data. For elementary types or properly aligned PODs.

template<class T>
void ZmqMessage::init_msg ( const T &  t,
zmq::message_t &  msg,
bool  binary_mode 
) [inline]

Initialize zmq message with variable treated either as binary data or something that can be written to stream (depending on binary_mode parameter).

void ZmqMessage::throw_zmq_exception ( const zmq::error_t &  e  )  throw (ZmqErrorType) [inline]

throw exception: either unwrapped zmq::error_t or wrapped exception, depending on configuration

void ZmqMessage::recv_msg ( zmq::socket_t &  sock,
zmq::message_t &  msg,
int  flags = 0 
) throw (ZmqErrorType) [inline]

Receive message part from socket

bool ZmqMessage::try_recv_msg ( zmq::socket_t &  sock,
zmq::message_t &  msg,
int  flags = ZMQ_NOBLOCK 
) throw (ZmqErrorType) [inline]

Try to receive message part from socket.

Returns:
false if would block

void ZmqMessage::send_msg ( zmq::socket_t &  sock,
zmq::message_t &  msg,
int  flags 
) throw (ZmqErrorType) [inline]

Send message part to socket with specified flags

void ZmqMessage::copy_msg ( zmq::message_t &  target,
zmq::message_t &  source 
) throw (ZmqErrorType) [inline]

Copy contents of one message part to another


ZmqMessage 0.1 — open source software, support@zmqmessage.org