gloox 1.0
dataformfieldcontainer.h
00001 /*
00002   Copyright (c) 2005-2009 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 #ifndef DATAFORMFIELDCONTAINER_H__
00015 #define DATAFORMFIELDCONTAINER_H__
00016 
00017 #include "dataformfield.h"
00018 
00019 #include <string>
00020 #include <list>
00021 
00022 namespace gloox
00023 {
00024 
00025   class DataFormField;
00026 
00035   class GLOOX_API DataFormFieldContainer
00036   {
00037     public:
00041       DataFormFieldContainer();
00042 
00047       DataFormFieldContainer( const DataFormFieldContainer& dffc );
00048 
00052       virtual ~DataFormFieldContainer();
00053 
00057       typedef std::list<DataFormField*> FieldList;
00058 
00064       bool hasField( const std::string& field ) const
00065         { return DataFormFieldContainer::field( field ) != 0; }
00066 
00073       DataFormField* field( const std::string& field ) const;
00074 
00079       FieldList& fields() { return m_fields; }
00080 
00085       const FieldList& fields() const { return m_fields; }
00086 
00092       virtual void setFields( FieldList& fields ) { m_fields = fields; }
00093 
00099       virtual void addField( DataFormField* field ) { m_fields.push_back( field ); }
00100 
00109       DataFormField* addField( DataFormField::FieldType type, const std::string& name,
00110                                const std::string& value = EmptyString,
00111                                const std::string& label = EmptyString )
00112       {
00113         DataFormField* field = new DataFormField( name, value, label, type );
00114         m_fields.push_back( field );
00115         return field;
00116       }
00117 
00118     protected:
00119       FieldList m_fields;
00120 
00121   };
00122 
00123 }
00124 
00125 #endif // DATAFORMFIELDCONTAINER_H__