libwreport  3.5
python.h
1 #ifndef WREPORT_PYTHON_H
2 #define WREPORT_PYTHON_H
3 
4 #include <Python.h>
5 #include <wreport/varinfo.h>
6 #include <wreport/var.h>
7 
8 namespace wreport {
9 struct Vartable;
10 }
11 
12 extern "C" {
13 
15 typedef struct {
16  PyObject_HEAD
17  wreport::Varinfo info;
18 } wrpy_Varinfo;
19 
21 PyAPI_DATA(PyTypeObject) wrpy_Varinfo_Type;
22 
24 #define wrpy_Varinfo_Check(ob) \
25  (Py_TYPE(ob) == &wrpy_Varinfo_Type || \
26  PyType_IsSubtype(Py_TYPE(ob), &wrpy_Varinfo_Type))
27 
28 
30 typedef struct {
31  PyObject_HEAD
32  const wreport::Vartable* table;
34 
36 PyAPI_DATA(PyTypeObject) wrpy_Vartable_Type;
37 
39 #define wrpy_Vartable_Check(ob) \
40  (Py_TYPE(ob) == &wrpy_Vartable_Type || \
41  PyType_IsSubtype(Py_TYPE(ob), &wrpy_Vartable_Type))
42 
43 
45 typedef struct {
46  PyObject_HEAD
47  wreport::Var var;
48 } wrpy_Var;
49 
51 PyAPI_DATA(PyTypeObject) wrpy_Var_Type;
52 
54 #define wrpy_Var_Check(ob) \
55  (Py_TYPE(ob) == &wrpy_Var_Type || \
56  PyType_IsSubtype(Py_TYPE(ob), &wrpy_Var_Type))
57 
58 
69 struct wrpy_c_api {
71  wrpy_Var* (*var_create)(const wreport::Varinfo&);
72 
74  wrpy_Var* (*var_create_i)(const wreport::Varinfo&, int);
75 
77  wrpy_Var* (*var_create_d)(const wreport::Varinfo&, double);
78 
80  wrpy_Var* (*var_create_c)(const wreport::Varinfo&, const char*);
81 
83  wrpy_Var* (*var_create_s)(const wreport::Varinfo&, const std::string&);
84 
86  wrpy_Var* (*var_create_copy)(const wreport::Var&);
87 
89  PyObject* (*var_value_to_python)(const wreport::Var&);
90 
92  int (*var_value_from_python)(PyObject* o, wreport::Var&);
93 
95  wrpy_Varinfo* (*varinfo_create)(wreport::Varinfo);
96 
98  wrpy_Vartable* (*vartable_create)(const wreport::Vartable*);
99 };
100 
101 }
102 
103 #endif
wreport.Var python object
Definition: python.h:45
A physical variable.
Definition: var.h:23
int(* var_value_from_python)(PyObject *o, wreport::Var &)
Set the value of a variable from a Python object (borrowed reference)
Definition: python.h:92
Information about a variable.
Definition: varinfo.h:135
wreport.Vartable python object
Definition: python.h:30
String functions.
Definition: benchmark.h:13
Implement fast access to information about WMO variables.
Holds a variable information table.
Definition: vartable.h:30
wreport.Varinfo python object
Definition: python.h:15
const _Varinfo * Varinfo
Varinfo reference.
Definition: varinfo.h:281
C++ functions exported by the wreport python bindings, to be used by other C++ bindings.
Definition: python.h:69