OmniSciDB  4201147b46
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ExpressionParser.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /*
18  * @file ExpressionParser.h
19  * @brief General Expression Parser using muparserx
20  *
21  */
22 
23 #pragma once
24 
25 #include <memory>
26 #include <string>
27 
28 namespace mup {
29 class ParserX;
30 }
31 
32 namespace import_export {
33 
35  public:
37 
38  void setExpression(const std::string& expression);
39 
40  void setStringConstant(const std::string& name, const std::string& value);
41  void setIntConstant(const std::string& name, const int value);
42 
43  std::string evalAsString();
44  int evalAsInt();
45  double evalAsDouble();
46  bool evalAsBool();
47 
48  private:
49  struct ParserDeleter {
50  void operator()(mup::ParserX* parser);
51  };
52  std::unique_ptr<mup::ParserX, ParserDeleter> parser_;
53 };
54 
55 } // namespace import_export
void setIntConstant(const std::string &name, const int value)
std::unique_ptr< mup::ParserX, ParserDeleter > parser_
void setStringConstant(const std::string &name, const std::string &value)
string name
Definition: setup.in.py:72
void setExpression(const std::string &expression)