dataformbase.cpp

00001 /*
00002   Copyright (c) 2005-2006 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 "dataformbase.h"
00015 #include "dataformitem.h"
00016 #include "dataformreported.h"
00017 
00018 
00019 namespace gloox
00020 {
00021 
00022   DataFormBase::DataFormBase()
00023   {
00024   }
00025 
00026   DataFormBase::~DataFormBase()
00027   {
00028     FieldList::const_iterator it = m_fields.begin();
00029     for( ; it != m_fields.end(); ++it )
00030     {
00031       DataFormItem *i = dynamic_cast<DataFormItem*>( (*it) );
00032       if( i )
00033       {
00034         delete i;
00035         continue;
00036       }
00037 
00038       DataFormReported *r = dynamic_cast<DataFormReported*>( (*it) );
00039       if( r )
00040       {
00041         delete r;
00042         continue;
00043       }
00044 
00045       delete (*it);
00046     }
00047   }
00048 
00049   bool DataFormBase::hasField( const std::string& field )
00050   {
00051     FieldList::const_iterator it = m_fields.begin();
00052     for( ; it != m_fields.end(); ++it )
00053     {
00054       if( (*it)->name() == field )
00055         return true;
00056     }
00057 
00058     return false;
00059   }
00060 
00061   DataFormField* DataFormBase::field( const std::string& field )
00062   {
00063     FieldList::const_iterator it = m_fields.begin();
00064     for( ; it != m_fields.end(); ++it )
00065     {
00066       if( (*it)->name() == field )
00067         return (*it);
00068     }
00069 
00070     return 0;
00071   }
00072 
00073 }

Generated on Tue May 1 14:20:20 2007 for gloox by  doxygen 1.5.1