libpniio
slice_rule.hpp
Go to the documentation of this file.
1 //
2 // (c) Copyright 2013 DESY, Eugen Wintersberger <eugen.wintersberger@desy.de>
3 //
4 // This file is part of libpniio.
5 //
6 // libpniio is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation, either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // libpniio is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with libpniio. If not, see <http://www.gnu.org/licenses/>.
18 // ===========================================================================
19 //
20 // Created on: May 6, 2013
21 // Author: Eugen Wintersberger <eugen.wintersberger@desy.de>
22 //
23 //
24 
25 #pragma once
26 
27 #include <pni/core/types.hpp>
28 #include <pni/core/arrays/slice.hpp>
29 
30 #include <boost/spirit/include/qi.hpp>
31 #include <boost/spirit/include/phoenix.hpp>
32 
33 namespace pni{
34 namespace io{
35 
43 
48 
69  template<typename ITERT>
73  struct slice_rule: boost::spirit::qi::grammar<ITERT,
74  boost::spirit::qi::locals<size_t,size_t,size_t>,
75  pni::core::slice()>
76  {
78  boost::spirit::qi::rule<ITERT,
79  boost::spirit::qi::locals<size_t,size_t,size_t>,
80  pni::core::slice() > slice_;
81 
83  slice_rule() : slice_rule::base_type(slice_)
84  {
85  using namespace boost::spirit;
86  using namespace boost::spirit::qi;
87  using namespace boost::phoenix;
88  using qi::_1;
89 
90  slice_= eps[_a=0,_b=0,_c=1]>>(
91  (int_[_a = _1,_b=_1+1]>> -(':' >>int_[_b = _1]>> -(':' >>
92  int_[_c=_1])))
93  |
94  ( ':' >> int_[_b = _1]>> -(':'>>int_[_c = _1]))
95  )[_val = construct<pni::core::slice>(_a,_b,_c)];
96  }
97  };
98 //end of namespace
99 }
100 }
slice_rule()
default constructor
Definition: slice_rule.hpp:83
boost::spirit::qi::rule< ITERT, boost::spirit::qi::locals< size_t, size_t, size_t >, pni::core::slice() > slice_
rule to parse a slice string
Definition: slice_rule.hpp:80
slice parser
Definition: slice_rule.hpp:73
Definition: spirit_container_traits.hpp:33
Definition: cbf_reader.hpp:41