Gaudi Framework, version v22r1

Home   Generated: Mon Feb 28 2011

ParseMaps.cpp

Go to the documentation of this file.
00001 // $Id: ParseMaps.cpp,v 1.6 2008/10/28 14:02:18 marcocle Exp $
00002 // ============================================================================
00003 // Include files
00004 // ============================================================================
00005 // Local
00006 // ============================================================================
00007 #include "GaudiKernel/Parsers.icpp"
00008 // ============================================================================
00025 // ============================================================================
00026 namespace Gaudi
00027 {
00028   namespace Parsers
00029   {
00030     // ========================================================================
00031     // map< TYPE, TYPE >
00032     // ========================================================================
00033     StatusCode parse
00034     ( map< int , int >& result ,
00035       const string&     input  )
00036     {
00037       MapGrammar< IntGrammar<int> , IntGrammar<int> > g;
00038       return parse
00039         ( createIterator(input)  ,
00040           IteratorT()            ,
00041           g[var(result)=arg1],
00042           SkipperGrammar()).full;
00043     }
00044     // ========================================================================
00045     StatusCode parse
00046     ( map< int , double >& result ,
00047       const string&        input  )
00048     {
00049       MapGrammar< IntGrammar<int> , RealGrammar<double> > g;
00050       return parse
00051         ( createIterator(input),
00052           IteratorT(),
00053           g[var(result)=arg1],
00054           SkipperGrammar()).full;
00055     }
00056     // ========================================================================
00057     StatusCode parse
00058     ( map<string,double>&  result ,
00059       const string&        input  )
00060     {
00061       MapGrammar<StringGrammar,RealGrammar<double> > g;
00062       return parse
00063         ( createIterator(input),
00064           IteratorT(),
00065           g[var(result)=arg1],
00066           SkipperGrammar()).full;
00067     }
00068     // ========================================================================
00069     StatusCode parse
00070     ( map< string , string >& result ,
00071       const string&           input  )
00072     {
00073       MapGrammar<StringGrammar,StringGrammar> g;
00074       return parse
00075         ( createIterator(input),
00076           IteratorT(),
00077           g[var(result)=arg1],
00078           SkipperGrammar()).full;
00079     }
00080     // ========================================================================
00081     StatusCode parse
00082     ( map< string , int >& result ,
00083       const string&        input  )
00084     {
00085       MapGrammar<StringGrammar,IntGrammar<int> > g;
00086       return parse
00087         ( createIterator(input),
00088           IteratorT(),
00089           g[var(result)=arg1],
00090           SkipperGrammar()).full;
00091     }
00092     // ========================================================================
00093     StatusCode parse
00094     ( map< std::string , std::vector< std::string > >& result ,
00095       const string&                                    input  )
00096     {
00097       MapGrammar<StringGrammar,VectorGrammar<StringGrammar> > g;
00098       return parse
00099         ( createIterator(input),
00100           IteratorT(),
00101           g[var(result)=arg1],
00102           SkipperGrammar()).full;
00103     }
00104     // ========================================================================
00105     StatusCode parse
00106     ( map< std::string , std::vector< int > >& result ,
00107       const string&                            input  )
00108     {
00109       MapGrammar<StringGrammar,VectorGrammar<IntGrammar<int> > > g;
00110       return parse
00111         ( createIterator(input),
00112           IteratorT(),
00113           g[var(result)=arg1],
00114           SkipperGrammar()).full;
00115     }
00116     // ========================================================================
00117     StatusCode parse
00118     ( map< std::string , std::vector< double > >& result ,
00119       const string&                               input  )
00120     {
00121       MapGrammar<StringGrammar,VectorGrammar<RealGrammar<double> > > g;
00122       return parse
00123         ( createIterator(input),
00124           IteratorT(),
00125           g[var(result)=arg1],
00126           SkipperGrammar()).full;
00127     }
00128     // ========================================================================
00129     /*  parse the pair expression (map-component)  " 'name' :value"
00130      *
00131      *  @code
00132      *
00133      *  const std::string input = "'PackageName':GaudiKernel" ;
00134      *  std::string name  ;
00135      *  std::string value ;
00136      *  StatusCode sc = Gaudi::Parsers::parse ( name , value , input ) ;
00137      *  if ( sc.isFailure() ) { ... }
00138      *  std::cout <<  "\tParsed name  is " << name
00139      *            <<  "\tParsed value is " << value << std::endl
00140      *  @endcode
00141      *
00142      *  @param  name  (output) the parsed name of the component, defined
00143      *                as 'name' or "name" before the column symbol ":",
00144      *                the leading and trailing blans are omitted
00145      *  @param  value (output) the parsed value of the component,
00146      *                defined as everything after the column symbol ":"
00147      *                till the end of the string
00148      *  @param  input (input) string to be parsed
00149      *  @return status code
00150      *
00151      *  @author Alexander MAZUROV Alexander.Mazurov@gmail.com
00152      *  @author Vanya BELYAEV  ibelyaev@physics.syr.edu
00153      *  @date 2006-05-12
00154      */
00155     // ========================================================================
00156     StatusCode parse ( string& name , string&  value , const string& input )
00157     {
00158       return parse
00159         ( input.c_str(),
00160           (
00161            ch_p('"' ) >> (+(anychar_p-ch_p('"' )))[assign_a(name)] >> ch_p('"' )
00162            |
00163            ch_p('\'') >> (+(anychar_p-ch_p('\'')))[assign_a(name)] >> ch_p('\'')
00164            )
00165           >> ":"
00166           >> (+anychar_p)[assign_a(value)], space_p).full;
00167     }
00168     // ========================================================================
00169     StatusCode parse
00170     ( map<int,std::string>& result ,
00171       const string&         input  )
00172     {
00173       MapGrammar<IntGrammar<int>,StringGrammar> g;
00174       return parse
00175         ( createIterator(input),
00176           IteratorT(),
00177           g[var(result)=arg1],
00178           SkipperGrammar()).full;
00179     }
00180     // ========================================================================
00181     StatusCode parse
00182     ( map<unsigned int,std::string>& result ,
00183       const string&         input  )
00184     {
00185       MapGrammar<IntGrammar<unsigned int>,StringGrammar> g;
00186       return parse
00187         ( createIterator(input),
00188           IteratorT(),
00189           g[var(result)=arg1],
00190           SkipperGrammar()).full;
00191     }
00192     // ========================================================================
00193     StatusCode parse
00194     ( map<std::string,unsigned int>& result ,
00195       const string&         input  )
00196     {
00197       MapGrammar<StringGrammar,IntGrammar<unsigned int> > g;
00198       return parse
00199         ( createIterator(input),
00200           IteratorT(),
00201           g[var(result)=arg1],
00202           SkipperGrammar()).full;
00203     }
00204     // ========================================================================
00205     /*  helper function, needed for implementation of map of pairs
00206      *  It is very useful construction for monitoring to
00207      *  represent the value and error or the allowed range for
00208      *  some parameter
00209      *  @param the map of pair
00210      *  @param input the string to be parsed
00211      *  @return status code
00212      *  @author Vanya BELYAEV Ivan.Belyaev@nikhef.nl
00213      *  @author Alexander MAZUROV Alexander.Mazurov@gmail.com
00214      *  @date 2009-05-19
00215      */
00216     StatusCode parse
00217     ( std::map<std::string,std::pair<double,double> >& params ,
00218       const std::string&                               input  )
00219     {
00220       typedef PairGrammar< RealGrammar<double> , RealGrammar <double> > PG ;
00221       MapGrammar < StringGrammar , PG > g ;
00222       return parse
00223         ( createIterator(input),
00224           IteratorT(),
00225           g[var(params)=arg1],
00226           SkipperGrammar()).full;
00227     }
00228     // ========================================================================
00229   } // end of namespace Parsers
00230   // ==========================================================================
00231 } // end of namespace Gaudi
00232 // ============================================================================
00233 // The END
00234 // ============================================================================
00235 
00236 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Feb 28 2011 18:27:14 for Gaudi Framework, version v22r1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004