OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
array.hpp
Go to the documentation of this file.
1 //
2 // Struct array
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 ARRAY_HPP_
18 #define ARRAY_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 <list>
29 
30 #define BOOST_SPIRIT_NO_PREDEFINED_TERMINALS
31 #define BOOST_SPIRIT_QI_DEBUG
32 
33 namespace SDDS {
34  struct array
35  {
42  , TYPE
46  };
47 
48  template <attributes A>
50  {
51  static bool apply()
52  {
53  std::string attributeString;
54  switch(A)
55  {
56  case NAME:
57  attributeString = "name";
58  break;
59  case SYMBOL:
60  attributeString = "symbol";
61  break;
62  case UNITS:
63  attributeString = "units";
64  break;
65  case DESCRIPTION:
66  attributeString = "description";
67  break;
68  case FORMAT_STRING:
69  attributeString = "format_string";
70  break;
71  case GROUP_NAME:
72  attributeString = "group_name";
73  break;
74  case TYPE:
75  attributeString = "type";
76  break;
77  case FIELD_LENGTH:
78  attributeString = "field_length";
79  break;
80  case DIMENSIONS:
81  attributeString = "dimensions";
82  break;
83  case ARRAY:
84  attributeString = "array";
85  break;
86  default:
87  return true;
88  }
89  std::cerr << attributeString << " not supported yet" << std::endl;
90  return false;
91  }
92  };
93  };
94 
95  struct arrayList: std::list<array> {};
96 
97  inline std::ostream& operator<<(std::ostream& out, const array& ) {
98  return out;
99  }
100 }
101 
102 namespace SDDS { namespace parser
103 {
104  namespace qi = boost::spirit::qi;
105  namespace ascii = boost::spirit::ascii;
106  namespace phx = boost::phoenix;
107 
108  template <typename Iterator>
109  struct array_parser: qi::grammar<Iterator, array(), skipper<Iterator> >
110  {
111  array_parser(error_handler<Iterator> & _error_handler);
112 
113  qi::rule<Iterator, array(), skipper<Iterator> > start;
114  qi::rule<Iterator, std::string(), skipper<Iterator> > array_name,
117  qi::rule<Iterator, long(), skipper<Iterator> > array_field,
119  qi::rule<Iterator, ast::datatype, skipper<Iterator> > array_type;
122  qi::symbols<char, ast::datatype> arraytype;
123  };
124 }}
125 #endif /* ARRAY_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
@ DESCRIPTION
Definition: array.hpp:39
@ DIMENSIONS
Definition: array.hpp:44
@ FIELD_LENGTH
Definition: array.hpp:43
@ GROUP_NAME
Definition: array.hpp:41
@ FORMAT_STRING
Definition: array.hpp:40
qi::rule< Iterator, std::string(), skipper< Iterator > > array_format
Definition: array.hpp:115
qi::rule< Iterator, array(), skipper< Iterator > > start
Definition: array.hpp:113
qi::rule< Iterator, std::string(), skipper< Iterator > > array_symbol
Definition: array.hpp:115
qi::rule< Iterator, ast::nil(), skipper< Iterator > > array_unsupported_post
Definition: array.hpp:121
qi::rule< Iterator, ast::nil(), skipper< Iterator > > array_unsupported_pre
Definition: array.hpp:120
qi::rule< Iterator, long(), skipper< Iterator > > array_dimensions
Definition: array.hpp:118
array_parser(error_handler< Iterator > &_error_handler)
Definition: array_def.hpp:30
qi::rule< Iterator, std::string(), skipper< Iterator > > array_description
Definition: array.hpp:115
qi::rule< Iterator, std::string(), skipper< Iterator > > quoted_string
Definition: array.hpp:116
qi::rule< Iterator, std::string(), skipper< Iterator > > array_units
Definition: array.hpp:115
qi::rule< Iterator, std::string(), skipper< Iterator > > array_name
Definition: array.hpp:114
qi::symbols< char, ast::datatype > arraytype
Definition: array.hpp:122
qi::rule< Iterator, std::string(), skipper< Iterator > > units
Definition: array.hpp:116
qi::rule< Iterator, std::string(), skipper< Iterator > > array_group
Definition: array.hpp:116
qi::rule< Iterator, std::string(), skipper< Iterator > > string
Definition: array.hpp:116
qi::rule< Iterator, ast::datatype, skipper< Iterator > > array_type
Definition: array.hpp:119
qi::rule< Iterator, long(), skipper< Iterator > > array_field
Definition: array.hpp:117