dataformfieldcontainer.h
/*
Copyright (c) 2005-2023 by Jakob Schröter <js@camaya.net>
This file is part of the gloox library. http://camaya.net/gloox
This software is distributed under a license. The full license
agreement can be found in the file LICENSE in this distribution.
This software may not be copied, modified, sold or distributed
other than expressed in the named license agreement.
This software is distributed without any warranty.
*/
#ifndef DATAFORMFIELDCONTAINER_H__
#define DATAFORMFIELDCONTAINER_H__
#include "dataformfield.h"
#include <string>
#include <list>
namespace gloox
{
class DataFormField;
class GLOOX_API DataFormFieldContainer
{
public:
DataFormFieldContainer();
DataFormFieldContainer( const DataFormFieldContainer& dffc );
virtual ~DataFormFieldContainer();
typedef std::list<DataFormField*> FieldList;
bool hasField( const std::string& field ) const
{ return DataFormFieldContainer::field( field ) != 0; }
DataFormField* field( const std::string& field ) const;
FieldList& fields() { return m_fields; }
const FieldList& fields() const { return m_fields; }
virtual void setFields( FieldList& fields ) { m_fields = fields; }
virtual void addField( DataFormField* field ) { m_fields.push_back( field ); }
DataFormField* addField( DataFormField::FieldType type, const std::string& name,
const std::string& value = EmptyString,
const std::string& label = EmptyString )
{
DataFormField* field = new DataFormField( name, value, label, type );
m_fields.push_back( field );
return field;
}
protected:
FieldList m_fields;
};
}
#endif // DATAFORMFIELDCONTAINER_H__
gloox::DataFormFieldContainer::addField
virtual void addField(DataFormField *field)
Definition dataformfieldcontainer.h:99
gloox::DataFormFieldContainer::DataFormFieldContainer
DataFormFieldContainer()
Definition dataformfieldcontainer.cpp:21
gloox::DataFormFieldContainer::setFields
virtual void setFields(FieldList &fields)
Definition dataformfieldcontainer.h:92
gloox::DataFormFieldContainer::field
DataFormField * field(const std::string &field) const
Definition dataformfieldcontainer.cpp:39
gloox::DataFormFieldContainer::hasField
bool hasField(const std::string &field) const
Definition dataformfieldcontainer.h:64
gloox::DataFormFieldContainer::fields
const FieldList & fields() const
Definition dataformfieldcontainer.h:85
gloox::DataFormFieldContainer::FieldList
std::list< DataFormField * > FieldList
Definition dataformfieldcontainer.h:57
gloox::DataFormFieldContainer::fields
FieldList & fields()
Definition dataformfieldcontainer.h:79
gloox::DataFormFieldContainer::addField
DataFormField * addField(DataFormField::FieldType type, const std::string &name, const std::string &value=EmptyString, const std::string &label=EmptyString)
Definition dataformfieldcontainer.h:109
gloox::DataFormField
An abstraction of a single field in a XEP-0004 Data Form.
Definition dataformfield.h:34
gloox::DataFormField::FieldType
FieldType
Definition dataformfield.h:41
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124