1 | #ifndef __C_INTERFACE__ |
---|
2 | #define __C_INTERFACE__ |
---|
3 | |
---|
4 | #include "xmlio.hpp" |
---|
5 | |
---|
6 | using namespace XMLIOSERVER; |
---|
7 | using namespace XMLIOSERVER::XML; |
---|
8 | |
---|
9 | typedef long int XInt, XSize; // Integer |
---|
10 | typedef bool XBool; // Logical |
---|
11 | typedef void * XPtr; // Pointeur C non typé |
---|
12 | typedef char * XString; // Pointeur C non typé |
---|
13 | |
---|
14 | typedef enum |
---|
15 | { |
---|
16 | NOTYPE = 0, |
---|
17 | DTREATMENT/* UNUSED */, DATE, CALENDAR, ECONTEXT, |
---|
18 | EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, |
---|
19 | GAXIS, GDOMAIN, GFIELD, GFILE, GGRID |
---|
20 | } XDType; |
---|
21 | |
---|
22 | typedef enum |
---|
23 | { |
---|
24 | NETCDF4 = 0 |
---|
25 | } XFileType; |
---|
26 | |
---|
27 | typedef enum |
---|
28 | { D360 = 0 , ALLLEAP, NOLEAP, JULIAN, GREGORIAN } XCalendarType ; |
---|
29 | |
---|
30 | typedef struct // Référence C à une objet de la bibliothÚque. |
---|
31 | { XDType data_type; XPtr data_ptr; } XHandle; |
---|
32 | |
---|
33 | #define MAKE_STRING(var_name, str_arg, int_arg) \ |
---|
34 | std::string var_name##temp; \ |
---|
35 | var_name##temp.append (str_arg, int_arg); \ |
---|
36 | size_t d = var_name##temp.find_first_not_of(' '); \ |
---|
37 | size_t f = var_name##temp.find_last_not_of (' '); \ |
---|
38 | std::string var_name = var_name##temp.substr(d, f-d+1) |
---|
39 | |
---|
40 | #define XML_SET(type, type_var, var, long_var) \ |
---|
41 | void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, type_var var) |
---|
42 | |
---|
43 | #define XML_SET_STRING(type, var, long_var) \ |
---|
44 | void xios_xml_set_##type##_##var(XPtr const _##type, XDType _dtype, const XString _##var, XSize _##var##_len) |
---|
45 | |
---|
46 | #ifdef __cplusplus |
---|
47 | extern"C" |
---|
48 | { |
---|
49 | #endif //__cplusplus |
---|
50 | |
---|
51 | /* ******************** HANDLE INTERFACE ******************** */ |
---|
52 | void xios_handle_create (XPtr * const _ret, XDType _dtype, const XString _id, XSize _id_len); |
---|
53 | |
---|
54 | /* ******************** XML INTERFACE *********************** */ |
---|
55 | void xios_xml_parse_file (const XString _filename, XSize _filename_len); |
---|
56 | void xios_xml_parse_string(const XString _xmlcontent, XSize _xmlcontent_len); |
---|
57 | |
---|
58 | /* ******************** CONTEXT INTERFACE ******************* */ |
---|
59 | void xios_context_set_current (XPtr const _ctx, bool _wswap); |
---|
60 | void xios_context_create (XPtr * _ctx, const XString _ctx_id, XSize _ctx_id_len, XCalendarType _calType); |
---|
61 | |
---|
62 | /* ****************** XML TREE INTERFACE ******************* */ |
---|
63 | void xios_xml_tree_add(const XPtr _parent, XDType _parent_type, XPtr * _child, |
---|
64 | XDType _child_type, const XString _child_id, XSize _child_id_len); |
---|
65 | void xios_xml_tree_show(const XString _filename, XSize _filename_len); |
---|
66 | |
---|
67 | // Attributs de field ou field_group |
---|
68 | XML_SET_STRING(field, name, name); |
---|
69 | XML_SET_STRING(field, sname, standard_name); |
---|
70 | XML_SET_STRING(field, lname, long_name); |
---|
71 | XML_SET_STRING(field, unit, unit); |
---|
72 | XML_SET_STRING(field, operation, operation); |
---|
73 | |
---|
74 | void xios_xml_set_field_freq_op(XPtr const _field, XDType _dtype, |
---|
75 | double year, double month, double day, |
---|
76 | double hour, double minute, double second); |
---|
77 | |
---|
78 | XML_SET(field, int, level, level); |
---|
79 | XML_SET(field, int, prec, prec); |
---|
80 | XML_SET(field, bool, enabled, enabled); |
---|
81 | |
---|
82 | XML_SET_STRING(field, dref, domain_ref); |
---|
83 | XML_SET_STRING(field, aref, axis_ref); |
---|
84 | XML_SET_STRING(field, gref, grid_ref); |
---|
85 | XML_SET_STRING(field, zref, zoom_ref); |
---|
86 | XML_SET_STRING(field, fref, field_ref); |
---|
87 | |
---|
88 | // Attributs de file ou file_group |
---|
89 | XML_SET_STRING(file, name, name) ; |
---|
90 | XML_SET_STRING(file, description, description); |
---|
91 | void xios_xml_set_file_output_freq(XPtr const _file, XDType _dtype, |
---|
92 | double year, double month, double day, |
---|
93 | double hour, double minute, double second); |
---|
94 | |
---|
95 | XML_SET(file, int, olevel, output_level); |
---|
96 | XML_SET(file, bool, enabled, enabled); |
---|
97 | |
---|
98 | // Attributs de grid ou grid_group |
---|
99 | XML_SET_STRING(grid, name, name) ; |
---|
100 | XML_SET_STRING(grid, description, description) ; |
---|
101 | XML_SET_STRING(grid, dref, domain_ref) ; |
---|
102 | XML_SET_STRING(grid, aref, axis_ref) ; |
---|
103 | |
---|
104 | // Attribut de axis ou axis_group |
---|
105 | XML_SET_STRING(axis, name, name) ; |
---|
106 | XML_SET_STRING(axis, sname, standard_name) ; |
---|
107 | XML_SET_STRING(axis, lname, long_name) ; |
---|
108 | |
---|
109 | XML_SET_STRING(axis, unit, unit) ; |
---|
110 | |
---|
111 | void xios_xml_set_axis_value(XPtr const _file, XDType _dtype, double value[], XSize value_size); |
---|
112 | |
---|
113 | |
---|
114 | // Attribut de domain ou domain_group |
---|
115 | XML_SET_STRING(domain, name, name) ; |
---|
116 | XML_SET_STRING(domain, sname, standard_name) ; |
---|
117 | XML_SET_STRING(domain, lname, long_name) ; |
---|
118 | |
---|
119 | XML_SET(domain, int, niglo, ni_glo); |
---|
120 | XML_SET(domain, int, njglo, nj_glo); |
---|
121 | |
---|
122 | XML_SET(domain, int, ibegin, ibegin); |
---|
123 | XML_SET(domain, int, iend, iend); |
---|
124 | XML_SET(domain, int, ni, ni); |
---|
125 | |
---|
126 | XML_SET(domain, int, jbegin, jbegin); |
---|
127 | XML_SET(domain, int, jend, jend); |
---|
128 | XML_SET(domain, int, nj, nj); |
---|
129 | |
---|
130 | void xios_xml_set_domain_mask(XPtr const _domain, XDType _dtype, bool * _mask , XSize _maskXsize, XSize _maskYsize); |
---|
131 | |
---|
132 | XML_SET(domain, int, ddim, data_dim); |
---|
133 | XML_SET(domain, int, dni, data_ni); |
---|
134 | XML_SET(domain, int, dnj, data_nj); |
---|
135 | XML_SET(domain, int, dibegin, data_ibegin); |
---|
136 | XML_SET(domain, int, djbegin, data_jbegin); |
---|
137 | |
---|
138 | XML_SET(domain, int, dnindex, data_n_index); |
---|
139 | |
---|
140 | void xios_xml_set_domain_diindex(XPtr const _domain, XDType _dtype, int _diindex[], XSize _diindex_size); |
---|
141 | void xios_xml_set_domain_djindex(XPtr const _domain, XDType _dtype, int _djindex[], XSize _djindex_size); |
---|
142 | |
---|
143 | void xios_xml_set_domain_lonvalue(XPtr const _domain, XDType _dtype, double _lonvalue[], XSize _lonvalue_Xsize, XSize _lonvalue_Ysize); |
---|
144 | void xios_xml_set_domain_latvalue(XPtr const _domain, XDType _dtype, double _latvalue[], XSize _latvalue_Xsize, XSize _latvalue_Ysize); |
---|
145 | |
---|
146 | XML_SET_STRING(domain, domtype, domtype) ; |
---|
147 | |
---|
148 | /* ****************** DATA TREATMENT INTERFACE ******************* */ |
---|
149 | void xios_dtreatment_start(XPtr const _context, XFileType filetype); |
---|
150 | |
---|
151 | #ifdef __cplusplus |
---|
152 | } |
---|
153 | #endif //__cplusplus |
---|
154 | |
---|
155 | |
---|
156 | #endif //__C_INTERFACE__ |
---|