OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
associate.hpp
Go to the documentation of this file.
1 //
2 // Struct associate
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 ASSOCIATE_HPP_
18 #define ASSOCIATE_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/spirit/include/phoenix_core.hpp>
27 #include <boost/spirit/include/phoenix_operator.hpp>
28 #include <boost/spirit/include/phoenix_fusion.hpp>
29 #include <boost/spirit/include/phoenix_bind.hpp>
30 #include <boost/fusion/include/adapt_struct.hpp>
31 
32 #include <list>
33 
34 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
35 #define BOOST_SPIRIT_QI_DEBUG
36 
37 namespace SDDS {
38  struct associate
39  {
42  , PATH
45  , SDDS
47  };
48 
49  template <attributes A>
51  {
52  static bool apply()
53  {
54  std::string attributeString;
55  switch(A)
56  {
57  case NAME:
58  attributeString = "name";
59  break;
60  case FILENAME:
61  attributeString = "filename";
62  break;
63  case PATH:
64  attributeString = "path";
65  break;
66  case DESCRIPTION:
67  attributeString = "description";
68  break;
69  case CONTENTS:
70  attributeString = "contents";
71  break;
72  case SDDS:
73  attributeString = "sdds";
74  break;
75  case ASSOCIATE:
76  attributeString = "associate";
77  break;
78  default:
79  return true;
80  }
81  std::cerr << attributeString << " not supported yet" << std::endl;
82  return false;
83  }
84  };
85  };
86 
87  struct associateList: std::list<associate> {};
88 
89  inline std::ostream& operator<<(std::ostream& out, const associate& ) {
90  return out;
91  }
92 }
93 
94 namespace SDDS { namespace parser
95 {
96  namespace qi = boost::spirit::qi;
97  namespace ascii = boost::spirit::ascii;
98  namespace phx = boost::phoenix;
99 
100  template <typename Iterator>
101  struct associate_parser: qi::grammar<Iterator, associate(), skipper<Iterator> >
102  {
103  associate_parser(error_handler<Iterator> & _error_handler);
104 
105  qi::rule<Iterator, associate(), skipper<Iterator> > start;
106  qi::rule<Iterator, std::string(), skipper<Iterator> > string, quoted_string,
109  qi::rule<Iterator, long(), skipper<Iterator> > associate_sdds;
112  };
113 }}
114 #endif /* ASSOCIATE_HPP_ */
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
Definition: array.hpp:33
std::ostream & operator<<(std::ostream &out, const array &)
Definition: array.hpp:97
associate_parser(error_handler< Iterator > &_error_handler)
qi::rule< Iterator, ast::nil(), skipper< Iterator > > associate_unsupported_pre
Definition: associate.hpp:110
qi::rule< Iterator, ast::nil(), skipper< Iterator > > associate_unsupported_post
Definition: associate.hpp:111
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_contents
Definition: associate.hpp:108
qi::rule< Iterator, std::string(), skipper< Iterator > > string
Definition: associate.hpp:106
qi::rule< Iterator, associate(), skipper< Iterator > > start
Definition: associate.hpp:105
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_filename
Definition: associate.hpp:107
qi::rule< Iterator, std::string(), skipper< Iterator > > quoted_string
Definition: associate.hpp:106
qi::rule< Iterator, long(), skipper< Iterator > > associate_sdds
Definition: associate.hpp:109
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_description
Definition: associate.hpp:107
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_path
Definition: associate.hpp:107
qi::rule< Iterator, std::string(), skipper< Iterator > > associate_name
Definition: associate.hpp:107