Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | Related Pages

jingledescription.cpp

00001 /*
00002   Copyright (c) 2008 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 #include "jingledescription.h"
00015 #include "tag.h"
00016 
00017 namespace gloox
00018 {
00019 
00020   namespace Jingle
00021   {
00022 
00023     // ---- Jingle::Description::Payload ----
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     // ---- ~Jingle::Description::Payload ----
00045 
00046     // ---- Jingle::Description ----
00047     Description::~Description()
00048     {
00049 //       util::clearList( m_payload );
00050       // FIXME:
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 }

Generated on Mon Jun 23 10:50:18 2008 for gloox by  doxygen 1.4.1