UDQASTNode.hpp
Go to the documentation of this file.
1/*
2 Copyright 2019 Equinor ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef UDQASTNODE_HPP
21#define UDQASTNODE_HPP
22
23#include <string>
24#include <set>
25#include <vector>
26#include <memory>
27
31
32
33
34namespace Opm {
35
37public:
39 explicit UDQASTNode(UDQTokenType type_arg);
40 explicit UDQASTNode(double scalar_value);
41 UDQASTNode(UDQTokenType type_arg, const std::string& func_name, const UDQASTNode& arg);
42 UDQASTNode(UDQTokenType type_arg, const std::string& func_name, const UDQASTNode& left, const UDQASTNode& right);
43 UDQASTNode(UDQTokenType type_arg, const std::string& func_name);
44 UDQASTNode(UDQTokenType type_arg, const std::string& string_value, const std::vector<std::string>& selector);
45
47
48 UDQSet eval(UDQVarType eval_target, const UDQContext& context) const;
49
50 bool valid() const;
52 std::set<UDQTokenType> func_tokens() const;
53 void update_type(const UDQASTNode& arg);
54 void set_left(const UDQASTNode& arg);
55 void set_right(const UDQASTNode& arg);
58
59 bool operator==(const UDQASTNode& data) const;
60
61 template<class Serializer>
62 void serializeOp(Serializer& serializer)
63 {
64 serializer(var_type);
65 serializer(type);
66 serializer(string_value);
67 serializer(selector);
68 serializer(scalar_value);
69 serializer(left);
70 serializer(right);
71 }
72
73private:
74 UDQTokenType type;
75 void func_tokens(std::set<UDQTokenType>& tokens) const;
76
77 std::string string_value;
78 std::vector<std::string> selector;
79 double scalar_value;
80 std::shared_ptr<UDQASTNode> left;
81 std::shared_ptr<UDQASTNode> right;
82};
83
84}
85
86#endif
const char *const string
Definition: cJSON.h:170
Definition: Serializer.hpp:38
Definition: UDQASTNode.hpp:36
void set_left(const UDQASTNode &arg)
UDQASTNode(UDQTokenType type_arg, const std::string &func_name, const UDQASTNode &arg)
UDQASTNode(double scalar_value)
UDQASTNode(UDQTokenType type_arg, const std::string &func_name, const UDQASTNode &left, const UDQASTNode &right)
UDQASTNode(UDQTokenType type_arg, const std::string &string_value, const std::vector< std::string > &selector)
std::set< UDQTokenType > func_tokens() const
void update_type(const UDQASTNode &arg)
bool valid() const
UDQASTNode * get_left() const
static UDQASTNode serializeObject()
bool operator==(const UDQASTNode &data) const
UDQASTNode(UDQTokenType type_arg, const std::string &func_name)
UDQASTNode(UDQTokenType type_arg)
void serializeOp(Serializer &serializer)
Definition: UDQASTNode.hpp:62
UDQSet eval(UDQVarType eval_target, const UDQContext &context) const
UDQVarType var_type
Definition: UDQASTNode.hpp:51
UDQASTNode * get_right() const
void set_right(const UDQASTNode &arg)
Definition: UDQContext.hpp:35
Definition: UDQSet.hpp:60
Definition: A.hpp:4
UDQVarType
Definition: UDQEnums.hpp:59
UDQTokenType
Definition: UDQEnums.hpp:74
static std::string data()
Definition: exprtk.hpp:40022