![]() |
|
|
Generated: 18 Jul 2008 |
00001 // $Id: Parsers.icpp,v 1.3 2007/09/26 16:13:42 marcocle Exp $ 00002 // ============================================================================ 00003 #ifndef GAUDIKERNEL_PARSERS_ICPP 00004 #define GAUDIKERNEL_PARSERS_ICPP 1 00005 // ============================================================================ 00006 // Include files 00007 // ============================================================================ 00008 // STD&STL 00009 // ============================================================================ 00010 #include <vector> 00011 #include <map> 00012 #include <string> 00013 // ============================================================================ 00014 // Boost.Bind 00015 // ============================================================================ 00016 #include "boost/bind.hpp" 00017 // ============================================================================ 00018 // Boost.Spirit 00019 // ============================================================================ 00020 #include "boost/spirit.hpp" 00021 // ============================================================================ 00022 // Boost.Spirit.Phoenix 00023 // ============================================================================ 00024 #include "boost/spirit/phoenix.hpp" 00025 // ============================================================================ 00026 // GaudiKernel 00027 // ============================================================================ 00028 #include "GaudiKernel/Parsers.h" 00029 #include "GaudiKernel/Grammars.h" 00030 // ============================================================================ 00048 // ============================================================================ 00049 namespace Gaudi 00050 { 00051 namespace Parsers 00052 { 00053 using namespace std; 00054 using namespace boost::spirit ; 00055 00057 typedef boost::spirit::position_iterator<string::const_iterator> IteratorT; 00058 00060 inline IteratorT createIterator( const std::string& input) 00061 { return IteratorT ( input.begin(), input.end() ) ; } 00062 00063 // ======================================================================== 00076 // ======================================================================== 00077 template<typename IntegerT> 00078 inline StatusCode parse_integer 00079 (IntegerT& result,const string& input) 00080 { 00081 return parse 00082 ( createIterator(input), 00083 IteratorT(), 00084 IntGrammar<IntegerT>()[var(result)=arg1]).full; 00085 } 00086 // ======================================================================== 00102 // ======================================================================== 00103 template<typename IntegerT> 00104 inline StatusCode parse_integer_vector 00105 ( std::vector<IntegerT>& result,const string& input) 00106 { 00107 return parse 00108 ( createIterator(input), 00109 IteratorT(), 00110 VectorGrammar<IntGrammar<IntegerT> >()[var(result)=arg1], 00111 SkipperGrammar()).full; 00112 } 00113 // ======================================================================== 00126 // ======================================================================== 00127 template<typename CharT> 00128 inline StatusCode parse_char 00129 ( CharT& result , const string& input ) 00130 { 00131 return parse 00132 ( createIterator(input), 00133 IteratorT(), 00134 CharGrammar<CharT>()[var(result)=arg1]).full; 00135 } 00136 // ======================================================================== 00152 // ======================================================================== 00153 template<typename CharT> 00154 inline StatusCode parse_char_vector 00155 (std::vector<CharT>& result,const string& input) 00156 { 00157 return parse 00158 ( createIterator(input), 00159 IteratorT(), 00160 VectorGrammar<CharGrammar<CharT> >()[var(result)=arg1], 00161 SkipperGrammar()).full; 00162 } 00163 // ======================================================================== 00176 template<typename RealT> 00177 inline StatusCode parse_real 00178 ( RealT& result , const string& input) 00179 { 00180 return parse 00181 ( createIterator(input), 00182 IteratorT(), 00183 RealGrammar<RealT>()[var(result)=arg1], 00184 SkipperGrammar()).full; 00185 } 00186 // ======================================================================== 00202 // ======================================================================== 00203 template<typename RealT> 00204 StatusCode parse_real_vector 00205 ( std::vector<RealT>& result,const string& input) 00206 { 00207 return parse 00208 ( createIterator(input), 00209 IteratorT(), 00210 VectorGrammar< RealGrammar<RealT> >()[var(result)=arg1], 00211 SkipperGrammar()).full; 00212 } 00213 } // end of namespace Gaudi::Parsers 00214 } // end of namespace Gaudi 00215 // ============================================================================ 00216 #endif 00217 // ============================================================================ 00218 // The END 00219 // ============================================================================ 00220 00221