00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef PMTextParse_h
00022 #define PMTextParse_h
00023
00024 #include <iosfwd>
00025
00026 #include <y2pm/PMTypes.h>
00027
00028 #include "TextParse.h"
00029
00031 namespace TextParse {
00032 ;
00033
00035
00036
00037
00039
00041
00043 template<>
00044 bool TextConvert<LangCode>::toText( const value_type & value_r, text_type & asText_r ) {
00045 asText_r = value_r;
00046 return true;
00047 }
00048 template<>
00049 bool TextConvert<LangCode>::fromText( value_type & value_r, const text_type & asText_r ) {
00050 value_r = value_type( asText_r );
00051 return true;
00052 }
00053
00055
00057 template<>
00058 bool TextConvert<PM::CandidateOrder>::toText( const value_type & value_r, text_type & asText_r ) {
00059 switch ( value_r ) {
00060 #define ENUM_OUT(T) case PM::CO_##T: asText_r = #T; return true
00061 ENUM_OUT( DEFAULT );
00062 ENUM_OUT( AVS );
00063 ENUM_OUT( ASV );
00064 #undef ENUM_OUT
00065 }
00066
00067 asText_r = "DEFAULT";
00068 return true;
00069 }
00070 template<>
00071 bool TextConvert<PM::CandidateOrder>::fromText( value_type & value_r, const text_type & asText_r ) {
00072 text_type match( stringutil::toUpper( asText_r ) );
00073 #define ENUM_OUT(T) if ( match == #T ) { value_r = PM::CO_##T; return true; }
00074 ENUM_OUT( DEFAULT );
00075 ENUM_OUT( AVS );
00076 ENUM_OUT( ASV );
00077 #undef ENUM_OUT
00078
00079 value_r = PM::CO_DEFAULT;
00080 return true;
00081 }
00082
00083
00085 }
00087
00088 #endif // PMTextParse_h