fipa_acl  1.4
Public Member Functions | List of all members
fipa::acl::BitefficientMessageParser Class Reference

Allows to parse a bytestream that conforms to the bitefficient representation of FIPA messages to a ACLMessage. More...

#include <bitefficient_message_parser.h>

Inherits fipa::acl::MessageParserImplementation.

Public Member Functions

bool parseData (const std::string &storage, ACLMessage &msg)
 parses a correctly encoded message according to grammar_bitefficient.h and creates a Message object for internal use More...
 
bool buildMessage (const Message &parsedMsg, ACLMessage &msg)
 creates an unpopulated message object and passes it around to have its fields populated, along with the parsed message where the data is extracted from More...
 
- Public Member Functions inherited from fipa::acl::MessageParserImplementation
virtual ~MessageParserImplementation ()
 

Detailed Description

Allows to parse a bytestream that conforms to the bitefficient representation of FIPA messages to a ACLMessage.

Given a bytestream that conforms to the FIPA Standard for the bitefficient representation of messages, this class can be used to parse this stream into a ACLMessage. The parsing makes extensive use of the boost::spirit library, a library whose contribution we want to acknowledge here. The Spirit library has been used to define the grammar and the underlying parser, i.e. the core of this library.

Internals: Since the parser works with a number of customized data structures to facilitate parsing, a number of function have been implemented in order to perform the conversion to the datastructure required for a ACLMessage. Yet (by August 2010), we haven't done any performance evaluation of the library.

Definition at line 43 of file bitefficient_message_parser.h.

Member Function Documentation

◆ buildMessage()

bool fipa::acl::BitefficientMessageParser::buildMessage ( const Message parsedMsg,
ACLMessage msg 
)

creates an unpopulated message object and passes it around to have its fields populated, along with the parsed message where the data is extracted from

Parameters
parsedMsgThe (intermediate) message from the spirit parser
msgThe (final) ACLMessage to be filled with the parsed data
Returns
the decoded ACLMessage object

Definition at line 40 of file bitefficient_message_parser.cpp.

41 {
42  msg.setPerformative(parsedMsg.type);
43  buildParameters(parsedMsg.parameters, msg);
44 
45  return true;
46 }

◆ parseData()

bool fipa::acl::BitefficientMessageParser::parseData ( const std::string &  storage,
ACLMessage msg 
)
virtual

parses a correctly encoded message according to grammar_bitefficient.h and creates a Message object for internal use

Parameters
storageArray of bytes that represent the bitefficient FIPA encoded message
msgThe message extracted from the data
Returns
The decoded ACLMessage object

Reimplemented from fipa::acl::MessageParserImplementation.

Definition at line 21 of file bitefficient_message_parser.cpp.

22 {
23  typedef fipa::acl::bitefficient::Message<std::string::const_iterator> bitefficient_message_grammar;
24  bitefficient_message_grammar grammar;
25  fipa::acl::Message parseTree;
26 
27  std::string::const_iterator iter = storage.begin();
28  std::string::const_iterator end = storage.end();
29  bool r = parse(iter, end, grammar, parseTree);
30 
31  if(r && iter == end)
32  {
33  return buildMessage(parseTree, msg);
34  }
35 
36  return false;
37 
38 }
bool buildMessage(const Message &parsedMsg, ACLMessage &msg)
creates an unpopulated message object and passes it around to have its fields populated, along with the parsed message where the data is extracted from

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