DataFormField Class Reference

An abstraction of a single field in a XEP-0004 Data Form. More...

#include <dataformfield.h>

Inherited by DataFormItem, and DataFormReported.

List of all members.

Public Types

enum  DataFormFieldType {
  FieldTypeBoolean, FieldTypeFixed, FieldTypeHidden, FieldTypeJidMulti,
  FieldTypeJidSingle, FieldTypeListMulti, FieldTypeListSingle, FieldTypeTextMulti,
  FieldTypeTextPrivate, FieldTypeTextSingle, FieldTypeItem, FieldTypeReported,
  FieldTypeInvalid, FieldTypeNone
}

Public Member Functions

 DataFormField (DataFormFieldType type=FieldTypeTextSingle)
 DataFormField (const std::string &name, const std::string &value="", const std::string &label="", DataFormFieldType type=FieldTypeTextSingle)
 DataFormField (Tag *tag)
virtual ~DataFormField ()
virtual StringMapoptions ()
virtual Tagtag () const
virtual const std::string & name () const
virtual void setName (const std::string &name)
virtual void setOptions (const StringMap &options)
virtual void addOption (const std::string &label, const std::string &value)
virtual bool required () const
virtual void setRequired (bool required)
virtual DataFormFieldType type () const
virtual const std::string & label () const
virtual void setLabel (const std::string &label)
virtual const std::string & description () const
virtual void setDescription (const std::string &desc)
virtual const std::string & value () const
virtual void setValue (const std::string &value)
virtual const StringListvalues () const
virtual void setValues (const StringList &values)
virtual void addValue (const std::string &value)

Detailed Description

An abstraction of a single field in a XEP-0004 Data Form.

Author:
Jakob Schroeter <js@camaya.net>
Since:
0.7

Definition at line 32 of file dataformfield.h.


Member Enumeration Documentation

Describes the possible type of a Data Form Field.

Enumerator:
FieldTypeBoolean 

The field enables an entity to gather or provide an either-or choice between two options. The default value is "false".

FieldTypeFixed 

The field is intended for data description (e.g., human-readable text such as "section" headers) rather than data gathering or provision. The <value/> child SHOULD NOT contain newlines (the \n and \r characters); instead an application SHOULD generate multiple fixed fields, each with one <value/> child.

FieldTypeHidden 

The field is not shown to the entity providing information, but instead is returned with the form.

FieldTypeJidMulti 

The field enables an entity to gather or provide multiple Jabber IDs.

FieldTypeJidSingle 

The field enables an entity to gather or provide a single Jabber ID.

FieldTypeListMulti 

The field enables an entity to gather or provide one or more options from among many.

FieldTypeListSingle 

The field enables an entity to gather or provide one option from among many.

FieldTypeTextMulti 

The field enables an entity to gather or provide multiple lines of text.

FieldTypeTextPrivate 

The field enables an entity to gather or provide a single line or word of text, which shall be obscured in an interface (e.g., *****).

FieldTypeTextSingle 

The field enables an entity to gather or provide a single line or word of text, which may be shown in an interface. This field type is the default and MUST be assumed if an entity receives a field type it does not understand.

FieldTypeItem 

The field really is an element of type 'item' which allows for addition of sub-fields. See the explanantion in XEP-0004 (Data Forms) Section 3.4 for more information

FieldTypeReported 

The field really is an element of type 'reported' which allows for addition of sub-fields. See the explanantion in XEP-0004 (Data Forms) Section 3.4 for more information

FieldTypeInvalid 

The field is invalid. Only possible if the field was created from a Tag not correctly describing a Data Form Field.

FieldTypeNone 

The field is child of either a <reported> or <item> element or has no type attribute.

Definition at line 39 of file dataformfield.h.


Constructor & Destructor Documentation

DataFormField ( DataFormFieldType  type = FieldTypeTextSingle  ) 

Constructs a new DataForm field.

Parameters:
type The type of the field. Default: text-single.

Definition at line 20 of file dataformfield.cpp.

DataFormField ( const std::string &  name,
const std::string &  value = "",
const std::string &  label = "",
DataFormFieldType  type = FieldTypeTextSingle 
)

Constructs a new DataForm field and fills it with the given values.

Parameters:
name The field's name (the value of the 'var' attribute).
value The field's value.
label The field's label.
type The field's type.
Since:
0.9

Definition at line 25 of file dataformfield.cpp.

DataFormField ( Tag tag  ) 

Constructs a new Data Form Field from an existing tag that describes a field.

Parameters:
tag The tag to parse.

Definition at line 32 of file dataformfield.cpp.

~DataFormField (  )  [virtual]

Virtual destructor.

Definition at line 92 of file dataformfield.cpp.


Member Function Documentation

virtual void addOption ( const std::string &  label,
const std::string &  value 
) [inline, virtual]

Adds a single option to the list of options.

Parameters:
label The label of the option.
value The value of the option.
Since:
0.9.4

Definition at line 148 of file dataformfield.h.

virtual void addValue ( const std::string &  value  )  [inline, virtual]

Adds a single value to the list of values.

Parameters:
value The value to add.

Definition at line 222 of file dataformfield.h.

virtual const std::string& description (  )  const [inline, virtual]

Use this function to retrieve the description of this field.

Returns:
The description of this field

Definition at line 185 of file dataformfield.h.

virtual const std::string& label (  )  const [inline, virtual]

Use this function to retrieve the describing label of this field.

Returns:
The describing label of this field.

Definition at line 173 of file dataformfield.h.

virtual const std::string& name (  )  const [inline, virtual]

Use this function to retrieve the name of the field (the content of the 'var' attribute).

Returns:
The name of the field.

Definition at line 124 of file dataformfield.h.

virtual StringMap& options (  )  [inline, virtual]

Use this function to retrieve the optional values of a field.

Returns:
The options of a field.

Definition at line 110 of file dataformfield.h.

virtual bool required (  )  const [inline, virtual]

Use this function to determine whether or not this field is required.

Returns:
Whether or not this field is required.

Definition at line 155 of file dataformfield.h.

virtual void setDescription ( const std::string &  desc  )  [inline, virtual]

Use this function to set the description of this field.

Parameters:
desc The description of this field.

Definition at line 191 of file dataformfield.h.

virtual void setLabel ( const std::string &  label  )  [inline, virtual]

Use this function to set the describing label of this field.

Parameters:
label The describing label of this field.

Definition at line 179 of file dataformfield.h.

virtual void setName ( const std::string &  name  )  [inline, virtual]

Sets the name (the content of the 'var' attribute) of the field. The name identifies the field uniquely in the form.

Parameters:
name The new name of the field.
Note:
Fields of type other than 'fixed' MUST have a name, if it is 'fixed', it MAY.

Definition at line 132 of file dataformfield.h.

virtual void setOptions ( const StringMap options  )  [inline, virtual]

Use this function to set the optional values of the field. The key of the map will be used as the label of the option, while the value will be used as ... the value. ;)

Parameters:
options The optional values of a list* or *multi type of field.

Definition at line 140 of file dataformfield.h.

virtual void setRequired ( bool  required  )  [inline, virtual]

Use this field to set this field to be required.

Parameters:
required Whether or not this field is required.

Definition at line 161 of file dataformfield.h.

virtual void setValue ( const std::string &  value  )  [inline, virtual]

Use this function to set the value of this field.

Parameters:
value The new value of this field.

Definition at line 203 of file dataformfield.h.

virtual void setValues ( const StringList values  )  [inline, virtual]

Use this function to set multiple values of this field, if it is of type 'text-multi'. If its not, use setValue() instead.

Parameters:
values The new values of this field.

Definition at line 216 of file dataformfield.h.

Tag * tag (  )  const [virtual]

Use this function to create a Tag representation of the form field. This is usually called by DataForm.

Returns:
A Tag hierarchically describing the form field, or NULL if the field is invalid (i.e. created from a Tag not correctly describing a Data Form Field).

Reimplemented in DataFormItem, and DataFormReported.

Definition at line 96 of file dataformfield.cpp.

virtual DataFormFieldType type (  )  const [inline, virtual]

Use this function to retrieve the type of this field.

Returns:
The type of this field.

Definition at line 167 of file dataformfield.h.

virtual const std::string& value (  )  const [inline, virtual]

Use this function to retrieve the value of this field.

Returns:
The value of this field.

Definition at line 197 of file dataformfield.h.

virtual const StringList& values (  )  const [inline, virtual]

Use this function to retrieve the values of this field, if its of type 'text-multi'.

Returns:
The value of this field.

Definition at line 209 of file dataformfield.h.


The documentation for this class was generated from the following files:

Generated on Mon Dec 7 13:28:24 2009 for gloox by  doxygen 1.6.1