OPAL (Object Oriented Parallel Accelerator Library) 2024.2
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
28#include <optional>
29#include <ostream>
30#include <string>
31
32#define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
33#define BOOST_SPIRIT_QI_DEBUG
34
35namespace SDDS {
37 {
38 std::optional<std::string> text_m;
39 std::optional<std::string> content_m;
40 };
41
42 inline std::ostream& operator<<(std::ostream& out, const description& desc) {
43 if (desc.text_m) out << "text = " << *desc.text_m << ", ";
44 if (desc.content_m) out << "content = " << *desc.content_m;
45 return out;
46 }
47}
48
51 (std::optional<std::string>, text_m)
52 (std::optional<std::string>, content_m)
53)
54
55namespace SDDS { namespace parser
56{
57 namespace qi = boost::spirit::qi;
58 namespace ascii = boost::spirit::ascii;
59 namespace phx = boost::phoenix;
60
61 template <typename Iterator>
62 struct description_parser: qi::grammar<Iterator, description(), skipper<Iterator> >
63 {
64 description_parser(error_handler<Iterator> & _error_handler);
65
66 qi::rule<Iterator, description(), skipper<Iterator> > start;
67 qi::rule<Iterator, std::string(), skipper<Iterator> > quoted_string,
68 description_text, description_content;
69 };
70}}
71#endif /* DESCRIPTION_HPP_ */
BOOST_FUSION_ADAPT_STRUCT(SDDS::description,(std::optional< std::string >, text_m)(std::optional< std::string >, content_m)) namespace SDDS
std::ostream & operator<<(std::ostream &out, const array &)
Definition array.hpp:97
std::optional< std::string > content_m
std::optional< std::string > text_m