00001 /* 00002 Copyright (c) 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 "dataformitem.h" 00015 00016 #include "tag.h" 00017 00018 namespace gloox 00019 { 00020 00021 DataFormItem::DataFormItem() 00022 : DataFormField( FIELD_TYPE_ITEM ) 00023 { 00024 } 00025 00026 DataFormItem::DataFormItem( Tag* tag ) 00027 : DataFormField( FIELD_TYPE_ITEM ) 00028 { 00029 if( tag->name() != "item" ) 00030 return; 00031 00032 Tag::TagList &l = tag->children(); 00033 Tag::TagList::const_iterator it = l.begin(); 00034 for( ; it != l.end(); ++it ) 00035 { 00036 DataFormField *f = new DataFormField( (*it) ); 00037 m_fields.push_back( f ); 00038 } 00039 } 00040 00041 DataFormItem::~DataFormItem() 00042 { 00043 } 00044 00045 Tag* DataFormItem::tag() 00046 { 00047 Tag *i = new Tag ( "item" ); 00048 DataFormBase::FieldList::const_iterator it = m_fields.begin(); 00049 for( ; it != m_fields.end(); ++it ) 00050 { 00051 i->addChild( (*it)->tag() ); 00052 } 00053 return i; 00054 } 00055 00056 }