Gaudi Framework, version v20r2

Generated: 18 Jul 2008

ParseMaps.cpp

Go to the documentation of this file.
00001 // $Id: ParseMaps.cpp,v 1.4 2008/01/14 19:42:56 marcocle Exp $
00002 // ============================================================================
00003 // Include files
00004 // ============================================================================
00005 // Local
00006 // ============================================================================
00007 #include "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       return parse
00038         ( createIterator(input)  , 
00039           IteratorT()            ,
00040           MapGrammar< IntGrammar<int> , IntGrammar<int> >()
00041           [var(result)=arg1],
00042           SkipperGrammar()).full;
00043     }
00044     // ========================================================================
00045     StatusCode parse
00046     ( map< int , double >& result , 
00047       const string&        input  )
00048     {
00049       return parse
00050         ( createIterator(input), 
00051           IteratorT(),
00052           MapGrammar< IntGrammar<int> , RealGrammar<double> >()
00053           [var(result)=arg1],
00054           SkipperGrammar()).full;
00055     }
00056     // ========================================================================
00057     StatusCode parse
00058     ( map<string,double>&  result , 
00059       const string&        input  )
00060     {
00061       return parse
00062         ( createIterator(input), 
00063           IteratorT(),
00064           MapGrammar<StringGrammar,RealGrammar<double> >()[var(result)=arg1],
00065           SkipperGrammar()).full;
00066     }
00067     // ========================================================================
00068     StatusCode parse
00069     ( map< string , string >& result , 
00070       const string&           input  ) 
00071     {
00072       return parse
00073         ( createIterator(input), 
00074           IteratorT(),
00075           MapGrammar<StringGrammar,StringGrammar>()[var(result)=arg1],
00076           SkipperGrammar()).full;
00077     }
00078     // ========================================================================
00079     StatusCode parse
00080     ( map< string , int >& result , 
00081       const string&        input  )
00082     {
00083       return parse
00084         ( createIterator(input), 
00085           IteratorT(),
00086           MapGrammar<StringGrammar,IntGrammar<int> >()[var(result)=arg1],
00087           SkipperGrammar()).full;
00088     }
00089     // ========================================================================
00090     StatusCode parse
00091     ( map< std::string , std::vector< std::string > >& result , 
00092       const string&                                    input  )
00093     {
00094       return parse
00095         ( createIterator(input), 
00096           IteratorT(),
00097           MapGrammar<StringGrammar,VectorGrammar<StringGrammar> >()
00098           [var(result)=arg1],
00099           SkipperGrammar()).full;
00100     }
00101     // ========================================================================
00102     StatusCode parse
00103     ( map< std::string , std::vector< int > >& result , 
00104       const string&                            input  )
00105     {
00106       return parse
00107         ( createIterator(input), 
00108           IteratorT(),
00109           MapGrammar<StringGrammar,VectorGrammar<IntGrammar<int> > >()
00110           [var(result)=arg1],
00111           SkipperGrammar()).full;
00112     }
00113     // ========================================================================
00114     StatusCode parse
00115     ( map< std::string , std::vector< double > >& result , 
00116       const string&                               input  )
00117     {
00118       return parse
00119         ( createIterator(input), 
00120           IteratorT(),
00121           MapGrammar<StringGrammar,VectorGrammar<RealGrammar<double> > >()
00122           [var(result)=arg1],
00123           SkipperGrammar()).full;
00124     }
00125     // ========================================================================
00126     /*  parse the pair expression (map-component)  " 'name' :value" 
00127      *  
00128      *  @code 
00129      *  
00130      *  const std::string input = "'PackageName':GaudiKernel" ;
00131      *  std::string name  ;
00132      *  std::string value ;
00133      *  StatusCode sc = Gaudi::Parsers::parse ( name , value , input ) ;
00134      *  if ( sc.isFailure() ) { ... } 
00135      *  std::cout <<  "\tParsed name  is " << name 
00136      *            <<  "\tParsed value is " << value << std::endl 
00137      *  @endcode 
00138      *  
00139      *  @param  name  (output) the parsed name of the component, defined 
00140      *                as 'name' or "name" before the column symbol ":", 
00141      *                the leading and trailing blans are omitted 
00142      *  @param  value (output) the parsed value of the component, 
00143      *                defined as everything after the column symbol ":" 
00144      *                till the end of the string
00145      *  @param  input (input) string to be parsed 
00146      *  @return status code 
00147      *  
00148      *  @author Alexander MAZUROV Alexander.Mazurov@gmail.com 
00149      *  @author Vanya BELYAEV  ibelyaev@physics.syr.edu
00150      *  @date 2006-05-12 
00151      */
00152     // ========================================================================
00153     StatusCode parse ( string& name , string&  value , const string& input )
00154     {
00155       return parse 
00156         ( input.c_str(),
00157           (
00158            ch_p('"' ) >> (+(anychar_p-ch_p('"' )))[assign_a(name)] >> ch_p('"' )
00159            |
00160            ch_p('\'') >> (+(anychar_p-ch_p('\'')))[assign_a(name)] >> ch_p('\'')
00161            )
00162           >> ":"
00163           >> (+anychar_p)[assign_a(value)], space_p).full;
00164     }
00165     // ========================================================================    
00166     StatusCode parse
00167     ( map<int,std::string>& result , 
00168       const string&         input  )
00169     {
00170       return parse
00171         ( createIterator(input), 
00172           IteratorT(),
00173           MapGrammar<IntGrammar<int>,StringGrammar>()[var(result)=arg1],
00174           SkipperGrammar()).full;
00175     }
00176     // ========================================================================
00177     StatusCode parse
00178     ( map<unsigned int,std::string>& result , 
00179       const string&         input  )
00180     {
00181       return parse
00182         ( createIterator(input), 
00183           IteratorT(),
00184           MapGrammar<IntGrammar<unsigned int>,
00185           StringGrammar>()[var(result)=arg1],
00186           SkipperGrammar()).full;
00187     }
00188     // ========================================================================
00189   } // end of namespace Parsers
00190 } // end of namespace Gaudi
00191 // ============================================================================
00192 // The END 
00193 // ============================================================================
00194 
00195 

Generated at Fri Jul 18 11:59:22 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004