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

#include <xml_envelope_format.h>

Inherits fipa::acl::EnvelopeFormat.

Public Member Functions

virtual ~XMLEnvelopeFormat ()
 
std::string apply (const ACLEnvelope &envelope) const
 
- Public Member Functions inherited from fipa::acl::EnvelopeFormat
virtual ~EnvelopeFormat ()
 

Detailed Description

Definition at line 10 of file xml_envelope_format.h.

Constructor & Destructor Documentation

◆ ~XMLEnvelopeFormat()

virtual fipa::acl::XMLEnvelopeFormat::~XMLEnvelopeFormat ( )
inlinevirtual

Definition at line 28 of file xml_envelope_format.h.

28 {}

Member Function Documentation

◆ apply()

std::string fipa::acl::XMLEnvelopeFormat::apply ( const ACLEnvelope envelope) const
virtual

Applies the format to the envelope

Returns
the formatted envelope object

Implements fipa::acl::EnvelopeFormat.

Definition at line 9 of file xml_envelope_format.cpp.

10 {
11  TiXmlDocument doc;
12  TiXmlDeclaration * decl = new TiXmlDeclaration( "1.0", "", "" );
13  doc.LinkEndChild( decl );
14 
15  TiXmlElement * envelopeElem = new TiXmlElement( "envelope" );
16  doc.LinkEndChild( envelopeElem );
17 
18  // Index for the params
19  int index = 1;
20  // Append base envelope
21  TiXmlElement* elem = getBaseEnvelope(envelope.getBaseEnvelope());
22  elem->SetAttribute("index", index++);
23  envelopeElem->LinkEndChild(elem);
24  // And all extra envelopes
25  BOOST_FOREACH(TiXmlElement* elem, getAllExternalEnvelopes(envelope))
26  {
27  elem->SetAttribute("index", index++);
28  envelopeElem->LinkEndChild(elem);
29  }
30 
31  TiXmlPrinter printer;
32  printer.SetIndent("");
33  printer.SetLineBreak("");
34  // When using a line break (for debugging), make sure to remove the last line break,
35  // so that the payload starts immediately after the last '>'.
36 
37  doc.Accept( &printer );
38  return printer.Str() + envelope.getPayload();
39 }

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