PDI 1.1.0

Data exchange made easy

expression.h
1 /*******************************************************************************
2  * Copyright (C) 2015-2020 Commissariat a l'energie atomique et aux energies alternatives (CEA)
3  * Copyright (C) 2020 Institute of Bioorganic Chemistry Polish Academy of Science (PSNC)
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of CEA nor the names of its contributors may be used to
14  * endorse or promote products derived from this software without specific
15  * prior written permission.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  ******************************************************************************/
25 
26 #ifndef PDI_EXPRESSION_H_
27 #define PDI_EXPRESSION_H_
28 
29 #include <map>
30 #include <memory>
31 #include <string>
32 #include <utility>
33 #include <vector>
34 
35 #include <pdi/pdi_fwd.h>
36 #include <pdi/paraconf_wrapper.h>
37 #include <pdi/ref_any.h>
38 
39 namespace PDI {
40 
41 class PDI_EXPORT Expression
42 {
43  struct PDI_NO_EXPORT Impl;
44 
45  std::unique_ptr<Impl> m_impl;
46 
47  Expression(std::unique_ptr<Impl>);
48 
49 public:
54  Expression();
55 
60  Expression(const Expression& expr);
61 
66  Expression(Expression&& expr);
67 
75  Expression(const char* expr);
76 
84  Expression(const std::string& expr);
85 
90  Expression(long expr);
91 
96  Expression(double expr);
97 
102  Expression(PC_tree_t expr);
103 
106  ~Expression();
107 
113  Expression& operator=(const Expression& expr);
114 
120  Expression& operator=(Expression&& expr);
121 
127  Expression operator+(const Expression& expr) const;
128 
134  Expression operator*(const Expression& expr) const;
135 
141  Expression operator-(const Expression& expr) const;
142 
148  Expression operator/(const Expression& expr) const;
149 
155  Expression operator%(const Expression& expr) const;
156 
161  operator bool () const;
162 
167  long to_long(Context& ctx) const;
168 
173  double to_double(Context& ctx) const;
174 
179  std::string to_string(Context& ctx) const;
180 
186  Ref to_ref(Context& ctx) const;
187 
194  Ref to_ref(Context& ctx, const Datatype& type) const;
195 };
196 
197 } // namespace PDI
198 
199 #endif // PDI_EXPRESSION_H_
Definition: context.h:42
std::string to_string(PC_tree_t tree)
Returns the string content of a scalar node.
Definition: expression.h:41
A Datatype is a Datatype_template that accepts no argument.
Definition: datatype.h:46
A dynamically typed reference to data with automatic memory management and read/write locking semanti...
Definition: pdi_fwd.h:93
long to_long(PC_tree_t tree)
Returns the int value of a scalar node.
Definition: array_datatype.h:37
double to_double(PC_tree_t tree)
Returns the floating point value of a scalar node.