Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

PMTextParse.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                      __   __    ____ _____ ____                      |
00004 |                      \ \ / /_ _/ ___|_   _|___ \                     |
00005 |                       \ V / _` \___ \ | |   __) |                    |
00006 |                        | | (_| |___) || |  / __/                     |
00007 |                        |_|\__,_|____/ |_| |_____|                    |
00008 |                                                                      |
00009 |                               core system                            |
00010 |                                                        (C) SuSE GmbH |
00011 \----------------------------------------------------------------------/
00012 
00013   File:       PMTextParse.h
00014 
00015   Author:     Michael Andres <ma@suse.de>
00016   Maintainer: Michael Andres <ma@suse.de>
00017 
00018   Purpose: Conversion of  y2pm specific datatypes to/from text representation.
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 // SINGLELINE
00037 //
00039 
00041 // LangCode
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 ); // explicit constructor
00051   return true;
00052 }
00053 
00055 // PM::CandidateOrder
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   // unknown value:
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   // unknown value:
00079   value_r = PM::CO_DEFAULT;
00080   return true;
00081 }
00082 
00083 
00085 } // namespace TextParse
00087 
00088 #endif // PMTextParse_h

Generated on Fri Nov 9 14:30:31 2007 for yast2-packagemanager by doxygen 1.3.6