gloox  1.0.21
dataform.h
1 /*
2  Copyright (c) 2005-2017 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 DATAFORM_H__
15 #define DATAFORM_H__
16 
17 #include "dataformfieldcontainer.h"
18 #include "adhocplugin.h"
19 
20 #include <string>
21 #include <list>
22 
23 namespace gloox
24 {
25 
26  class Tag;
27  class DataFormItem;
28  class DataFormReported;
29 
33  enum FormType
34  {
46  };
47 
56  class GLOOX_API DataForm : public AdhocPlugin, public DataFormFieldContainer
57  {
58  public:
62  typedef std::list<DataFormItem*> ItemList;
63 
71  DataForm( FormType type, const StringList& instructions, const std::string& title = EmptyString );
72 
80  DataForm( FormType type, const std::string& title = EmptyString );
81 
86  DataForm( const Tag* tag );
87 
92  DataForm( const DataForm& form );
93 
97  virtual ~DataForm();
98 
103  const std::string& title() const { return m_title; }
104 
110  void setTitle( const std::string& title ) { m_title = title; }
111 
116  const StringList& instructions() const { return m_instructions; }
117 
125  void setInstructions( const StringList& instructions ) { m_instructions = instructions; }
126 
131  const DataFormReported* reported() const { return m_reported; }
132 
137  const ItemList& items() const { return m_items; }
138 
144  FormType type() const { return m_type; }
145 
150  void setType( FormType type ) { m_type = type; }
151 
158  bool parse( const Tag* tag );
159 
163  operator bool() const { return m_type != TypeInvalid; }
164 
165  // reimplemented from StanzaExtension
166  virtual const std::string& filterString() const;
167 
168  // reimplemented from StanzaExtension
169  virtual StanzaExtension* newInstance( const Tag* tag ) const
170  {
171  return new DataForm( tag );
172  }
173 
174  // reimplemented from StanzaExtension
175  virtual Tag* tag() const;
176 
177  // reimplemented from StanzaExtension
178  virtual StanzaExtension* clone() const
179  {
180  return new DataForm( *this );
181  }
182 
183  protected:
184  FormType m_type;
185 
186  private:
187  StringList m_instructions;
188 
189  std::string m_title;
190  DataFormReported* m_reported;
191  ItemList m_items;
192 
193  };
194 
195 }
196 
197 #endif // DATAFORM_H__
const DataFormReported * reported() const
Definition: dataform.h:131
std::list< std::string > StringList
Definition: gloox.h:1251
const ItemList & items() const
Definition: dataform.h:137
void setTitle(const std::string &title)
Definition: dataform.h:110
An abstraction of a XEP-0004 Data Form.
Definition: dataform.h:56
An abstraction of a <reported> element in a XEP-0004 Data Form of type result.
std::list< DataFormItem * > ItemList
Definition: dataform.h:62
An abstract base class for a XEP-0004 Data Form.
virtual StanzaExtension * newInstance(const Tag *tag) const
Definition: dataform.h:169
const std::string & title() const
Definition: dataform.h:103
virtual StanzaExtension * clone() const
Definition: dataform.h:178
FormType
Definition: dataform.h:33
FormType type() const
Definition: dataform.h:144
The namespace for the gloox library.
Definition: adhoc.cpp:27
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
void setInstructions(const StringList &instructions)
Definition: dataform.h:125
const StringList & instructions() const
Definition: dataform.h:116
void setType(FormType type)
Definition: dataform.h:150
const std::string EmptyString
Definition: gloox.cpp:125
This is an abstraction of an XML element.
Definition: tag.h:46
A base class for Adhoc Command plugins (DataForm, IO Data, ...).
Definition: adhocplugin.h:38