PDI 0.6.1

Data exchange made easy

expression.h
1 /*******************************************************************************
2  * Copyright (C) 2015-2019 Commissariat a l'energie atomique et aux energies alternatives (CEA)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of CEA nor the names of its contributors may be used to
13  * endorse or promote products derived from this software without specific
14  * prior written permission.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  ******************************************************************************/
24 
25 #ifndef PDI_EXPRESSION_H_
26 #define PDI_EXPRESSION_H_
27 
28 #include <memory>
29 #include <string>
30 
31 #include <pdi/pdi_fwd.h>
32 #include <pdi/ref_any.h>
33 
34 namespace PDI {
35 
36 class PDI_EXPORT Expression
37 {
38  struct PDI_NO_EXPORT Impl;
39 
40  friend struct Impl;
41 
42  std::unique_ptr<Impl> m_impl;
43 
44  Expression(std::unique_ptr<Impl>);
45 
46 public:
51  Expression();
52 
57  Expression(const Expression& expr);
58 
63  Expression(Expression&& expr);
64 
72  Expression(const char* expr);
73 
81  Expression(const std::string& expr);
82 
87  Expression(long expr);
88 
93  Expression(double expr);
94 
97  ~Expression();
98 
104  Expression& operator=(const Expression& expr);
105 
111  Expression& operator=(Expression&& expr);
112 
117  operator bool () const;
118 
123  long to_long(Context& ctx) const;
124 
129  double to_double(Context& ctx) const;
130 
135  std::string to_string(Context& ctx) const;
136 
141  Ref to_ref(Context& ctx) const;
142 
143 };
144 
145 } // namespace PDI
146 
147 #endif // PDI_EXPRESSION_H_
Definition: context.h:41
std::string to_string(PC_tree_t tree)
Returns the string content of a scalar node.
Definition: expression.h:36
A dynamically typed reference to data with automatic memory management and read/write locking semanti...
Definition: pdi_fwd.h:77
long to_long(PC_tree_t tree)
Returns the int value of a scalar node.
Definition: array_datatype.h:33
double to_double(PC_tree_t tree)
Returns the floating point value of a scalar node.