cmtkCommandLineConvert.txx

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //  Copyright 2004-2009 SRI International
00005 //
00006 //  This file is part of the Computational Morphometry Toolkit.
00007 //
00008 //  http://www.nitrc.org/projects/cmtk/
00009 //
00010 //  The Computational Morphometry Toolkit is free software: you can
00011 //  redistribute it and/or modify it under the terms of the GNU General Public
00012 //  License as published by the Free Software Foundation, either version 3 of
00013 //  the License, or (at your option) any later version.
00014 //
00015 //  The Computational Morphometry Toolkit is distributed in the hope that it
00016 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00017 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018 //  GNU General Public License for more details.
00019 //
00020 //  You should have received a copy of the GNU General Public License along
00021 //  with the Computational Morphometry Toolkit.  If not, see
00022 //  <http://www.gnu.org/licenses/>.
00023 //
00024 //  $Revision: 1057 $
00025 //
00026 //  $LastChangedDate: 2009-12-15 16:56:38 -0800 (Tue, 15 Dec 2009) $
00027 //
00028 //  $LastChangedBy: torsten_at_home $
00029 //
00030 */
00031 
00032 namespace
00033 cmtk
00034 {
00035 
00038 
00040 template<> 
00041 inline bool CommandLine::Item::Convert<bool>( const char* str ) 
00042 { 
00043   if ( ! str ) 
00044     return false; 
00045   else
00046     return !strcmp( str, "yes" ); 
00047 }
00048 
00050 template<> 
00051 inline float CommandLine::Item::Convert<float>( const char* str ) 
00052 {
00053   return static_cast<float>( this->ConvertStrToDouble( str ) );
00054 }
00055 
00057 template<> 
00058 inline double CommandLine::Item::Convert<double>( const char* str ) 
00059 {
00060   return static_cast<double>( this->ConvertStrToDouble( str ) );
00061 }
00062 
00064 template<> 
00065 inline long int
00066 CommandLine::Item::Convert<long int>( const char* str ) 
00067 {
00068   return static_cast<long int>( this->ConvertStrToLong( str ) );
00069 }
00070 
00072 template<> 
00073 inline int CommandLine::Item::Convert<int>( const char* str ) 
00074 {
00075   return static_cast<int>( this->ConvertStrToLong( str ) );
00076 }
00077 
00079 template<> 
00080 inline unsigned int 
00081 CommandLine::Item::Convert<unsigned int>( const char* str ) 
00082 {
00083   return static_cast<unsigned int>( this->ConvertStrToLong( str ) );
00084 }
00085 
00087 template<> 
00088 inline unsigned long int
00089 CommandLine::Item::Convert<unsigned long int>( const char* str ) 
00090 {
00091   return static_cast<unsigned long int>( this->ConvertStrToLong( str ) );
00092 }
00093 
00095 template<> 
00096 inline char
00097 CommandLine::Item::Convert<char>( const char* str ) 
00098 {
00099   return static_cast<char>( this->ConvertStrToLong( str ) );
00100 }
00101 
00103 template<> 
00104 inline unsigned char
00105 CommandLine::Item::Convert<unsigned char>( const char* str ) 
00106 { 
00107   return static_cast<unsigned char>( this->ConvertStrToLong( str ) );
00108 }
00109 
00111 template<> 
00112 inline signed char
00113 CommandLine::Item::Convert<signed char>( const char* str ) 
00114 { 
00115   return static_cast<signed char>( this->ConvertStrToLong( str ) );
00116 }
00117 
00119 template<> 
00120 inline short 
00121 CommandLine::Item::Convert<short>( const char* str ) 
00122 {
00123   return static_cast<short>( this->ConvertStrToLong( str ) );
00124 }
00125 
00127 template<> 
00128 inline
00129 const char* 
00130 CommandLine::Item::Convert<const char*>( const char* str ) 
00131 {
00132   return str; 
00133 }
00134 
00136 template<> 
00137 inline
00138 std::vector<std::string> 
00139 CommandLine::Item::Convert< std::vector<std::string> >( const char* str ) 
00140 {
00141   std::vector<std::string> v;
00142   v.push_back( std::string( str ) );
00143   return v; 
00144 }
00145 
00146 } // namespace cmtk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines