AMPS C/C++ Client Class Reference
AMPS C/C++ Client Version 5.3.4.3
AMPS::CompositeMessageParser Class Reference

Used to retrieve individual message parts from AMPS composite messages, which are messages where the data contains a number of parts and each part is a complete message of a specific message type. More...

#include <CompositeMessageParser.hpp>

Public Member Functions

 CompositeMessageParser (void)
 Creates a new CompositeMessageParser with 0 valid parts.
 
template<class T >
size_t parse (const T &message_)
 Parses a composite message, first clearing any existing data in the parser. More...
 
size_t parse (const char *data_, size_t length_)
 Parses a composite message body, first clearing any existing data in the parser. More...
 
size_t size (void) const
 Returns the number of valid message parts in the message that was last parsed.
 
AMPS::Field getPart (size_t index_) const
 Returns the data of a message part. More...
 

Detailed Description

Used to retrieve individual message parts from AMPS composite messages, which are messages where the data contains a number of parts and each part is a complete message of a specific message type.

For example, a composite message type of "composite-json-binary" may be declared on the server that combines a set of JSON headers with an opaque binary payload. CompositeMessageParser makes it easy to retrieve the parts of a composite message from the composite message payload. CompositeMessageParser does not make a copy of the underlying data parsed: your application must ensure that the underlying data is valid while using the CompositeMessageParser.

Member Function Documentation

AMPS::Field AMPS::CompositeMessageParser::getPart ( size_t  index_) const
inline

Returns the data of a message part.

Parameters
index_The index of the part to retrieve.
Returns
A Message::Field that points to the requested message part's data. If index_ is invalid, a 0-length Message::Field pointing to NULL.
template<class T >
size_t AMPS::CompositeMessageParser::parse ( const T &  message_)
inline

Parses a composite message, first clearing any existing data in the parser.

This function is designed to accept an AMPS::Message whose data is a composite message. It will also work for any other class that implements a getDataRaw(char**, size_t*) that sets the provided char* to the start of the payload and the provided size_t to the length of the data.

Parameters
message_The AMPS::Message whose data is a composite message.
Returns
The number of valid composite message parts found in message_.
size_t AMPS::CompositeMessageParser::parse ( const char *  data_,
size_t  length_ 
)
inline

Parses a composite message body, first clearing any existing data in the parser.

Parameters
data_A pointer to the composite message data.
length_The length, in bytes, of the composite message data at data_.
Returns
The number of valid composite message parts found in message_.

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