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;
97 message_.getRawData(&data, &length);
98 return parse(data, length);
105 const unsigned char* end = (
const unsigned char*) data_ + length_;
106 const unsigned char* p = (
const unsigned char*) data_;
107 while ((p + 4) <= end)
109 size_t partLength = p[0];
110 partLength = partLength << 8 | p[1];
111 partLength = partLength << 8 | p[2];
112 partLength = partLength << 8 | p[3];
115 if (p + partLength <= end)
117 _parts.emplace_back(PartLocator((
const char*)(p), partLength));
121 return _parts.size();
126 return _parts.size();
131 if (index_ < _parts.size())
133 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:124
Defines the AMPS::Field class, which represents the value of a field in a message.
Field represents the value of a single field in a Message.
Definition: Field.hpp:87
AMPS::Field getPart(size_t index_) const
Returns the data of a message part.
Definition: CompositeMessageParser.hpp:129
CompositeMessageParser(void)=default
Creates a new CompositeMessageParser with 0 valid parts.
size_t parse(const T &message_)
Parses a composite message, first clearing any existing data in the parser.
Definition: CompositeMessageParser.hpp:93
Definition: AMPSException.hpp:32
Used to retrieve individual message parts from AMPS composite messages, which are messages where the ...
Definition: CompositeMessageParser.hpp:45