Gaudi Framework, version v21r7

Home   Generated: 22 Jan 2010

Parsers.h

Go to the documentation of this file.
00001 // $Id: Parsers.h,v 1.5 2008/01/14 19:42:56 marcocle Exp $
00002 // ============================================================================
00003 #ifndef GAUDIPROPERTYPARSERS_PARSERS_H
00004 #define GAUDIPROPERTYPARSERS_PARSERS_H 1
00005 // ============================================================================
00006 // Include files
00007 // ============================================================================
00008 // STD & STL
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     // Advanced parses
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     // vector< vector< TYPE > >
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     // map< TYPE, TYPE >
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     // ========================================================================
00590     GAUDI_API StatusCode parse
00591     ( std::string&       name  ,
00592       std::string&       value ,
00593       const std::string& input ) ;
00594     // ========================================================================
00603     GAUDI_API StatusCode parse
00604     ( Gaudi::Histo1DDef& histo ,
00605       const std::string& input ) ;
00606     // ========================================================================
00615     GAUDI_API StatusCode parse
00616     ( std::map<std::string,Gaudi::Histo1DDef>& histos ,
00617       const std::string&                       input  ) ;
00618     // ========================================================================
00630     GAUDI_API StatusCode parse
00631     ( std::map<std::string,std::pair<double,double> >& params ,
00632       const std::string&                               input  ) ;
00633     // ========================================================================
00641     template <class T, unsigned int N>
00642     StatusCode parse ( T(&result)[N] , const std::string& input ) 
00643     {
00644       typedef std::vector<T> _Vct ;
00645       // create the temporary vector 
00646       _Vct tmp ;
00647       StatusCode sc = parse ( tmp , input ) ;
00648       if ( sc.isFailure()  ) { return sc                  ; }  //  RETURN 
00649       if ( N != tmp.size() ) { return StatusCode::FAILURE ; }  //  RETURN 
00650       //
00651       std::copy ( tmp.begin() , tmp.end() , result ) ;
00652       //
00653       return StatusCode::SUCCESS ;                            //  RETURN
00654     }
00655     // ========================================================================
00663     template <unsigned int N>
00664     StatusCode parse ( char(&result)[N] , const std::string& input ) 
00665     {
00666       // clear the string 
00667       std::fill_n ( result , N , ' ' ) ; 
00668       // create the temporary string
00669       std::string tmp ;
00670       StatusCode sc = parse ( tmp , input ) ;
00671       if ( sc.isFailure()  ) { return sc                 ; }  //  RETURN 
00672       if       ( N     == tmp.size() )
00673       { std::copy ( tmp.begin() , tmp.end() , result ) ; }
00674       else if  ( N + 2    == tmp.size()                 && 
00675                  ( '\''   == tmp[0] || '\"' == tmp[0] ) && 
00676                  ( tmp[0] == tmp[tmp.size()-1]          ))
00677       { std::copy ( tmp.begin() + 1 , tmp.end() -1 , result ) ; }        
00678       else { return StatusCode::FAILURE ; }
00679       //
00680       return StatusCode::SUCCESS ;                            //  RETURN
00681     }
00682     // ========================================================================
00683   } //                                          end of namespace Gaudi::Parsers
00684   // ==========================================================================
00685 } //                                                     end of namespace Gaudi
00686 // ============================================================================
00687 // The END
00688 // ============================================================================
00689 #endif //GAUDIPROPERTYPARSERS_PARSERS_H
00690 // ============================================================================

Generated at Fri Jan 22 20:27:45 2010 for Gaudi Framework, version v21r7 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004