TibrvMsg()

Constructor

Declaration

TibrvMsg(tibrv_u32 initialSize=512);    // Declare empty msg obj.
TibrvMsg(const TibrvMsg& msg);          // Copy constructor.
TibrvMsg(const void* bytes);            // Create from bytes.
TibrvMsg(tibrvMsg Cmsg,                 // Create from C handle.
         tibrv_bool detached);

Purpose

Create a message object.

Remarks

The first form of this constructor merely declares a C++ variable. It does not allocate storage; it does not create a C message object. (Subsequent operations on the variable automatically allocates storage and create the inner structure.) This form works efficiently with methods such as TibrvTransport::sendRequest(), which requires a variable to receive its reply message and overwrites the contents of that variable.

The other forms of this constructor simultaneously declare a variable, allocate storage, create an object with inner structure, and store the status code in the object. The status code indicates any conditions that might make the message object unusable; if the object is unusable, any subsequent operation on the message will return the same status code.

None of the constructors place address information (for example, the subject) on the new message object.

This class has no destroy() method; use the destructor instead (see ~TibrvMsg()).

Parameter

Description

initialSize

Optional.

This form of the constructor declares an empty message variable. When a subsequent operation triggers storage allocation, allocate a storage block of this size (in bytes).

msg

Create an independent copy of this message.

bytes

Create a message with fields populated from this byte array. The new message is completely independent of the byte array.

For example, programs can create such byte arrays from messages using the method TibrvMsg::getAsBytes(), and store them in files; after reading them from such files, programs can reconstruct a message from its byte array.

Cmsg

Create a C++ message object that embeds this C message handle. This form of the constructor does not copy the C message.

detached

Specify whether the Cmsg is detached—that is, whether the program owns the message.

TIBRV_TRUE indicates a detached inbound message, or a message created in the program. The destructor also destroys the embedded C message.

TIBRV_FALSE indicates an attached inbound message. The destructor does not destroy the embedded C message.

See Also

TibrvMsg::createCopy()

TibrvMsg::detach()

TibrvMsg::getAsBytes()

TibrvMsg::getStatus()

TibrvMsg::getHandle()

tibrvMsg in TIBCO Rendezvous C Reference