00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "jingledescription.h"
00015 #include "tag.h"
00016
00017 namespace gloox
00018 {
00019
00020 namespace Jingle
00021 {
00022
00023
00024 Tag* Jingle::Description::Payload::tag() const
00025 {
00026 if( m_attribs.empty() )
00027 return 0;
00028
00029 Tag* t = new Tag( "payload-type" );
00030 StringMap::const_iterator it = m_attribs.begin();
00031 for( ; it != m_attribs.end(); ++it )
00032 t->addAttribute( (*it).first, (*it).second );
00033
00034 it = m_parameters.begin();
00035 for( ; it != m_parameters.end(); ++it )
00036 {
00037 Tag* p = new Tag( t, "parameter" );
00038 p->addAttribute( "name", (*it).first );
00039 p->addAttribute( "value", (*it).second );
00040 }
00041
00042 return t;
00043 }
00044
00045
00046
00047 Description::~Description()
00048 {
00049
00050
00051 PayloadList::iterator it1 = m_payload.begin();
00052 PayloadList::iterator it2;
00053 while( it1 != m_payload.end() )
00054 {
00055 it2 = it1++;
00056 delete (*it2);
00057 m_payload.erase( it2 );
00058 }
00059
00060 }
00061
00062 const std::string& Description::filterString() const
00063 {
00064 static const std::string filter = "./description[@xmlns='" + xmlns() + "']";
00065 return filter;
00066 }
00067
00068 Tag* Description::tag() const
00069 {
00070 Tag* t = new Tag( "description" );
00071 t->setXmlns( xmlns() );
00072
00073 PayloadList::const_iterator it = m_payload.begin();
00074 for( ; it != m_payload.end(); ++it )
00075 {
00076 if( (*it) )
00077 t->addChild( (*it)->tag() );
00078 }
00079
00080 return t;
00081 }
00082 }
00083
00084 }