OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
ast.hpp
Go to the documentation of this file.
1 //
2 // Namespace ast
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 AST_HPP_
18 #define AST_HPP_
19 
20 #include <boost/variant.hpp>
21 #include <boost/spirit/include/qi.hpp>
22 
23 #include <string>
24 #include <vector>
25 
26 namespace SDDS {
27  namespace ast {
28  enum datatype { FLOAT
31  , LONG
33  , STRING };
34 
35  enum datamode { ASCII
36  , BINARY};
37 
40 
41  struct nil {};
42 
43  typedef boost::variant<float,
44  double,
45  short,
46  long,
47  char,
48  std::string> variant_t;
49 
50  typedef std::vector<variant_t> columnData_t;
51 
52  inline
54  switch(type) {
55  case FLOAT:
56  return "float";
57  case DOUBLE:
58  return "double";
59  case SHORT:
60  return "short";
61  case LONG:
62  return "long";
63  case CHARACTER:
64  return "char";
65  case STRING:
66  return "string";
67  default:
68  return "unknown";
69  }
70  }
71 
72  }
73 
74  namespace parser {
75  namespace qi = boost::spirit::qi;
76 
77  template <typename Iterator, typename Skipper>
78  struct string: qi::grammar<Iterator, std::string(), Skipper >
79  {
80  string();
81 
82  boost::spirit::qi::rule<Iterator, std::string(), Skipper> start;
83  };
84 
85  template <typename Iterator, typename Skipper>
86  struct qstring: qi::grammar<Iterator, std::string(), Skipper >
87  {
88  qstring();
89 
90  boost::spirit::qi::rule<Iterator, std::string(), Skipper> start;
91  };
92 }
93 }
94 
95 #endif // AST_HPP_
boost::function< boost::tuple< double, bool >arguments_t)> type
Definition: function.hpp:21
Definition: array.hpp:33
std::string getDataTypeString(datatype type)
Definition: ast.hpp:53
endianess
Definition: ast.hpp:38
@ BIGENDIAN
Definition: ast.hpp:38
@ LITTLEENDIAN
Definition: ast.hpp:39
datamode
Definition: ast.hpp:35
@ ASCII
Definition: ast.hpp:35
@ BINARY
Definition: ast.hpp:36
std::vector< variant_t > columnData_t
Definition: ast.hpp:50
datatype
Definition: ast.hpp:28
@ STRING
Definition: ast.hpp:33
@ DOUBLE
Definition: ast.hpp:29
@ LONG
Definition: ast.hpp:31
@ FLOAT
Definition: ast.hpp:28
@ CHARACTER
Definition: ast.hpp:32
@ SHORT
Definition: ast.hpp:30
boost::variant< float, double, short, long, char, std::string > variant_t
Definition: ast.hpp:48
boost::spirit::qi::rule< Iterator, std::string(), Skipper > start
Definition: ast.hpp:82
boost::spirit::qi::rule< Iterator, std::string(), Skipper > start
Definition: ast.hpp:90