GrammarsForVectors.h
Go to the documentation of this file.00001
00002
00003 #ifndef GAUDIKERNEL_VCTGRAMMARS_H
00004 #define GAUDIKERNEL_VCTGRAMMARS_H 1
00005
00006
00007
00008 #include "GaudiKernel/Grammars.h"
00009
00010 #include "GaudiKernel/StatusCode.h"
00011 #include "GaudiKernel/Point3DTypes.h"
00012 #include "GaudiKernel/Point4DTypes.h"
00013 #include "GaudiKernel/Vector3DTypes.h"
00014 #include "GaudiKernel/Vector4DTypes.h"
00015
00016 namespace Gaudi
00017 {
00018
00019 namespace Parsers
00020 {
00021
00022 using namespace boost::spirit ;
00023
00024 using namespace phoenix ;
00025
00032 template <class ScalarGrammarT, class POINT>
00033 class Pnt3DGrammar : public grammar
00034 <
00035 Pnt3DGrammar<ScalarGrammarT,POINT>,
00036 typename ClosureGrammar<POINT>::context_t
00037 >
00038 {
00039 public:
00040
00042 typedef POINT ResultT ;
00043 typedef ClosureGrammar<POINT> ClosureT ;
00044
00045 public:
00046
00048 void matchX ( double value) const { this->val().SetX ( value ) ; }
00049 void matchY ( double value) const { this->val().SetY ( value ) ; }
00050 void matchZ ( double value) const { this->val().SetZ ( value ) ; }
00051
00052 public:
00053
00054 template <typename ScannerT>
00055 struct definition
00056 {
00057 definition ( Pnt3DGrammar const & self )
00058 {
00059
00060 inner =
00061 !( ( str_p("x") | "X" | "pX" | "Px" | "PX" ) >> ':' ) >>
00062 scalar [ boost::bind(&Pnt3DGrammar::matchX,&self,_1) ] >>
00063 ',' >>
00064 !( ( str_p("y") | "Y" | "pY" | "Py" | "PY" ) >> ':' ) >>
00065 scalar [ boost::bind(&Pnt3DGrammar::matchY,&self,_1) ] >>
00066 ',' >>
00067 !( ( str_p("z") | "Z" | "pZ" | "Pz" | "PZ" ) >> ':' ) >>
00068 scalar [ boost::bind(&Pnt3DGrammar::matchZ,&self,_1) ] ;
00069
00070 pnt =
00071 ( str_p ("(") >> inner >> ')' ) |
00072 ( str_p ("[") >> inner >> ']' ) ;
00073
00074 }
00076 rule<ScannerT> const & start() const { return pnt ; }
00077
00078 rule<ScannerT> pnt , inner ;
00079 ScalarGrammarT scalar ;
00080
00081 };
00082
00083 } ;
00084
00091 template <class ScalarGrammarT, class POINT>
00092 class Pnt4DGrammar : public grammar
00093 <
00094 Pnt4DGrammar<ScalarGrammarT,POINT>,
00095 typename ClosureGrammar<POINT>::context_t
00096 >
00097 {
00098 public:
00099
00101 typedef POINT ResultT ;
00102 typedef ClosureGrammar<POINT> ClosureT ;
00103
00104 public:
00105
00107 void matchX ( double value) const { this->val().SetPx ( value ) ; }
00108 void matchY ( double value) const { this->val().SetPy ( value ) ; }
00109 void matchZ ( double value) const { this->val().SetPz ( value ) ; }
00110 void matchT ( double value) const { this->val().SetE ( value ) ; }
00111
00112 public:
00113
00114 template <typename ScannerT>
00115 struct definition
00116 {
00117 definition ( Pnt4DGrammar const & self )
00118 {
00119
00120 x = !( ( str_p("x") | "X" | "pX" | "Px" | "PX" ) && ':' )
00121 >> scalar [ boost::bind(&Pnt4DGrammar::matchX,&self,_1) ] ;
00122 y = !( ( str_p("y") | "Y" | "pY" | "Py" | "PY" ) && ':' )
00123 >> scalar [ boost::bind(&Pnt4DGrammar::matchY,&self,_1) ] ;
00124 z = !( ( str_p("z") | "Z" | "pZ" | "Pz" | "PZ" ) && ':' )
00125 >> scalar [ boost::bind(&Pnt4DGrammar::matchZ,&self,_1) ] ;
00126 e = !( ( str_p("t") | "T" | "e" | "E" ) && ':' )
00127 >> scalar [ boost::bind(&Pnt4DGrammar::matchT,&self,_1) ] ;
00128
00129 p3 = x >> ',' >> y >> ',' >> z ;
00130
00131 inner =
00132 ( p3 >> ( str_p(',') | ';' ) >> e ) |
00133 ( str_p("(") >> p3 >> ')' >> ( str_p(',') | ';' ) >> e ) |
00134 ( str_p("[") >> p3 >> ']' >> ( str_p(',') | ';' ) >> e ) |
00135 ( e >> ( str_p(",") | ';') >> '(' >> p3 >> ')' ) |
00136 ( e >> ( str_p(",") | ';') >> '[' >> p3 >> ']' ) ;
00137
00138 pnt =
00139 ( str_p ("(") >> inner >> ')' ) |
00140 ( str_p ("[") >> inner >> ']' ) ;
00141
00142 }
00144 rule<ScannerT> const & start() const { return pnt ; }
00145
00146 rule<ScannerT> x,y,z,e,p3,inner, pnt ;
00147 ScalarGrammarT scalar ;
00148
00149 };
00150
00151 } ;
00152
00153 }
00154
00155 }
00156
00157
00158
00159 #endif // GAUDIKERNEL_VCTGRAMMARS_H
00160