The Gaudi Framework  v33r1 (b1225454)
Grammars.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 #ifdef __GNUC__
14 # pragma GCC system_header
15 #endif
16 // ============================================================================
17 // Include files
18 // ============================================================================
19 // STD:
20 //==============================================================================
21 #include <list>
22 #include <map>
23 #include <set>
24 #include <string>
25 #include <tuple>
26 #include <type_traits>
27 #include <unordered_map>
28 #include <unordered_set>
29 #include <vector>
30 //==============================================================================
31 // Boost:
32 //==============================================================================
33 #include <boost/fusion/include/std_pair.hpp>
34 #include <boost/fusion/include/unused.hpp>
35 #include <boost/spirit/include/qi.hpp>
36 
37 #include <boost/spirit/include/phoenix_core.hpp>
38 #include <boost/spirit/include/phoenix_operator.hpp>
39 
40 #include <boost/spirit/repository/include/qi_confix.hpp>
41 //==============================================================================
42 // Gaudi:
43 //==============================================================================
44 #include "GaudiKernel/HashMap.h"
45 #include "GaudiKernel/HistoDef.h"
48 #include "GaudiKernel/StringKey.h"
49 #include "GaudiKernel/VectorMap.h"
50 //==============================================================================
51 namespace Gaudi {
52  namespace Parsers {
53  //==============================================================================
54  // Namespace aliases:
55  //==============================================================================
56  namespace sp = boost::spirit;
57  namespace ph = boost::phoenix;
58  namespace qi = sp::qi;
59  namespace enc = sp::ascii;
60  namespace rep = sp::repository;
61  //==============================================================================
62  // Grammars
63  //==============================================================================
64  typedef std::string::const_iterator DefaultIterator;
65  typedef enc::space_type DefaultSkipper;
66  //==============================================================================
67  template <typename Iterator, typename T, typename Skipper, class Enable = void>
68  struct Grammar_ {
69  /* READ THIS IF YOUR COMPILE BREAKS ON THE FOLLOWING LINE
70  *
71  * To users: You have to ask developers to implement parser for your type T
72  * To developer: You have to implement and register Grammar for type T
73  *
74  */
75  BOOST_MPL_ASSERT_MSG( false, GRAMMAR_FOR_TYPE_DOES_NOT_EXISTS, ( T ) );
76  };
77 
78 #define REGISTER_GRAMMAR( ResultType, GrammarName ) \
79  template <typename Iterator, typename Skipper> \
80  struct Grammar_<Iterator, ResultType, Skipper> { \
81  typedef GrammarName<Iterator, Skipper> Grammar; \
82  }
83  //==============================================================================
84  template <typename Iterator>
85  struct SkipperGrammar : qi::grammar<Iterator> {
87  comments = enc::space | rep::confix( "/*", "*/" )[*( qi::char_ - "*/" )] |
88  rep::confix( "//", ( sp::eol | sp::eoi ) )[*( qi::char_ - ( sp::eol | sp::eoi ) )];
89  }
90  qi::rule<Iterator> comments;
91  };
92  //==============================================================================
93  template <typename Iterator, typename Skipper>
94  struct StringGrammar : qi::grammar<Iterator, std::string(), qi::locals<char>, Skipper> {
95  //------------------------------------------------------------------------------
97  //------------------------------------------------------------------------------
98  StringGrammar() : StringGrammar::base_type( str ) {
99  begin_quote = enc::char_( "\"'" );
100  quote = enc::char_( qi::_r1 );
101 
102  str = qi::lexeme[begin_quote[qi::_a = qi::_1] >
103  *( ( enc::char_( '\\' ) >> quote( qi::_a ) )[qi::_val += qi::_a] |
104  ( enc::char_[qi::_val += qi::_1] - quote( qi::_a ) ) ) > quote( qi::_a )];
105  }
106  //------------------------------------------------------------------------------
107  qi::rule<Iterator, std::string(), qi::locals<char>, Skipper> str;
108  qi::rule<Iterator, char()> begin_quote;
109  qi::rule<Iterator, void( char )> quote;
110  //------------------------------------------------------------------------------
111  };
112  REGISTER_GRAMMAR( std::string, StringGrammar );
113  REGISTER_GRAMMAR( Gaudi::StringKey, StringGrammar );
114  //==============================================================================
115  template <typename Iterator, typename Skipper>
116  struct CharGrammar : qi::grammar<Iterator, char(), Skipper> {
117  typedef char ResultT;
118  CharGrammar() : CharGrammar::base_type( ch ) {
119  ch = qi::int_parser<char>() | '\'' >> ( qi::char_ - '\'' ) >> '\'';
120  }
121  qi::rule<Iterator, char(), Skipper> ch;
122  };
123  REGISTER_GRAMMAR( char, CharGrammar );
124  //==============================================================================
125  template <typename Iterator, typename Skipper>
126  struct BoolGrammar : qi::grammar<Iterator, bool(), Skipper> {
127  typedef bool ResultT;
129  boolean_literal = ( qi::lit( "true" ) | "True" | "TRUE" | "1" )[qi::_val = true] |
130  ( qi::lit( "false" ) | "False" | "FALSE" | "0" )[qi::_val = false];
131  }
132  qi::rule<Iterator, bool(), Skipper> boolean_literal;
133  };
134  REGISTER_GRAMMAR( bool, BoolGrammar );
135  //==============================================================================
136  template <typename Iterator, typename RT, typename Skipper>
137  struct IntGrammar : qi::grammar<Iterator, RT(), Skipper> {
138  typedef RT ResultT;
139  IntGrammar() : IntGrammar::base_type( integer ) {
140  integer = qi::int_parser<RT>()[qi::_val = qi::_1] >> -qi::no_case[qi::char_( 'L' )];
141  }
142  qi::rule<Iterator, RT(), Skipper> integer;
143  };
144  // ----------------------------------------------------------------------------
145  // Register IntGrammar:
146  // ----------------------------------------------------------------------------
147  template <typename Iterator, typename T, typename Skipper>
148  struct Grammar_<Iterator, T, Skipper, std::enable_if_t<std::is_integral_v<T>>> {
150  };
151  //==============================================================================
152  template <typename Iterator, typename RT, typename Skipper>
153  struct RealGrammar : qi::grammar<Iterator, RT(), Skipper> {
154  typedef RT ResultT;
155  RealGrammar() : RealGrammar::base_type( real ) { real = qi::real_parser<RT>(); }
156  qi::rule<Iterator, RT(), Skipper> real;
157  };
158  // ----------------------------------------------------------------------------
159  // Register RealGrammar:
160  // ----------------------------------------------------------------------------
161  template <typename Iterator, typename T, typename Skipper>
162  struct Grammar_<Iterator, T, Skipper, std::enable_if_t<std::is_floating_point_v<T>>> {
164  };
165  //==============================================================================
166  // Grammar for std::tuples
167  //==============================================================================
168  template <typename T>
170 
171  template <typename T>
173 
174  template <typename T, typename... Ts>
175  struct tuple_remove_first_type<std::tuple<T, Ts...>> {
176  typedef std::tuple<Ts...> type;
177  };
178 
179  template <typename T, typename... Ts>
180  struct tuple_get_first_type<std::tuple<T, Ts...>> {
181  typedef T type;
182  };
183 
184  // ----------------------------------------------------------------------------
185 
186  template <typename Iterator, typename TupleT, std::size_t N, typename Skipper>
188  : qi::grammar<Iterator, TupleT(), qi::locals<typename tuple_get_first_type<TupleT>::type>, Skipper> {
189  //---------------------------------------------------------------------------
190  typedef TupleT ResultT;
193  //---------------------------------------------------------------------------
194  struct Operations {
195  //----------------------------------------------------------------------
196 
197  void operator()( ResultT& res, HeadT& head, TailT& tail ) const {
198  res = std::tuple_cat( std::tuple<HeadT>( head ), tail );
199  }
200  //----------------------------------------------------------------------
201  };
202  //---------------------------------------------------------------------------
204  tup = grHead[qi::_a = qi::_1] >> ',' >> grLast[op( qi::_val, qi::_a, qi::_1 )];
205  }
206 
209 
210  qi::rule<Iterator, ResultT(), qi::locals<HeadT>, Skipper> tup;
211  ph::function<Operations> op;
212  };
213 
214  template <typename Iterator, typename TupleT, typename Skipper>
215  struct TupleInnerGrammar<Iterator, TupleT, 1, Skipper> : qi::grammar<Iterator, TupleT(), Skipper> {
216  //---------------------------------------------------------------------------
217  typedef TupleT ResultT;
218  // typedef typename ResultT::value_type Tuple1T;
219  //---------------------------------------------------------------------------
220  struct Operations {
221  //---------------------------------------------------------------------
222  void operator()( ResultT& res, const std::tuple_element_t<0, ResultT>& val ) const {
223  res = ResultT();
224  std::get<0>( res ) = val;
225  }
226  //----------------------------------------------------------------------
227  };
228  //---------------------------------------------------------------------------
229  TupleInnerGrammar() : TupleInnerGrammar::base_type( tup ) { tup = grFirst[op( qi::_val, qi::_1 )]; }
230 
232 
233  qi::rule<Iterator, ResultT(), Skipper> tup;
234  ph::function<Operations> op;
235  };
236 
237  // ----------------------------------------------------------------------------
238  template <typename Iterator, typename TupleT, std::size_t N, typename Skipper>
239  struct TupleGrammar : qi::grammar<Iterator, TupleT(), qi::locals<char>, Skipper> {
240  typedef TupleT ResultT;
241  TupleGrammar() : TupleGrammar::base_type( tup ) {
242  begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')'];
243  end = enc::char_( qi::_r1 );
244 
245  tup = begin[qi::_a = qi::_1] >> grTuple[qi::_val = qi::_1] >> end( qi::_a );
246  }
247 
248  qi::rule<Iterator, char()> begin;
249  qi::rule<Iterator, void( char )> end;
250  qi::rule<Iterator, ResultT(), qi::locals<char>, Skipper> tup;
252  };
253 
254  // -----------------------------------------------------------------------------
255  // Register TupleGrammar for std::tuple:
256  // ----------------------------------------------------------------------------
257  template <typename Iterator, typename Skipper, typename... Args>
258  struct Grammar_<Iterator, std::tuple<Args...>, Skipper> {
259  typedef TupleGrammar<Iterator, std::tuple<Args...>, sizeof...( Args ), Skipper> Grammar;
260  };
261  //==============================================================================
262  template <typename Iterator, typename VectorT, typename Skipper>
263  struct VectorGrammar : qi::grammar<Iterator, VectorT(), qi::locals<char>, Skipper> {
264  //------------------------------------------------------------------------------
265  typedef VectorT ResultT;
266  //------------------------------------------------------------------------------
267  VectorGrammar() : VectorGrammar::base_type( vec ) {
268  begin =
269  enc::char_( '[' )[qi::_val = ']'] | enc::char_( '{' )[qi::_val = '}'] | enc::char_( '(' )[qi::_val = ')'];
270  end = enc::char_( qi::_r1 );
271  list = elementGrammar % ',';
272  vec = begin[qi::_a = qi::_1] >> -list[qi::_val = qi::_1] >> end( qi::_a );
273  }
274  // ----------------------------------------------------------------------------
276  qi::rule<Iterator, char()> begin;
277  qi::rule<Iterator, void( char )> end;
278 
279  qi::rule<Iterator, ResultT(), qi::locals<char>, Skipper> vec;
280  qi::rule<Iterator, ResultT(), Skipper> list;
281  // ----------------------------------------------------------------------------
282  };
283  // ----------------------------------------------------------------------------
284  // Register VectorGrammar for std::vector:
285  // ----------------------------------------------------------------------------
286  template <typename Iterator, typename InnerT, typename AllocatorT, typename Skipper>
287  struct Grammar_<Iterator, std::vector<InnerT, AllocatorT>, Skipper> {
289  };
290  // ----------------------------------------------------------------------------
291  // Register VectorGrammar for std::list:
292  // ----------------------------------------------------------------------------
293  template <typename Iterator, typename InnerT, typename AllocatorT, typename Skipper>
294  struct Grammar_<Iterator, std::list<InnerT, AllocatorT>, Skipper> {
296  };
297  // ----------------------------------------------------------------------------
298  // Register VectorGrammar for std::set:
299  // ----------------------------------------------------------------------------
300  template <typename Iterator, typename InnerT, typename CompareT, typename AllocatorT, typename Skipper>
301  struct Grammar_<Iterator, std::set<InnerT, CompareT, AllocatorT>, Skipper> {
303  };
304  // ----------------------------------------------------------------------------
305  // Register VectorGrammar for std::unordered_set:
306  // ----------------------------------------------------------------------------
307  template <typename Iterator, typename InnerT, typename HashT, typename CompareT, typename AllocatorT,
308  typename Skipper>
309  struct Grammar_<Iterator, std::unordered_set<InnerT, HashT, CompareT, AllocatorT>, Skipper> {
311  };
312 
313  //==============================================================================
314  template <typename Iterator, typename PairT, typename Skipper>
315  struct PairGrammar : qi::grammar<Iterator, PairT(), qi::locals<char>, Skipper> {
316  //------------------------------------------------------------------------------
317  typedef PairT ResultT;
318  typedef typename PairT::first_type first_type;
319  typedef typename PairT::second_type second_type;
320  //------------------------------------------------------------------------------
321  struct first {};
322  struct second {};
323  //------------------------------------------------------------------------------
324  PairGrammar() : PairGrammar( "," ) {}
325  PairGrammar( const std::string& delimeter ) : PairGrammar::base_type( pair ) {
326  begin = enc::char_( '(' )[qi::_val = ')'] | enc::char_( '[' )[qi::_val = ']'];
327  end = qi::char_( qi::_r1 );
328  pair = begin[qi::_a = qi::_1] >> pair_in[qi::_val = qi::_1] >> end( qi::_a );
329  pair_in = key >> qi::lit( delimeter ) >> value;
330  }
331  // ----------------------------------------------------------------------------
334  qi::rule<Iterator, char()> begin;
335  qi::rule<Iterator, void( char )> end;
336  qi::rule<Iterator, ResultT(), qi::locals<char>, Skipper> pair;
338  // ph::function<Operations> op;
339  // ----------------------------------------------------------------------------
340  }; // END PairGrammar
341  // ----------------------------------------------------------------------------
342  // Register PairGrammar:
343  // ----------------------------------------------------------------------------
344  template <typename Iterator, typename KeyT, typename ValueT, typename Skipper>
345  struct Grammar_<Iterator, std::pair<KeyT, ValueT>, Skipper> {
347  };
348  // ============================================================================
349  template <typename Iterator, typename MapT, typename Skipper>
350  struct MapGrammar : qi::grammar<Iterator, MapT(), Skipper> {
351  //------------------------------------------------------------------------------
352  typedef MapT ResultT;
353  typedef typename MapT::key_type KeyT;
354  typedef typename MapT::mapped_type MappedT;
356 
358  //------------------------------------------------------------------------------
359  struct tag_key {};
360  struct tag_mapped {};
361  struct Operations {
362  //----------------------------------------------------------------------
363  void operator()( ResultT& res, const VectorPairT& vec ) const {
364  for ( auto cur = vec.begin(); cur != vec.end(); ++cur ) { res.insert( *cur ); }
365  }
366  void operator()( PairT& res, const KeyT& key, tag_key ) const { res.first = key; }
367  void operator()( PairT& res, const MappedT& value, tag_mapped ) const { res.second = value; }
368  //----------------------------------------------------------------------
369  };
370  //------------------------------------------------------------------------------
371  MapGrammar() : MapGrammar::base_type( map ) {
372  pair = key[op( qi::_val, qi::_1, tag_key() )] > ( qi::lit( ':' ) | '=' ) >
373  value[op( qi::_val, qi::_1, tag_mapped() )];
374  list = -( pair % enc::char_( ',' ) );
375  map = ( ( '[' >> list >> ']' ) | ( '{' >> list >> '}' ) )[op( qi::_val, qi::_1 )];
376  }
377  // ----------------------------------------------------------------------------
380  qi::rule<Iterator, PairT(), Skipper> pair;
382  qi::rule<Iterator, ResultT(), Skipper> map;
383  ph::function<Operations> op;
384  // ----------------------------------------------------------------------------
385  };
386  // ----------------------------------------------------------------------------
387  // Register MapGrammar for std::map:
388  // ----------------------------------------------------------------------------
389  template <typename Iterator, typename KeyT, typename ValueT, typename KeyCompareT, typename AllocatorT,
390  typename Skipper>
391  struct Grammar_<Iterator, std::map<KeyT, ValueT, KeyCompareT, AllocatorT>, Skipper> {
393  };
394  // ----------------------------------------------------------------------------
395  // Register MapGrammar for std::unordered_map:
396  // ----------------------------------------------------------------------------
397  template <typename Iterator, typename KeyT, typename ValueT, typename HashT, typename KeyCompareT,
398  typename AllocatorT, typename Skipper>
399  struct Grammar_<Iterator, std::unordered_map<KeyT, ValueT, HashT, KeyCompareT, AllocatorT>, Skipper> {
401  };
402  // ----------------------------------------------------------------------------
403  // Register MapGrammar for GaudiUtils::VectorMap:
404  // ----------------------------------------------------------------------------
405  template <typename Iterator, typename KeyT, typename ValueT, typename KeyCompareT, typename AllocatorT,
406  typename Skipper>
407  struct Grammar_<Iterator, GaudiUtils::VectorMap<KeyT, ValueT, KeyCompareT, AllocatorT>, Skipper> {
409  };
410  // ============================================================================
411  template <typename Iterator, typename PointT, typename Skipper>
412  struct Pnt3DGrammar : qi::grammar<Iterator, PointT(), Skipper> {
413  typedef PointT ResultT;
414  typedef typename PointT::Scalar Scalar;
415  // ----------------------------------------------------------------------------
416  struct Operations {
417  void operator()( ResultT& res, const Scalar& scalar, const char xyz ) const {
418  switch ( xyz ) {
419  case 'x':
420  res.SetX( scalar );
421  break;
422  case 'y':
423  res.SetY( scalar );
424  break;
425  case 'z':
426  res.SetZ( scalar );
427  break;
428  default:
429  break;
430  }
431  }
432  }; // Operations
433  // ----------------------------------------------------------------------------
434  Pnt3DGrammar() : Pnt3DGrammar::base_type( point ) {
435  point = list | ( '(' >> list >> ')' ) | ( '[' >> list >> ']' );
436  list = -( enc::no_case[qi::lit( "x" ) | qi::lit( "px" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'x' )] >>
437  ',' >> -( enc::no_case[qi::lit( "y" ) | qi::lit( "py" )] >> ':' ) >>
438  scalar[op( qi::_val, qi::_1, 'y' )] >> ',' >>
439  -( enc::no_case[qi::lit( "z" ) | qi::lit( "pz" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'z' )];
440  }
441  // ----------------------------------------------------------------------------
444  ph::function<Operations> op;
445  // ----------------------------------------------------------------------------
446  }; // Pnt3DGrammar
447  // ----------------------------------------------------------------------------
448  // Register Pnt3DGrammar for ROOT::Math::PositionVector3D:
449  // ----------------------------------------------------------------------------
450  template <typename Iterator, typename T1, typename T2, typename Skipper>
451  struct Grammar_<Iterator, ROOT::Math::PositionVector3D<T1, T2>, Skipper> {
453  };
454  // ----------------------------------------------------------------------------
455  // Register Pnt3DGrammar for ROOT::Math::DisplacementVector3D:
456  // ----------------------------------------------------------------------------
457  template <typename Iterator, typename T1, typename T2, typename Skipper>
458  struct Grammar_<Iterator, ROOT::Math::DisplacementVector3D<T1, T2>, Skipper> {
460  };
461  // ============================================================================
462  template <typename Iterator, typename PointT, typename Skipper>
463  struct Pnt4DGrammar : qi::grammar<Iterator, PointT(), Skipper> {
464  typedef PointT ResultT;
465  typedef typename PointT::Scalar ScalarT;
466  //-----------------------------------------------------------------------------
467  struct Operations {
468 
469  void operator()( ResultT& res, const ScalarT& scalar, const char xyz ) const {
470  switch ( xyz ) {
471  case 'x':
472  res.SetPx( scalar );
473  break;
474  case 'y':
475  res.SetPy( scalar );
476  break;
477  case 'z':
478  res.SetPz( scalar );
479  break;
480  case 'e':
481  res.SetE( scalar );
482  break;
483  default:
484  break;
485  }
486  }
487  void operator()( ResultT& res, const ResultT& xyz ) const {
488  res.SetPx( xyz.Px() );
489  res.SetPy( xyz.Py() );
490  res.SetPz( xyz.Pz() );
491  }
492  }; // Operations
493  // ----------------------------------------------------------------------------
494  Pnt4DGrammar() : Pnt4DGrammar::base_type( point4d ) {
495  point4d = list4d | ( '(' >> list4d >> ')' ) | ( '[' >> list4d >> ']' );
496  list4d = ( point3d[op( qi::_val, qi::_1 )] >> enc::char_( ";," ) >> e[op( qi::_val, qi::_1, 'e' )] ) |
497  ( e[op( qi::_val, qi::_1, 'e' )] >> enc::char_( ";," ) >> point3d[op( qi::_val, qi::_1 )] );
498  e = -( enc::no_case[enc::char_( "te" )] >> ':' ) >> scalar[qi::_val = qi::_1];
499 
500  point3d = list3d | ( '(' >> list3d >> ')' ) | ( '[' >> list3d >> ']' );
501  list3d = -( enc::no_case[qi::lit( "x" ) | qi::lit( "px" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'x' )] >>
502  ',' >> -( enc::no_case[qi::lit( "y" ) | qi::lit( "py" )] >> ':' ) >>
503  scalar[op( qi::_val, qi::_1, 'y' )] >> ',' >>
504  -( enc::no_case[qi::lit( "z" ) | qi::lit( "pz" )] >> ':' ) >> scalar[op( qi::_val, qi::_1, 'z' )];
505  }
506  // ----------------------------------------------------------------------------
508  qi::rule<Iterator, ScalarT(), Skipper> e;
510  ph::function<Operations> op;
511  // ----------------------------------------------------------------------------
512  }; // Pnt4DGrammar
513  // ----------------------------------------------------------------------------
514  // Register Pnt4DGrammar for ROOT::Math::LorentzVector:
515  // ----------------------------------------------------------------------------
516  template <typename Iterator, typename T1, typename Skipper>
517  struct Grammar_<Iterator, ROOT::Math::LorentzVector<T1>, Skipper> {
519  };
520  // ============================================================================
521  template <typename Iterator, typename Skipper>
522  struct Histo1DGrammar : qi::grammar<Iterator, Gaudi::Histo1DDef(), qi::locals<char>, Skipper> {
524  // ----------------------------------------------------------------------------
525  struct Operations {
526  void operator()( ResultT& res, const std::string& title ) const { res.setTitle( title ); }
527  void operator()( ResultT& res, const double& val, const char lh ) const {
528  switch ( lh ) {
529  case 'l':
530  res.setLowEdge( val );
531  break;
532  case 'h':
533  res.setHighEdge( val );
534  break;
535  default:
536  break;
537  }
538  }
539  void operator()( ResultT& res, int val ) const { res.setBins( val ); }
540  void operator()( ResultT& res ) const {}
541  }; // Operations
542  // ----------------------------------------------------------------------------
543  Histo1DGrammar() : Histo1DGrammar::base_type( hist ) {
544  val1 = title[op( qi::_val, qi::_1 )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >>
545  qi::double_[op( qi::_val, qi::_1, 'h' )] >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] );
546  val2 = qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'h' )] >> ',' >>
547  title[op( qi::_val, qi::_1 )] >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] );
548  val3 = qi::double_[op( qi::_val, qi::_1, 'l' )] >> ',' >> qi::double_[op( qi::_val, qi::_1, 'h' )] >>
549  -( ',' >> title[op( qi::_val, qi::_1 )] ) >> -( ',' >> qi::int_[op( qi::_val, qi::_1 )] );
550  begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')'];
551  end = enc::char_( qi::_r1 );
552  hist = begin[qi::_a = qi::_1] >> ( val1 | val2 | val3 )[qi::_val = qi::_1] >> end( qi::_a );
553  }
554  // ----------------------------------------------------------------------------
555  qi::rule<Iterator, ResultT(), qi::locals<char>, Skipper> hist;
557  qi::rule<Iterator, char()> begin;
558  qi::rule<Iterator, void( char )> end;
560  ph::function<Operations> op;
561  // ----------------------------------------------------------------------------
562  }; // Histo1DGrammar
563  // ----------------------------------------------------------------------------
565  // ============================================================================
566  template <typename Iterator, typename Skipper>
567  struct KeyValueGrammar : qi::grammar<Iterator, std::pair<std::string, std::string>(), Skipper> {
568  //------------------------------------------------------------------------------
570  //------------------------------------------------------------------------------
571  struct first {};
572  struct second {};
573 
575  //------------------------------------------------------------------------------
576  pair = gstring >> ":" >> +enc::char_;
577  }
578  // ----------------------------------------------------------------------------
580  qi::rule<Iterator, ResultT(), Skipper> pair;
581  // ----------------------------------------------------------------------------
582  }; // END KeyValueGrammar
583  // We don't register KeyalueGrammar because it's a special parser
584  // ============================================================================
585  } // namespace Parsers
586 } // namespace Gaudi
qi::rule< Iterator, char()> begin
Definition: Grammars.h:334
qi::rule< Iterator, ResultT(), Skipper > pair
Definition: Grammars.h:580
VectorGrammar< Iterator, std::vector< InnerT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:288
qi::rule< Iterator, ResultT(), Skipper > val3
Definition: Grammars.h:556
qi::rule< Iterator, VectorPairT(), Skipper > list
Definition: Grammars.h:381
StringGrammar< Iterator, Skipper > gstring
Definition: Grammars.h:579
MapGrammar< Iterator, std::map< KeyT, ValueT, KeyCompareT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:392
Grammar_< Iterator, ScalarT, Skipper >::Grammar scalar
Definition: Grammars.h:509
PairT::second_type second_type
Definition: Grammars.h:319
void operator()(ResultT &res, int val) const
Definition: Grammars.h:539
REGISTER_GRAMMAR(std::string, StringGrammar)
void operator()(ResultT &res, const std::string &title) const
Definition: Grammars.h:526
qi::rule< Iterator > comments
Definition: Grammar.h:56
Grammar_< Iterator, typename PairT::first_type, Skipper >::Grammar key
Definition: Grammars.h:332
qi::rule< Iterator, ResultT(), Skipper > point
Definition: Grammars.h:442
qi::rule< Iterator, ResultT(), qi::locals< char >, Skipper > pair
Definition: Grammars.h:336
qi::rule< Iterator, ResultT(), qi::locals< char >, Skipper > tup
Definition: Grammars.h:250
qi::rule< Iterator, ResultT(), qi::locals< char >, Skipper > vec
Definition: Grammars.h:279
struct GAUDI_API vector
Parametrisation class for vector-like implementation.
SkipperGrammar< IteratorT > Skipper
Definition: Factory.h:36
qi::rule< Iterator, ResultT(), qi::locals< HeadT >, Skipper > tup
Definition: Grammars.h:210
ph::function< Operations > op
Definition: Grammars.h:444
STL namespace.
MapT::mapped_type MappedT
Definition: Grammars.h:354
Grammar_< Iterator, std::tuple_element_t< 0, ResultT >, Skipper >::Grammar grFirst
Definition: Grammars.h:231
T end(T... args)
StringGrammar< Iterator, Skipper > title
Definition: Grammars.h:559
void operator()(ResultT &res, const Scalar &scalar, const char xyz) const
Definition: Grammars.h:417
qi::rule< Iterator, ResultT(), Skipper > map
Definition: Grammars.h:382
void operator()(ResultT &res, const std::tuple_element_t< 0, ResultT > &val) const
Definition: Grammars.h:222
TupleInnerGrammar< Iterator, TailT, N - 1, Skipper > grLast
Definition: Grammars.h:207
BOOST_MPL_ASSERT_MSG(false, GRAMMAR_FOR_TYPE_DOES_NOT_EXISTS,(T))
VectorGrammar< Iterator, std::unordered_set< InnerT, HashT, CompareT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:310
void operator()(ResultT &res, const ResultT &xyz) const
Definition: Grammars.h:487
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:44
qi::rule< Iterator, void(char)> quote
Definition: Grammar.h:76
void operator()(PairT &res, const KeyT &key, tag_key) const
Definition: Grammars.h:366
qi::rule< Iterator, ScalarT(), Skipper > e
Definition: Grammars.h:508
qi::rule< Iterator, ResultT(), Skipper > list3d
Definition: Grammars.h:507
PairGrammar(const std::string &delimeter)
Definition: Grammars.h:325
STL class.
Grammar_< Iterator, typename VectorT::value_type, Skipper >::Grammar elementGrammar
Definition: Grammars.h:275
Grammar_< Iterator, HeadT, Skipper >::Grammar grHead
Definition: Grammars.h:208
int N
Definition: IOTest.py:110
qi::rule< Iterator, char()> begin
Definition: Grammars.h:557
3D point typedefs
struct GAUDI_API map
Parametrisation class for map-like implementation.
qi::rule< Iterator, ResultT(), Skipper > point3d
Definition: Grammars.h:507
qi::rule< Iterator, Node(), Skipper > real
Definition: Grammar.h:121
qi::rule< Iterator, void(char)> end
Definition: Grammars.h:249
std::pair< KeyT, MappedT > PairT
Definition: Grammars.h:355
ph::function< Operations > op
Definition: Grammars.h:211
Pnt3DGrammar< Iterator, ROOT::Math::DisplacementVector3D< T1, T2 >, Skipper > Grammar
Definition: Grammars.h:459
qi::rule< Iterator, ResultT(), Skipper > val1
Definition: Grammars.h:556
VectorGrammar< Iterator, std::list< InnerT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:295
Grammar_< Iterator, typename PairT::second_type, Skipper >::Grammar value
Definition: Grammars.h:333
Simple helper class for description of 1D-histogram The class is targeted to act as the primary "hist...
Definition: HistoDef.h:41
qi::rule< Iterator, ResultT(), qi::locals< char >, Skipper > hist
Definition: Grammars.h:555
MapT::key_type KeyT
Definition: Grammars.h:353
qi::rule< Iterator, ResultT(), Skipper > pair_in
Definition: Grammars.h:337
PairT::first_type first_type
Definition: Grammars.h:318
tuple_get_first_type< TupleT >::type HeadT
Definition: Grammars.h:192
qi::rule< Iterator, ResultT(), Skipper > point4d
Definition: Grammars.h:507
qi::rule< Iterator, PairT(), Skipper > pair
Definition: Grammars.h:380
MapGrammar< Iterator, GaudiUtils::VectorMap< KeyT, ValueT, KeyCompareT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:408
qi::rule< Iterator, ResultT(), Skipper > list
Definition: Grammars.h:280
MapGrammar< Iterator, std::unordered_map< KeyT, ValueT, HashT, KeyCompareT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:400
std::string::const_iterator DefaultIterator
Definition: Grammars.h:64
void operator()(ResultT &res, HeadT &head, TailT &tail) const
Definition: Grammars.h:197
Pnt4DGrammar< Iterator, ROOT::Math::LorentzVector< T1 >, Skipper > Grammar
Definition: Grammars.h:518
Grammar_< Iterator, typename MapT::key_type, Skipper >::Grammar key
Definition: Grammars.h:378
enc::space_type DefaultSkipper
Definition: Grammars.h:65
std::vector< PairT > VectorPairT
Definition: Grammars.h:357
qi::rule< Iterator, void(char)> end
Definition: Grammars.h:277
T tuple_cat(T... args)
qi::rule< Iterator, bool(), Skipper > boolean_literal
Definition: Grammars.h:132
STL class.
void operator()(PairT &res, const MappedT &value, tag_mapped) const
Definition: Grammars.h:367
boost::spirit::classic::position_iterator2< ForwardIterator > Iterator
Definition: Iterator.h:28
PairGrammar< Iterator, std::pair< KeyT, ValueT >, Skipper > Grammar
Definition: Grammars.h:346
T begin(T... args)
void operator()(ResultT &res, const ScalarT &scalar, const char xyz) const
Definition: Grammars.h:469
Forward declarations for the functions in SerializeSTL.h.
Definition: GaudiHistoID.h:146
qi::rule< Iterator, std::string(), qi::locals< char >, Skipper > str
Definition: Grammar.h:74
tuple_remove_first_type< TupleT >::type TailT
Definition: Grammars.h:191
qi::rule< Iterator, char(), Skipper > ch
Definition: Grammars.h:121
TupleInnerGrammar< Iterator, TupleT, N, Skipper > grTuple
Definition: Grammars.h:251
qi::rule< Iterator, void(char)> end
Definition: Grammars.h:558
void operator()(ResultT &res, const VectorPairT &vec) const
Definition: Grammars.h:363
qi::rule< Iterator, ResultT(), Skipper > list4d
Definition: Grammars.h:507
qi::rule< Iterator, char()> begin
Definition: Grammars.h:276
ph::function< Operations > op
Definition: Grammars.h:383
Pnt3DGrammar< Iterator, ROOT::Math::PositionVector3D< T1, T2 >, Skipper > Grammar
Definition: Grammars.h:452
void operator()(ResultT &res) const
Definition: Grammars.h:540
VectorGrammar< Iterator, std::set< InnerT, CompareT, AllocatorT >, Skipper > Grammar
Definition: Grammars.h:302
4D point typedefs
Grammar_< Iterator, typename MapT::mapped_type, Skipper >::Grammar value
Definition: Grammars.h:379
qi::rule< Iterator, RT(), Skipper > real
Definition: Grammars.h:156
qi::rule< Iterator, RT(), Skipper > integer
Definition: Grammars.h:142
qi::rule< Iterator, char()> begin
Definition: Grammars.h:248
qi::rule< Iterator, ResultT(), Skipper > val2
Definition: Grammars.h:556
qi::rule< Iterator, void(char)> end
Definition: Grammars.h:335
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
Gaudi::Histo1DDef ResultT
Definition: Grammars.h:523
qi::rule< Iterator, char()> begin_quote
Definition: Grammar.h:75
std::pair< std::string, std::string > ResultT
Definition: Grammars.h:569
ph::function< Operations > op
Definition: Grammars.h:510
qi::rule< Iterator, ResultT(), Skipper > tup
Definition: Grammars.h:233
qi::rule< Iterator, ResultT(), Skipper > list
Definition: Grammars.h:442
void operator()(ResultT &res, const double &val, const char lh) const
Definition: Grammars.h:527
PointT::Scalar ScalarT
Definition: Grammars.h:465
Grammar_< Iterator, Scalar, Skipper >::Grammar scalar
Definition: Grammars.h:443
ph::function< Operations > op
Definition: Grammars.h:560