dataformfield.h

00001 /*
00002   Copyright (c) 2005-2006 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 
00014 #ifndef DATAFORMFIELD_H__
00015 #define DATAFORMFIELD_H__
00016 
00017 #include "gloox.h"
00018 
00019 #include <string>
00020 
00021 namespace gloox
00022 {
00023 
00024   class Tag;
00031   class GLOOX_API DataFormField
00032   {
00033     public:
00034 
00038       enum DataFormFieldType
00039       {
00040         FIELD_TYPE_BOOLEAN,         
00042         FIELD_TYPE_FIXED,           
00047         FIELD_TYPE_HIDDEN,          
00049         FIELD_TYPE_JID_MULTI,       
00051         FIELD_TYPE_JID_SINGLE,      
00053         FIELD_TYPE_LIST_MULTI,      
00055         FIELD_TYPE_LIST_SINGLE,     
00057         FIELD_TYPE_TEXT_MULTI,      
00059         FIELD_TYPE_TEXT_PRIVATE,    
00061         FIELD_TYPE_TEXT_SINGLE,     
00065         FIELD_TYPE_ITEM,            
00068         FIELD_TYPE_REPORTED,        
00071         FIELD_TYPE_INVALID,         
00073         FIELD_TYPE_NONE             
00075       };
00076 
00081       DataFormField( DataFormFieldType type = FIELD_TYPE_TEXT_SINGLE );
00082 
00087       DataFormField( Tag *tag );
00088 
00092       virtual ~DataFormField();
00093 
00098       StringMap& options() { return m_options; };
00099 
00106       virtual Tag* tag() const;
00107 
00112       virtual const std::string& name() const { return m_name; };
00113 
00120       void setName( const std::string& name ) { m_name = name; };
00121 
00128       void setOptions( const StringMap& options ) { m_options = options; };
00129 
00134       bool required() const { return m_required; };
00135 
00140       void setRequired( bool required ) { m_required = required; };
00141 
00146       DataFormFieldType type() const { return m_type; };
00147 
00152       const std::string& label() const { return m_label; };
00153 
00158       void setLabel( const std::string& label ) { m_label = label; };
00159 
00164       const std::string& value() const { return m_value; };
00165 
00170       void setValue( const std::string& value ) { m_value = value; };
00171 
00176       const StringList& values() const { return m_values; };
00177 
00183       void setValues( const StringList& values ) { m_values = values; };
00184 
00185     private:
00186       StringMap m_options;
00187       StringList m_values;
00188 
00189       std::string m_name;
00190       std::string m_desc;
00191       std::string m_label;
00192       std::string m_value;
00193       DataFormFieldType m_type;
00194       bool m_required;
00195   };
00196 
00197 }
00198 
00199 #endif // DATAFORMFIELD_H__

Generated on Tue May 1 14:20:20 2007 for gloox by  doxygen 1.5.1