Qore zmq Module  1.0.0
Qore::ZMQ::ZFrame Class Reference

The ZFrame class implements a ZeroMQ frame. More...

Public Member Methods

binary bin ()
 Returns the frame's contents as a binary object. More...
 
 constructor ()
 constructs an empty ZFrame More...
 
 constructor (string str)
 constructs a ZFrame from the string supplied More...
 
 constructor (binary b)
 constructs a ZFrame from the binary data supplied More...
 
 copy ()
 copies a ZFrame object More...
 
ZMsg decode ()
 Decodes a serialized message frame created by ZMsg::encode() and returns a new message object. More...
 
bool eq (ZFrame frm)
 Returns True if two frames have identical size and data. More...
 
*string meta (string property)
 Returns meta data property for the frame. More...
 
bool more ()
 Returns the frame's MORE indicator. More...
 
nothing print (*string prefix)
 Sends a message to the zsys log sink (may be stdout, or system facility) More...
 
int readi2 (int offset)
 Reads a signed 16-bit integer from the given offset in the frame. More...
 
int readi4 (int offset)
 Reads a signed 32-bit integer from the given offset in the frame. More...
 
int size ()
 Returns the byte size of the frame's data. More...
 
bool streq (string str)
 Returns True if the frame body is equal to the string excluding the terminating null. More...
 
string strhex ()
 Returns frame data encoded as printable hex string, useful for ØMQ UUIDs. More...
 

Detailed Description

The ZFrame class implements a ZeroMQ frame.

This class does not support modifications after the constructor in order to remain lock-free

Member Function Documentation

◆ bin()

binary Qore::ZMQ::ZFrame::bin ( )

Returns the frame's contents as a binary object.

Code Flags:
CONSTANT
Example
binary b = frame.bin();
Returns
the frame's contents as a binary object

◆ constructor() [1/3]

Qore::ZMQ::ZFrame::constructor ( )

constructs an empty ZFrame

Example
ZFrame frame();

◆ constructor() [2/3]

Qore::ZMQ::ZFrame::constructor ( binary  b)

constructs a ZFrame from the binary data supplied

Example
ZFrame frame(bin);

The binary data is copied to the frame's memory.

◆ constructor() [3/3]

Qore::ZMQ::ZFrame::constructor ( string  str)

constructs a ZFrame from the string supplied

Example
ZFrame frame(str);

The string data is copied to the frame's memory.

◆ copy()

Qore::ZMQ::ZFrame::copy ( )

copies a ZFrame object

Example
ZFrame frame_new = frame.copy();

◆ decode()

ZMsg Qore::ZMQ::ZFrame::decode ( )

Decodes a serialized message frame created by ZMsg::encode() and returns a new message object.

Code Flags:
CONSTANT
Example:
ZMsg msg = frame.decode();
Exceptions
ZFRAME-DECODE-ERRORthis exception is thrown if an error occurs decoding the frame
See also
Qore::ZMQ::ZMsg::encode() "ZMsg::encode()"

◆ eq()

bool Qore::ZMQ::ZFrame::eq ( ZFrame  frm)

Returns True if two frames have identical size and data.

Code Flags:
CONSTANT
Example
bool b = frame.eq(frm);
Parameters
frmthe frame to compare
Returns
True if the two frames have identical size and data

◆ meta()

*string Qore::ZMQ::ZFrame::meta ( string  property)

Returns meta data property for the frame.

Code Flags:
CONSTANT
Example
*string str = frame.meta("Socket-Type");
Parameters
propertya meta-data property for the first frame in the message; the string is converted to UTF-8 encoding if necessary; the following properties are available:
  • "Socket-Type":
  • "Identity":
  • "Resource":
  • "Peer-Address" if supported by the undelying transport; this property will return the IP address of the remote endpoint as returned by getnameinfo(2).
Returns
a string in UTF-8 encoding giving the property value or nothing if no such property is set for the frame
Exceptions
MISSING-FEATURE-ERRORthrown if the underlying czmq library is missing the zframe_meta() function; check HAVE_ZFRAME_META before calling this method
Note
  • the input string is converted to UTF-8 encoding if necessary
  • Other properties may be defined based on the underlying security mechanism
  • only available if the underlying library supports it; check HAVE_ZFRAME_META before calling this method

◆ more()

bool Qore::ZMQ::ZFrame::more ( )

Returns the frame's MORE indicator.

Code Flags:
CONSTANT
Example
bool b = frame.more();
Returns
the frame's MORE indicator

◆ print()

nothing Qore::ZMQ::ZFrame::print ( *string  prefix)

Sends a message to the zsys log sink (may be stdout, or system facility)

Example
frame.print("my-frame");
Parameters
prefixan optional string to log before the frame

◆ readi2()

int Qore::ZMQ::ZFrame::readi2 ( int  offset)

Reads a signed 16-bit integer from the given offset in the frame.

Example:
int i = frame.readi2(0);
Parameters
offsetthe byte offset in the frame
Returns
a signed 16-bit integer at the given position in the frame
Exceptions
ZFRAME-READ-ERRORthis exception is thrown when an invalid offset argument is used

◆ readi4()

int Qore::ZMQ::ZFrame::readi4 ( int  offset)

Reads a signed 32-bit integer from the given offset in the frame.

Example:
int i = frame.readi4(0);
Parameters
offsetthe byte offset in the frame
Returns
a signed 32-bit integer at the given position in the frame
Exceptions
ZFRAME-READ-ERRORthis exception is thrown when an invalid offset argument is used

◆ size()

int Qore::ZMQ::ZFrame::size ( )

Returns the byte size of the frame's data.

Code Flags:
CONSTANT
Example
int size = frame.size();

◆ streq()

bool Qore::ZMQ::ZFrame::streq ( string  str)

Returns True if the frame body is equal to the string excluding the terminating null.

Code Flags:
CONSTANT
Example
bool b = frame.streq(str);
Parameters
strthe string to compare the frame's body with
Returns
True if the frame body is equal to the string excluding the terminating null

◆ strhex()

string Qore::ZMQ::ZFrame::strhex ( )

Returns frame data encoded as printable hex string, useful for ØMQ UUIDs.

Code Flags:
CONSTANT
Example
string str = frame.strhex();
Returns
frame data encoded as printable hex string, useful for ØMQ UUIDs

The documentation for this class was generated from the following file: