File indexing completed on 2025-09-18 09:13:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #pragma once
0012
0013 #include <Gaudi/Accumulators/StaticHistogram.h>
0014
0015 #include <Gaudi/Parsers/Factory.h>
0016 #include <GaudiKernel/ToStream.h>
0017
0018 #if ( BOOST_VERSION >= 187000 ) && ( BOOST_VERSION < 188000 )
0019 # define BOOST_ALLOW_DEPRECATED_HEADERS
0020 #endif
0021 #include <boost/spirit/include/qi.hpp>
0022 #undef BOOST_ALLOW_DEPRECATED_HEADERS
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033 namespace Gaudi {
0034 namespace Parsers {
0035
0036 namespace qi = boost::spirit::qi;
0037
0038 template <typename Iterator, typename Skipper, typename Arithmetic>
0039 struct AxisGrammar : qi::grammar<Iterator, Gaudi::Accumulators::Axis<Arithmetic>(), qi::locals<char>, Skipper> {
0040 using Axis = Gaudi::Accumulators::Axis<Arithmetic>;
0041 struct StoreNbinsOp {
0042 void operator()( Axis& res, unsigned int const& nBins ) const { res.setNumBins( nBins ); }
0043 };
0044 struct StoreMinValueOp {
0045 void operator()( Axis& res, Arithmetic const& minValue ) const { res.setMinValue( minValue ); }
0046 };
0047 struct StoreMaxValueOp {
0048 void operator()( Axis& res, Arithmetic const& maxValue ) const { res.setMaxValue( maxValue ); }
0049 };
0050 struct StoreTitleOp {
0051 void operator()( Axis& res, std::string const& title ) const { res.setTitle( title ); }
0052 };
0053 AxisGrammar() : AxisGrammar::base_type( axis ) {
0054 begin = enc::char_( '[' )[qi::_val = ']'] | enc::char_( '(' )[qi::_val = ')'];
0055 end = enc::char_( qi::_r1 );
0056 core = qi::int_[storeNbins( qi::_val, qi::_1 )] >> "," >> qi::double_[storeMinValue( qi::_val, qi::_1 )] >>
0057 "," >> qi::double_[storeMaxValue( qi::_val, qi::_1 )] >>
0058 -( "," >> title[storeTitle( qi::_val, qi::_1 )] );
0059 axis = begin[qi::_a = qi::_1] >> core[qi::_val = qi::_1] >> end( qi::_a );
0060 }
0061 qi::rule<Iterator, Axis(), qi::locals<char>, Skipper> axis;
0062 qi::rule<Iterator, Axis(), Skipper> core;
0063 qi::rule<Iterator, char()> begin;
0064 qi::rule<Iterator, void( char )> end;
0065 StringGrammar<Iterator, Skipper> title;
0066 ph::function<StoreNbinsOp> storeNbins;
0067 ph::function<StoreMinValueOp> storeMinValue;
0068 ph::function<StoreMaxValueOp> storeMaxValue;
0069 ph::function<StoreTitleOp> storeTitle;
0070 };
0071
0072 template <typename Iterator, typename Skipper, typename Arithmetic>
0073 struct Grammar_<Iterator, Gaudi::Accumulators::Axis<Arithmetic>, Skipper> {
0074 using Grammar = AxisGrammar<Iterator, Skipper, Arithmetic>;
0075 };
0076
0077
0078 template <typename Arithmetic>
0079 StatusCode parse( Gaudi::Accumulators::Axis<Arithmetic>& result, const std::string& input ) {
0080 return parse_( result, input );
0081 }
0082
0083 }
0084
0085 }