BLPAPI C++  3.20.6
Message Class Reference

#include <blpapi_message.h>

Classes

struct  RecapType
 

Public Types

enum  Fragment {
  FRAGMENT_NONE = 0,
  FRAGMENT_START = 1,
  FRAGMENT_INTERMEDIATE = 2,
  FRAGMENT_END = 3
}
 

Public Member Functions

 Message (const Message &original)
 
 ~Message ()
 
Messageoperator= (const Message &rhs)
 
Name messageType () const
 
const char * topicName () const
 
Service service () const
 
int numCorrelationIds () const
 
CorrelationId correlationId (size_t index=0) const
 
RecapType::Type recapType () const
 
bool hasElement (const Name &name, bool excludeNullElements=false) const
 
bool hasElement (const char *name, bool excludeNullElements=false) const
 
size_t numElements () const
 
const Element getElement (const Name &name) const
 
const Element getElement (const char *name) const
 
bool getElementAsBool (const Name &name) const
 
bool getElementAsBool (const char *name) const
 
char getElementAsChar (const Name &name) const
 
char getElementAsChar (const char *name) const
 
Int32 getElementAsInt32 (const Name &name) const
 
Int32 getElementAsInt32 (const char *name) const
 
Int64 getElementAsInt64 (const Name &name) const
 
Int64 getElementAsInt64 (const char *name) const
 
Float32 getElementAsFloat32 (const Name &name) const
 
Float32 getElementAsFloat32 (const char *name) const
 
Float64 getElementAsFloat64 (const Name &name) const
 
Float64 getElementAsFloat64 (const char *name) const
 
Datetime getElementAsDatetime (const Name &name) const
 
Datetime getElementAsDatetime (const char *name) const
 
const char * getElementAsString (const Name &name) const
 
const char * getElementAsString (const char *name) const
 
Bytes getElementAsBytes (const Name &name) const
 
const char * getRequestId () const
 
const Element asElement () const
 
const char * getPrivateData (size_t *size) const
 
Fragment fragmentType () const
 
int timeReceived (TimePoint *timestamp) const
 
std::ostream & print (std::ostream &stream, int level=0, int spacesPerLevel=4) const
 

Detailed Description

A handle to a single message.

Message objects are obtained from a MessageIterator. Each Message is associated with a Service and with one or more CorrelationId values. The Message contents are represented as an Element and some convenient shortcuts are supplied to the Element accessors.

A Message is a handle to a single underlying protocol message. The underlying messages are reference counted - the underlying Message object is freed when the last Message object which references it is destroyed.

See Component blpapi_message

Member Enumeration Documentation

◆ Fragment

enum Fragment

A message could be split into more than one fragments to reduce each message size. This enum is used to indicate whether a message is a fragmented message and the position in the fragmented messages.

Enumerator
FRAGMENT_NONE 

message is not fragmented

FRAGMENT_START 

the first fragmented message

FRAGMENT_INTERMEDIATE 

intermediate fragmented messages

FRAGMENT_END 

the last fragmented message

Constructor & Destructor Documentation

◆ Message()

Message ( const Message original)

Construct the message using the handle of the original.

◆ ~Message()

~Message ( )

Destroy this message.

Member Function Documentation

◆ asElement()

const Element asElement ( ) const

Returns the contents of this Message as a read-only Element. The Element returned remains valid until this Message is destroyed.

◆ correlationId()

CorrelationId correlationId ( size_t  index = 0) const

Returns the specified indexth CorrelationId associated with this message. If index>=numCorrelationIds() then an exception is thrown.

◆ fragmentType()

Message::Fragment fragmentType ( ) const

Return fragment type of this message. The return value is a value of enum Fragment to indicate whether it is a fragmented message of a big message and its positions in fragmentation if it is.

◆ getElement() [1/2]

const Element getElement ( const Name name) const

Equivalent to asElement().getElement(name).

◆ getElement() [2/2]

const Element getElement ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElement(name).

◆ getElementAsBool() [1/2]

bool getElementAsBool ( const Name name) const

Equivalent to asElement().getElementAsBool(name).

◆ getElementAsBool() [2/2]

bool getElementAsBool ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsBool(name).

◆ getElementAsBytes()

Bytes getElementAsBytes ( const Name name) const

Equivalent to asElement().getElementAsBytes(name).

◆ getElementAsChar() [1/2]

char getElementAsChar ( const Name name) const

Equivalent to asElement().getElementAsChar(name).

◆ getElementAsChar() [2/2]

char getElementAsChar ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsChar(name).

◆ getElementAsDatetime() [1/2]

Datetime getElementAsDatetime ( const Name name) const

Equivalent to asElement().getElementAsDatetime(name).

◆ getElementAsDatetime() [2/2]

Datetime getElementAsDatetime ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsDatetime(name).

◆ getElementAsFloat32() [1/2]

Float32 getElementAsFloat32 ( const Name name) const

Equivalent to asElement().getElementAsFloat32(name).

◆ getElementAsFloat32() [2/2]

Float32 getElementAsFloat32 ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsFloat32(name).

◆ getElementAsFloat64() [1/2]

Float64 getElementAsFloat64 ( const Name name) const

Equivalent to asElement().getElementAsFloat64(name).

◆ getElementAsFloat64() [2/2]

Float64 getElementAsFloat64 ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsFloat64(name).

◆ getElementAsInt32() [1/2]

Int32 getElementAsInt32 ( const Name name) const

Equivalent to asElement().getElementAsInt32(name).

◆ getElementAsInt32() [2/2]

Int32 getElementAsInt32 ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsInt32(name).

◆ getElementAsInt64() [1/2]

Int64 getElementAsInt64 ( const Name name) const

Equivalent to asElement().getElementAsInt64(name).

◆ getElementAsInt64() [2/2]

Int64 getElementAsInt64 ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsInt64(name).

◆ getElementAsString() [1/2]

const char * getElementAsString ( const Name name) const

Equivalent to asElement().getElementAsString(name).

◆ getElementAsString() [2/2]

const char * getElementAsString ( const char *  name) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().getElementAsString(name).

◆ getPrivateData()

const char * getPrivateData ( size_t *  size) const

DEPRECATED

Return a raw pointer to the message private data if it had any. If size is a valid pointer (not 0), it will be filled with the size of the private data. If the message has no private data attached to it the return value is 0 and the size pointer (if valid) is set to 0.

◆ getRequestId()

const char * getRequestId ( ) const

Return a pointer offering unmodifiable access to the message's request id if one exists, otherwise return null.

When present, the request id can be reported to Bloomberg to troubleshoot the cause of failure messages, or issues with the data contained in the message.

Note that request id is not the same as correlation id and should not be used for correlation purposes.

◆ hasElement() [1/2]

bool hasElement ( const Name name,
bool  excludeNullElements = false 
) const

Equivalent to asElement().hasElement(name).

◆ hasElement() [2/2]

bool hasElement ( const char *  name,
bool  excludeNullElements = false 
) const
Deprecated:
Use the form that takes Name instead of const char*.

Equivalent to asElement().hasElement(name).

◆ messageType()

Name messageType ( ) const

Returns the type of this message.

◆ numCorrelationIds()

int numCorrelationIds ( ) const

Returns the number of CorrelationIds associated with this message.

Note: A Message will have exactly one CorrelationId unless allowMultipleCorrelatorsPerMsg option was enabled for the Session this Message came from. When allowMultipleCorrelatorsPerMsg is disabled (the default) and more than one active subscription would result in the same Message the Message is delivered multiple times (without making physical copied). Each Message is accompanied by a single CorrelationId. When allowMultipleCorrelatorsPerMsg is enabled and more than one active subscription would result in the same Message the Message is delivered once with a list of corresponding CorrelationId values.

◆ numElements()

size_t numElements ( ) const

Equivalent to asElement().numElements().

◆ operator=()

Message & operator= ( const Message rhs)

Copies the message specified by rhs into the current message.

◆ print()

std::ostream & print ( std::ostream &  stream,
int  level = 0,
int  spacesPerLevel = 4 
) const

Format this Message to the specified output stream at the (absolute value of) the optionally specified indentation level and return a reference to stream. If level is specified, optionally specify spacesPerLevel, the number of spaces per indentation level for this and all of its nested objects. If level is negative, suppress indentation of the first line. If spacesPerLevel is negative, format the entire output on one line, suppressing all but the initial indentation (as governed by level).

◆ recapType()

Message::RecapType::Type recapType ( ) const

Return the recap type of this message. The return value is a value of enum RecapType::Type to indicate whether this message is a solicited recap, an unsolicited recap, or neither.

◆ service()

Service service ( ) const

Returns the service which sent this Message.

◆ timeReceived()

int timeReceived ( TimePoint timestamp) const

Load into the specified timestamp, the time when the message was received by the sdk. This method will fail if there is no timestamp associated with Message. On failure, the timestamp is not modified. Return 0 on success and a non-zero value otherwise. Note that by default the subscription data messages are not timestamped (but all the other messages are). To enable recording receive time for subscription data, set SessionOptions::recordSubscriptionDataReceiveTimes.

◆ topicName()

const char * topicName ( ) const
Deprecated:
This method will always return empty string.

Returns a pointer to a null-terminated string containing the topic string associated with this message. If there is no topic associated with this message then an empty string is returned. The pointer returned remains valid until the Message is destroyed.

This function has been deprecated because messages could contain multiple payloads with different correlation ids, and each of these correlation ids may map to different topic strings.

In such scenario, it will be incorrect to return one out of the topics(for the various correlation ids in the message) as the topic name for the message.Trying to make this correct will result in some extra look up costs.

For correctness, users are encouraged to maintain a data structure in their application to help retrieve the topic name associated with the cid's present in the delivered message.


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