13 #include "dataformfield.h"
20 static const char* fieldTypeValues[] =
22 "boolean",
"fixed",
"hidden",
"jid-multi",
"jid-single",
23 "list-multi",
"list-single",
"text-multi",
"text-private",
"text-single",
""
27 : m_type( type ), m_required( false )
32 const std::string& label,
FieldType type )
33 : m_type( type ), m_name( name ), m_label( label ), m_required( false )
35 m_values.push_back( value );
47 if( !tag->
name().empty() )
51 m_type = (
FieldType)util::lookup( type, fieldTypeValues );
60 TagList::const_iterator it = l.begin();
61 for( ; it != l.end(); ++it )
63 if( (*it)->name() ==
"desc" )
64 m_desc = (*it)->cdata();
65 else if( (*it)->name() ==
"required" )
67 else if( (*it)->name() ==
"value" )
74 else if( (*it)->name() ==
"option" )
78 m_options.insert( std::make_pair( (*it)->findAttribute(
"label" ), v->
cdata() ) );
93 Tag* field =
new Tag(
"field" );
98 new Tag( field,
"required" );
100 if( !m_desc.empty() )
101 new Tag( field,
"desc", m_desc );
105 StringMultiMap::const_iterator it = m_options.begin();
106 for( ; it != m_options.end(); ++it )
108 Tag* option =
new Tag( field,
"option",
"label", (*it).first );
109 new Tag( option,
"value", (*it).second );
114 if( m_values.size() == 0 || m_values.front() ==
"false" || m_values.front() ==
"0" )
115 new Tag( field,
"value",
"0" );
117 new Tag( field,
"value",
"1" );
122 StringList::const_iterator it = m_values.begin();
123 for( ; it != m_values.end() ; ++it )
124 new Tag( field,
"value", (*it) );
129 new Tag( field,
"value", m_values.front() );