26 #ifndef _AMPS_COMPOSITEMESSAGEPARSER_HPP_ 27 #define _AMPS_COMPOSITEMESSAGEPARSER_HPP_ 62 size_t parse(
const T& message_);
71 size_t parse(
const char* data_,
size_t length_);
76 size_t size(
void)
const;
86 typedef std::pair<const char*, size_t> PartLocator;
87 typedef std::vector<PartLocator> PartVector;
100 message_.getRawData(&data, &length);
101 return parse(data, length);
108 const unsigned char* end = (
const unsigned char*) data_ + length_;
109 const unsigned char* p = (
const unsigned char*) data_;
110 while ((p + 4) <= end)
112 size_t partLength = p[0];
113 partLength = partLength << 8 | p[1];
114 partLength = partLength << 8 | p[2];
115 partLength = partLength << 8 | p[3];
118 if (p + partLength <= end)
120 #ifdef AMPS_USE_EMPLACE 121 _parts.emplace_back(PartLocator((
const char*)(p), partLength));
123 _parts.push_back(PartLocator((
const char*)(p), partLength));
128 return _parts.size();
133 return _parts.size();
138 if (index_ < _parts.size())
140 const PartLocator& part = _parts[index_];
size_t size(void) const
Returns the number of valid message parts in the message that was last parsed.
Definition: CompositeMessageParser.hpp:131
Defines the AMPS::Field class, which represents the value of a field in a message.
CompositeMessageParser(void)
Creates a new CompositeMessageParser with 0 valid parts.
Definition: CompositeMessageParser.hpp:91
Field represents the value of a single field in a Message.
Definition: Field.hpp:86
AMPS::Field getPart(size_t index_) const
Returns the data of a message part.
Definition: CompositeMessageParser.hpp:136
size_t parse(const T &message_)
Parses a composite message, first clearing any existing data in the parser.
Definition: CompositeMessageParser.hpp:96
Definition: ampsplusplus.hpp:102
Used to retrieve individual message parts from AMPS composite messages, which are messages where the ...
Definition: CompositeMessageParser.hpp:45