gloox 1.0.27
dataformfieldcontainer.h
1/*
2 Copyright (c) 2005-2023 by Jakob Schröter <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
22namespace gloox
23{
24
25 class DataFormField;
26
35 class GLOOX_API DataFormFieldContainer
36 {
37 public:
42
48
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__
An abstract base class for a XEP-0004 Data Form.
virtual void addField(DataFormField *field)
virtual void setFields(FieldList &fields)
bool hasField(const std::string &field) const
const FieldList & fields() const
std::list< DataFormField * > FieldList
DataFormField * addField(DataFormField::FieldType type, const std::string &name, const std::string &value=EmptyString, const std::string &label=EmptyString)
An abstraction of a single field in a XEP-0004 Data Form.
The namespace for the gloox library.
Definition adhoc.cpp:28