OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
description.hpp
Go to the documentation of this file.
1 //
2 // Struct description
3 //
4 // Copyright (c) 2015, Christof Metzger-Kraus, Helmholtz-Zentrum Berlin
5 // All rights reserved
6 //
7 // This file is part of OPAL.
8 //
9 // OPAL is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License as published by
11 // the Free Software Foundation, either version 3 of the License, or
12 // (at your option) any later version.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
16 //
17 #ifndef DESCRIPTION_HPP_
18 #define DESCRIPTION_HPP_
19 
20 #include "ast.hpp"
21 #include "skipper.hpp"
22 #include "error_handler.hpp"
23 
24 #include <boost/config/warning_disable.hpp>
25 #include <boost/spirit/include/qi.hpp>
26 #include <boost/fusion/include/adapt_struct.hpp>
27 #include <boost/optional.hpp>
28 
29 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
30 #define BOOST_SPIRIT_QI_DEBUG
31 
32 namespace SDDS {
33  struct description
34  {
35  boost::optional<std::string> text_m;
36  boost::optional<std::string> content_m;
37 
38  };
39 
40  inline std::ostream& operator<<(std::ostream& out, const description& desc) {
41  if (desc.text_m) out << "text = " << *desc.text_m << ", ";
42  if (desc.content_m) out << "content = " << *desc.content_m;
43  return out;
44  }
45 }
46 
49  (boost::optional<std::string>, text_m)
50  (boost::optional<std::string>, content_m)
51 )
52 
53 namespace SDDS { namespace parser
54 {
55  namespace qi = boost::spirit::qi;
56  namespace ascii = boost::spirit::ascii;
57  namespace phx = boost::phoenix;
58 
59  template <typename Iterator>
60  struct description_parser: qi::grammar<Iterator, description(), skipper<Iterator> >
61  {
62  description_parser(error_handler<Iterator> & _error_handler);
63 
64  qi::rule<Iterator, description(), skipper<Iterator> > start;
65  qi::rule<Iterator, std::string(), skipper<Iterator> > quoted_string,
66  description_text, description_content;
67  };
68 }}
69 #endif /* DESCRIPTION_HPP_ */
BOOST_FUSION_ADAPT_STRUCT(SDDS::description,(boost::optional< std::string >, text_m)(boost::optional< std::string >, content_m)) namespace SDDS
Definition: description.hpp:47
Definition: array.hpp:33
std::ostream & operator<<(std::ostream &out, const array &)
Definition: array.hpp:97
boost::optional< std::string > text_m
Definition: description.hpp:35
boost::optional< std::string > content_m
Definition: description.hpp:36