gloox  1.0
dataformfieldcontainer.h
1 /*
2  Copyright (c) 2005-2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #ifndef DATAFORMFIELDCONTAINER_H__
15 #define DATAFORMFIELDCONTAINER_H__
16 
17 #include "dataformfield.h"
18 
19 #include <string>
20 #include <list>
21 
22 namespace gloox
23 {
24 
25  class DataFormField;
26 
35  class GLOOX_API DataFormFieldContainer
36  {
37  public:
42 
48 
52  virtual ~DataFormFieldContainer();
53 
57  typedef std::list<DataFormField*> FieldList;
58 
64  bool hasField( const std::string& field ) const
65  { return DataFormFieldContainer::field( field ) != 0; }
66 
73  DataFormField* field( const std::string& field ) const;
74 
79  FieldList& fields() { return m_fields; }
80 
85  const FieldList& fields() const { return m_fields; }
86 
92  virtual void setFields( FieldList& fields ) { m_fields = fields; }
93 
99  virtual void addField( DataFormField* field ) { m_fields.push_back( field ); }
100 
109  DataFormField* addField( DataFormField::FieldType type, const std::string& name,
110  const std::string& value = EmptyString,
111  const std::string& label = EmptyString )
112  {
113  DataFormField* field = new DataFormField( name, value, label, type );
114  m_fields.push_back( field );
115  return field;
116  }
117 
118  protected:
119  FieldList m_fields;
120 
121  };
122 
123 }
124 
125 #endif // DATAFORMFIELDCONTAINER_H__