00001
00002
00003 #ifndef GAUDIPROPERTYPARSERS_PARSERS_H
00004 #define GAUDIPROPERTYPARSERS_PARSERS_H 1
00005
00006
00007
00008
00009
00010 #include <string>
00011 #include <vector>
00012 #include <map>
00013
00014 #include "GaudiKernel/StatusCode.h"
00015 #include "GaudiKernel/HistoDef.h"
00016
00048
00049 namespace Gaudi
00050 {
00051
00052 class Histo1DDef ;
00053
00054 namespace Parsers
00055 {
00056
00067 GAUDI_API StatusCode parse
00068 ( bool& result , const std::string& input ) ;
00069
00081 GAUDI_API StatusCode parse
00082 ( char& result ,
00083 const std::string& input ) ;
00085 GAUDI_API StatusCode parse
00086 ( unsigned char& result ,
00087 const std::string& input ) ;
00089 GAUDI_API StatusCode parse
00090 ( signed char& result ,
00091 const std::string& input ) ;
00092
00104 GAUDI_API StatusCode parse
00105 ( int& result ,
00106 const std::string& input ) ;
00108 GAUDI_API StatusCode parse
00109 ( short& result ,
00110 const std::string& input ) ;
00112 GAUDI_API StatusCode parse
00113 ( unsigned short& result ,
00114 const std::string& input ) ;
00116 GAUDI_API StatusCode parse
00117 ( unsigned int& result ,
00118 const std::string& input ) ;
00120 GAUDI_API StatusCode parse
00121 ( long& result ,
00122 const std::string& input ) ;
00124 GAUDI_API StatusCode parse
00125 ( unsigned long& result ,
00126 const std::string& input ) ;
00128 GAUDI_API StatusCode parse
00129 ( long long& result ,
00130 const std::string& input ) ;
00132 GAUDI_API StatusCode parse
00133 ( unsigned long long& result,
00134 const std::string& input ) ;
00135
00147 GAUDI_API StatusCode parse
00148 ( double& result ,
00149 const std::string& input ) ;
00151 GAUDI_API StatusCode parse
00152 ( float& result ,
00153 const std::string& input ) ;
00155 GAUDI_API StatusCode parse
00156 ( long double& result ,
00157 const std::string& input ) ;
00158
00170 GAUDI_API StatusCode parse
00171 ( std::string& result ,
00172 const std::string& input ) ;
00173
00186 GAUDI_API StatusCode parse
00187 ( std::vector<bool>& result ,
00188 const std::string& input ) ;
00189
00202 GAUDI_API StatusCode parse
00203 ( std::vector<char>& result ,
00204 const std::string& input ) ;
00206 GAUDI_API StatusCode parse
00207 ( std::vector<unsigned char>& result ,
00208 const std::string& input ) ;
00210 GAUDI_API StatusCode parse
00211 ( std::vector<signed char>& result ,
00212 const std::string& input ) ;
00213
00226 GAUDI_API StatusCode parse
00227 ( std::vector<int>& result ,
00228 const std::string& input ) ;
00230 GAUDI_API StatusCode parse
00231 ( std::vector<short>& result ,
00232 const std::string& input ) ;
00234 GAUDI_API StatusCode parse
00235 ( std::vector<unsigned short>& result ,
00236 const std::string& input ) ;
00238 GAUDI_API StatusCode parse
00239 ( std::vector<unsigned int>& result ,
00240 const std::string& input ) ;
00242 GAUDI_API StatusCode parse
00243 ( std::vector<long>& result ,
00244 const std::string& input ) ;
00246 GAUDI_API StatusCode parse
00247 ( std::vector<unsigned long>& result ,
00248 const std::string& input ) ;
00250 GAUDI_API StatusCode parse
00251 ( std::vector<long long>& result ,
00252 const std::string& input ) ;
00254 GAUDI_API StatusCode parse
00255 ( std::vector<unsigned long long>& result,
00256 const std::string& input ) ;
00257
00270 GAUDI_API StatusCode parse
00271 ( std::vector<double>& result ,
00272 const std::string& input ) ;
00274 GAUDI_API StatusCode parse
00275 ( std::vector<float>& result ,
00276 const std::string& input ) ;
00278 GAUDI_API StatusCode parse
00279 ( std::vector<long double>& result ,
00280 const std::string& input ) ;
00281
00294 GAUDI_API StatusCode parse
00295 ( std::vector<std::string>& result ,
00296 const std::string& input ) ;
00297
00298
00299
00312 GAUDI_API StatusCode parse
00313 ( std::pair<double,double>& result ,
00314 const std::string& input ) ;
00315
00328 GAUDI_API StatusCode parse
00329 ( std::pair<int,int>& result ,
00330 const std::string& input ) ;
00331
00345 GAUDI_API StatusCode parse
00346 ( std::vector< std::pair<double,double> >& result ,
00347 const std::string& input ) ;
00348
00362 GAUDI_API StatusCode parse
00363 ( std::vector< std::pair<int,int> >& result ,
00364 const std::string& input ) ;
00365
00366
00367
00380 GAUDI_API StatusCode parse
00381 ( std::vector< std::vector<std::string> >& result ,
00382 const std::string& input ) ;
00383
00396 GAUDI_API StatusCode parse
00397 ( std::vector< std::vector<double> >& result ,
00398 const std::string& input ) ;
00399
00400
00401
00414 GAUDI_API StatusCode parse
00415 ( std::map< int , int >& result ,
00416 const std::string& input ) ;
00417
00431 GAUDI_API StatusCode parse
00432 ( std::map< int , double >& result ,
00433 const std::string& input ) ;
00434
00447 GAUDI_API StatusCode parse
00448 ( std::map< std::string , std::string >& result ,
00449 const std::string& input ) ;
00450
00464 GAUDI_API StatusCode parse
00465 ( std::map< std::string , int >& result ,
00466 const std::string& input ) ;
00467
00481 GAUDI_API StatusCode parse
00482 ( std::map< std::string , double >& result ,
00483 const std::string& input ) ;
00484
00500 GAUDI_API StatusCode parse
00501 ( std::map< std::string , std::vector< std::string> >& result ,
00502 const std::string& input ) ;
00503
00519 GAUDI_API StatusCode parse
00520 ( std::map< std::string , std::vector< int > >& result ,
00521 const std::string& input ) ;
00522
00538 GAUDI_API StatusCode parse
00539 ( std::map< std::string , std::vector< double > >& result ,
00540 const std::string& input ) ;
00541
00549 GAUDI_API StatusCode parse
00550 ( std::map<int, std::string>& result ,
00551 const std::string& input ) ;
00552
00560 GAUDI_API StatusCode parse
00561 ( std::map<unsigned int, std::string>& result ,
00562 const std::string& input ) ;
00563
00568 GAUDI_API StatusCode parse
00569 ( std::map<std::string, unsigned int>& result ,
00570 const std::string& input ) ;
00571
00598 GAUDI_API StatusCode parse
00599 ( std::string& name ,
00600 std::string& value ,
00601 const std::string& input ) ;
00602
00611 GAUDI_API StatusCode parse
00612 ( Gaudi::Histo1DDef& histo ,
00613 const std::string& input ) ;
00614
00623 GAUDI_API StatusCode parse
00624 ( std::map<std::string,Gaudi::Histo1DDef>& histos ,
00625 const std::string& input ) ;
00626
00638 GAUDI_API StatusCode parse
00639 ( std::map<std::string,std::pair<double,double> >& params ,
00640 const std::string& input ) ;
00641
00649 template <class T, unsigned int N>
00650 StatusCode parse ( T(&result)[N] , const std::string& input )
00651 {
00652 typedef std::vector<T> _Vct ;
00653
00654 _Vct tmp ;
00655 StatusCode sc = parse ( tmp , input ) ;
00656 if ( sc.isFailure() ) { return sc ; }
00657 if ( N != tmp.size() ) { return StatusCode::FAILURE ; }
00658
00659 std::copy ( tmp.begin() , tmp.end() , result ) ;
00660
00661 return StatusCode::SUCCESS ;
00662 }
00663
00671 template <unsigned int N>
00672 StatusCode parse ( char(&result)[N] , const std::string& input )
00673 {
00674
00675 std::fill_n ( result , N , ' ' ) ;
00676
00677 std::string tmp ;
00678 StatusCode sc = parse ( tmp , input ) ;
00679 if ( sc.isFailure() ) { return sc ; }
00680 if ( N == tmp.size() )
00681 { std::copy ( tmp.begin() , tmp.end() , result ) ; }
00682 else if ( N + 2 == tmp.size() &&
00683 ( '\'' == tmp[0] || '\"' == tmp[0] ) &&
00684 ( tmp[0] == tmp[tmp.size()-1] ))
00685 { std::copy ( tmp.begin() + 1 , tmp.end() -1 , result ) ; }
00686 else { return StatusCode::FAILURE ; }
00687
00688 return StatusCode::SUCCESS ;
00689 }
00690
00691 }
00692
00693 }
00694
00695
00696
00697 #endif //GAUDIPROPERTYPARSERS_PARSERS_H
00698