libpniio
delimiter_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 #pragma once
25 
26 #include <pni/core/types.hpp>
27 #include <boost/spirit/include/qi.hpp>
28 
29 namespace pni{
30 namespace io{
31 
49  template<typename ITERT >
50  struct delimiter_rule : boost::spirit::qi::grammar<ITERT,
51  pni::core::string()>
52  {
54  boost::spirit::qi::rule<ITERT,pni::core::string()> delimiter;
55 
56  //--------------------------------------------------------------------
64  delimiter_rule::base_type(delimiter)
65  {
66  using namespace boost::spirit;
67  //default behavior - at least one whitespace is a valid delimiter
68  delimiter = +qi::blank;
69  }
70 
71  //--------------------------------------------------------------------
83  delimiter_rule(char symbol):
84  delimiter_rule::base_type(delimiter)
85  {
86  using namespace boost::spirit;
87  if(symbol == ' ')
88  delimiter = +qi::blank;
89  else
90  delimiter = *qi::blank>>qi::char_(symbol)>>*qi::blank;
91  }
92 
93  };
94 
95 //end of namespace
96 }
97 }
boost::spirit::qi::rule< ITERT, pni::core::string()> delimiter
main parser rule
Definition: delimiter_rule.hpp:54
delimiter_rule()
default constructor
Definition: delimiter_rule.hpp:63
Definition: spirit_container_traits.hpp:33
Definition: cbf_reader.hpp:41
delimiter parser
Definition: delimiter_rule.hpp:50
delimiter_rule(char symbol)
constructor
Definition: delimiter_rule.hpp:83