gloox  0.9.9.12
dataformbase.h
1 /*
2  Copyright (c) 2005-2008 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 DATAFORMBASE_H__
15 #define DATAFORMBASE_H__
16 
17 #include "dataformfield.h"
18 
19 #include <string>
20 #include <list>
21 
22 namespace gloox
23 {
24 
33  class GLOOX_API DataFormBase
34  {
35  public:
39  DataFormBase();
40 
44  virtual ~DataFormBase();
45 
49  typedef std::list<DataFormField*> FieldList;
50 
56  bool hasField( const std::string& field );
57 
64  DataFormField* field( const std::string& field );
65 
70  FieldList& fields() { return m_fields; }
71 
77  virtual void setFields( FieldList& fields ) { m_fields = fields; }
78 
84  virtual void addField( DataFormField *field ) { m_fields.push_back( field ); }
85 
94  DataFormField* addField( DataFormField::DataFormFieldType type, const std::string& name,
95  const std::string& value = "", const std::string& label = "" )
96  { m_fields.push_back( new DataFormField( name, value, label, type ) ); return m_fields.back(); }
97 
98  protected:
99  FieldList m_fields;
100 
101  };
102 
103 }
104 
105 #endif // DATAFORMBASE_H__