PDI 1.4.3

the PDI data interface

paraconf_wrapper.h
1 /*******************************************************************************
2  * Copyright (C) 2015-2021 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 
29 #ifndef PDI_PARACONF_WRAPPER_H_
30 #define PDI_PARACONF_WRAPPER_H_
31 
32 #include <functional>
33 #include <string>
34 
35 #include <paraconf.h>
36 
37 #include <pdi/pdi_fwd.h>
38 
39 
40 namespace PDI {
41 
45 struct PDI_EXPORT Paraconf_wrapper {
46 
47  PC_errhandler_t m_handler;
48 
49 
51 
53 
54 };
55 
67 int PDI_EXPORT len(PC_tree_t tree);
68 
81 int PDI_EXPORT len(PC_tree_t tree, int dflt);
82 
90 long PDI_EXPORT to_long(PC_tree_t tree);
91 
100 long PDI_EXPORT to_long(PC_tree_t tree, long dflt);
101 
109 double PDI_EXPORT to_double(PC_tree_t tree);
110 
119 double PDI_EXPORT to_double(PC_tree_t tree, double dflt);
120 
128 std::string PDI_EXPORT to_string(PC_tree_t tree);
129 
138 std::string PDI_EXPORT to_string(PC_tree_t tree, const std::string& dflt);
139 
147 bool PDI_EXPORT to_bool(PC_tree_t tree);
148 
157 bool PDI_EXPORT to_bool(PC_tree_t tree, bool dflt);
158 
159 
165 bool PDI_EXPORT is_list(PC_tree_t tree);
166 
172 bool PDI_EXPORT is_map(PC_tree_t tree);
173 
179 bool PDI_EXPORT is_scalar(PC_tree_t tree);
180 
186 void PDI_EXPORT each(PC_tree_t tree, std::function<void(PC_tree_t)> operation);
187 
194 void PDI_EXPORT opt_each(PC_tree_t tree, std::function<void(PC_tree_t)> operation);
195 
201 void PDI_EXPORT each(PC_tree_t tree, std::function<void (PC_tree_t,PC_tree_t)> operation);
202 
209 void PDI_EXPORT each_in_omap(PC_tree_t tree, std::function<void (PC_tree_t,PC_tree_t)> operation);
210 
211 } // namespace PDI
212 
213 #endif // PDI_PARACONF_WRAPPER_H_
void each_in_omap(PC_tree_t tree, std::function< void(PC_tree_t, PC_tree_t)> operation)
Iterates and apply the provided function to all elements of a PC ordered mapping. ...
std::string to_string(PC_tree_t tree)
Returns the string content of a scalar node.
bool is_map(PC_tree_t tree)
Checks if the tree is a map.
void each(PC_tree_t tree, std::function< void(PC_tree_t)> operation)
Iterates and apply the provided function to all elements of a PC list.
void opt_each(PC_tree_t tree, std::function< void(PC_tree_t)> operation)
Iterates and apply the provided function to all elements of a PC list or directly to the provided ele...
bool is_scalar(PC_tree_t tree)
Checks if the tree is a scalar.
bool is_list(PC_tree_t tree)
Checks if the tree is a list.
int len(PC_tree_t tree)
Returns the length of a node.
long to_long(PC_tree_t tree)
Returns the int value of a scalar node.
Automatically installs a paraconf error-handler that ignores errors and uninstalls it on destruction...
Definition: paraconf_wrapper.h:45
bool to_bool(PC_tree_t tree)
Returns the boolean 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.
PC_errhandler_t m_handler
Definition: paraconf_wrapper.h:47