dataform.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 DATAFORM_H__
#define DATAFORM_H__
#include "dataformfieldcontainer.h"
#include "adhocplugin.h"
#include <string>
#include <list>
namespace gloox
{
class Tag;
class DataFormItem;
class DataFormReported;
enum FormType
{
TypeForm,
TypeSubmit,
TypeCancel,
TypeResult,
TypeInvalid
};
class GLOOX_API DataForm : public AdhocPlugin, public DataFormFieldContainer
{
public:
typedef std::list<DataFormItem*> ItemList;
DataForm( FormType type, const StringList& instructions, const std::string& title = EmptyString );
DataForm( FormType type, const std::string& title = EmptyString );
DataForm( const Tag* tag );
DataForm( const DataForm& form );
virtual ~DataForm();
const std::string& title() const { return m_title; }
void setTitle( const std::string& title ) { m_title = title; }
const StringList& instructions() const { return m_instructions; }
void setInstructions( const StringList& instructions ) { m_instructions = instructions; }
const DataFormReported* reported() const { return m_reported; }
const ItemList& items() const { return m_items; }
FormType type() const { return m_type; }
void setType( FormType type ) { m_type = type; }
bool parse( const Tag* tag );
operator bool() const { return m_type != TypeInvalid; }
// reimplemented from StanzaExtension
virtual const std::string& filterString() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* newInstance( const Tag* tag ) const
{
return new DataForm( tag );
}
// reimplemented from StanzaExtension
virtual Tag* tag() const;
// reimplemented from StanzaExtension
virtual StanzaExtension* clone() const
{
return new DataForm( *this );
}
protected:
FormType m_type;
private:
StringList m_instructions;
std::string m_title;
DataFormReported* m_reported;
ItemList m_items;
};
}
#endif // DATAFORM_H__
gloox::AdhocPlugin::AdhocPlugin
AdhocPlugin(int type)
Definition adhocplugin.h:47
gloox::DataFormFieldContainer::DataFormFieldContainer
DataFormFieldContainer()
Definition dataformfieldcontainer.cpp:21
gloox::DataFormItem
An abstraction of an <item> element in a XEP-0004 Data Form of type result.
Definition dataformitem.h:32
gloox::DataFormReported
An abstraction of a <reported> element in a XEP-0004 Data Form of type result.
Definition dataformreported.h:34
gloox::DataForm::reported
const DataFormReported * reported() const
Definition dataform.h:131
gloox::DataForm::clone
virtual StanzaExtension * clone() const
Definition dataform.h:178
gloox::DataForm::instructions
const StringList & instructions() const
Definition dataform.h:116
gloox::DataForm::title
const std::string & title() const
Definition dataform.h:103
gloox::DataForm::items
const ItemList & items() const
Definition dataform.h:137
gloox::DataForm::newInstance
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition dataform.h:169
gloox::DataForm::ItemList
std::list< DataFormItem * > ItemList
Definition dataform.h:62
gloox::DataForm::DataForm
DataForm(FormType type, const StringList &instructions, const std::string &title=EmptyString)
Definition dataform.cpp:24
gloox::DataForm::setTitle
void setTitle(const std::string &title)
Definition dataform.h:110
gloox::DataForm::setInstructions
void setInstructions(const StringList &instructions)
Definition dataform.h:125
gloox::DataForm::setType
void setType(FormType type)
Definition dataform.h:150
gloox::DataForm::type
FormType type() const
Definition dataform.h:144
gloox::DataForm::tag
virtual Tag * tag() const
Definition dataform.cpp:106
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition stanzaextension.h:204
gloox::Tag
This is an abstraction of an XML element.
Definition tag.h:47
gloox
The namespace for the gloox library.
Definition adhoc.cpp:28
gloox::StringList
std::list< std::string > StringList
Definition gloox.h:1251
gloox::EmptyString
const std::string EmptyString
Definition gloox.cpp:124
gloox::FormType
FormType
Definition dataform.h:34
gloox::TypeSubmit
@ TypeSubmit
Definition dataform.h:37
gloox::TypeCancel
@ TypeCancel
Definition dataform.h:39
gloox::TypeInvalid
@ TypeInvalid
Definition dataform.h:44
gloox::TypeForm
@ TypeForm
Definition dataform.h:35
gloox::TypeResult
@ TypeResult
Definition dataform.h:41