DataFormField Class Reference

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

#include <dataformfield.h>

Inherited by DataFormItem, and DataFormReported.

Inheritance diagram for DataFormField:

Inheritance graph
[legend]
List of all members.

Public Types

enum  DataFormFieldType {
  FIELD_TYPE_BOOLEAN, FIELD_TYPE_FIXED, FIELD_TYPE_HIDDEN, FIELD_TYPE_JID_MULTI,
  FIELD_TYPE_JID_SINGLE, FIELD_TYPE_LIST_MULTI, FIELD_TYPE_LIST_SINGLE, FIELD_TYPE_TEXT_MULTI,
  FIELD_TYPE_TEXT_PRIVATE, FIELD_TYPE_TEXT_SINGLE, FIELD_TYPE_ITEM, FIELD_TYPE_REPORTED,
  FIELD_TYPE_INVALID, FIELD_TYPE_NONE
}

Public Member Functions

 DataFormField (DataFormFieldType type=FIELD_TYPE_TEXT_SINGLE)
 DataFormField (Tag *tag)
virtual ~DataFormField ()
StringMapoptions ()
virtual Tagtag () const
virtual const std::string & name () const
void setName (const std::string &name)
void setOptions (const StringMap &options)
bool required () const
void setRequired (bool required)
DataFormFieldType type () const
const std::string & label () const
void setLabel (const std::string &label)
const std::string & value () const
void setValue (const std::string &value)
const StringListvalues () const
void setValues (const StringList &values)

Detailed Description

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

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

Definition at line 31 of file dataformfield.h.


Member Enumeration Documentation

enum DataFormFieldType

Describes the possible type of a Data Form Field.

Enumerator:
FIELD_TYPE_BOOLEAN  The field enables an entity to gather or provide an either-or choice between two options. The default value is "false".
FIELD_TYPE_FIXED  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.
FIELD_TYPE_HIDDEN  The field is not shown to the entity providing information, but instead is returned with the form.
FIELD_TYPE_JID_MULTI  The field enables an entity to gather or provide multiple Jabber IDs.
FIELD_TYPE_JID_SINGLE  The field enables an entity to gather or provide a single Jabber ID.
FIELD_TYPE_LIST_MULTI  The field enables an entity to gather or provide one or more options from among many.
FIELD_TYPE_LIST_SINGLE  The field enables an entity to gather or provide one option from among many.
FIELD_TYPE_TEXT_MULTI  The field enables an entity to gather or provide multiple lines of text.
FIELD_TYPE_TEXT_PRIVATE  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., *****).
FIELD_TYPE_TEXT_SINGLE  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.
FIELD_TYPE_ITEM  The field really is an element of type 'item' which allows for addition of sub-fields. See the explanantion in JEP-0004 (Data Forms) Section 3.4 for more information
FIELD_TYPE_REPORTED  The field really is an element of type 'reported' which allows for addition of sub-fields. See the explanantion in JEP-0004 (Data Forms) Section 3.4 for more information
FIELD_TYPE_INVALID  The field is invalid. Only possible if the field was created from a Tag not correctly describing a Data Form Field.
FIELD_TYPE_NONE  The field is child of either a <reported> or <item> element. Do not use.

Definition at line 38 of file dataformfield.h.


Constructor & Destructor Documentation

DataFormField ( DataFormFieldType  type = FIELD_TYPE_TEXT_SINGLE  ) 

Constructs a new Data Form Field.

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

Definition at line 20 of file dataformfield.cpp.

Referenced by DataFormItem::DataFormItem(), and DataFormReported::DataFormReported().

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 25 of file dataformfield.cpp.

~DataFormField (  )  [virtual]

Virtual destructor.

Definition at line 85 of file dataformfield.cpp.


Member Function Documentation

StringMap& options (  )  [inline]

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

Returns:
The options of a field.

Definition at line 98 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).

Definition at line 89 of file dataformfield.cpp.

Referenced by DataFormField::DataFormField().

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 112 of file dataformfield.h.

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

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 120 of file dataformfield.h.

void setOptions ( const StringMap options  )  [inline]

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 128 of file dataformfield.h.

bool required (  )  const [inline]

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

Returns:
Whether or not this field is required.

Definition at line 134 of file dataformfield.h.

void setRequired ( bool  required  )  [inline]

Use this field to set this field to be required.

Parameters:
required Whether or not this field is required.

Definition at line 140 of file dataformfield.h.

DataFormFieldType type (  )  const [inline]

Use this function to retrieve the type of this field.

Returns:
The type of this field.

Definition at line 146 of file dataformfield.h.

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

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

Returns:
The describing label of this field.

Definition at line 152 of file dataformfield.h.

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

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

Parameters:
label The describing label of this field.

Definition at line 158 of file dataformfield.h.

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

Use this function to retrieve the value of this field.

Returns:
The value of this field.

Definition at line 164 of file dataformfield.h.

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

Use this function to set the value of this field.

Parameters:
value The new value of this field.

Definition at line 170 of file dataformfield.h.

const StringList& values (  )  const [inline]

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 176 of file dataformfield.h.

void setValues ( const StringList values  )  [inline]

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 183 of file dataformfield.h.


The documentation for this class was generated from the following files:
Generated on Tue May 1 14:20:23 2007 for gloox by  doxygen 1.5.1