1 | #include "c_interface.hpp" |
---|
2 | |
---|
3 | /* ********************************************************** */ |
---|
4 | /* CONVERSION FUNCTION */ |
---|
5 | /* ********************************************************** */ |
---|
6 | |
---|
7 | static inline std::string stringXtoStd(XString _str) |
---|
8 | { |
---|
9 | char * const temp = new char[_str.len+1](); |
---|
10 | memset(temp, '\0', _str.len+1); |
---|
11 | memcpy(temp, _str.str, _str.len); |
---|
12 | std::string _retstr(temp); |
---|
13 | size_t d = _retstr.find_first_not_of(' '); |
---|
14 | size_t f = _retstr.find_last_not_of (' '); |
---|
15 | |
---|
16 | delete[] temp; |
---|
17 | return (_retstr.substr(d, f-d+1)); |
---|
18 | } |
---|
19 | |
---|
20 | static inline XString stringXtoStd(const std::string& _str) |
---|
21 | { |
---|
22 | XString _retstr = {new char[_str.size()](), _str.size()}; |
---|
23 | memcpy(_retstr.str, _str.c_str(), _str.size()); |
---|
24 | return (_retstr); |
---|
25 | } |
---|
26 | |
---|
27 | /* ********************************************************** */ |
---|
28 | /* HANDLE INTERFACE */ |
---|
29 | /* ********************************************************** */ |
---|
30 | |
---|
31 | void xios_handle_create_(XHandle * _ret, const XDType * const _dtype, const XString * const _id) |
---|
32 | { |
---|
33 | try { |
---|
34 | switch(*_dtype) |
---|
35 | { |
---|
36 | /*ECONTEXT, |
---|
37 | EAXIS, EDOMAIN, EFIELD, EFILE, EGRID, |
---|
38 | GAXIS, GDOMAIN, GFIELD, GFILE, GGRID*/ |
---|
39 | case (ECONTEXT): |
---|
40 | //if (Context::) |
---|
41 | break; |
---|
42 | |
---|
43 | default : |
---|
44 | break; |
---|
45 | }; |
---|
46 | } catch(const Exception &exc) |
---|
47 | { ERROR(exc.displayText()); } |
---|
48 | } |
---|
49 | |
---|
50 | void xios_handle_verify_(XBool * _ret, const XHandle * const _hd) |
---|
51 | { |
---|
52 | try { |
---|
53 | |
---|
54 | } catch(const Exception &exc) |
---|
55 | { ERROR(exc.displayText()); } |
---|
56 | } |
---|
57 | |
---|
58 | void xios_handle_getType_(XDType * _ret, const XHandle * const _hd) |
---|
59 | { |
---|
60 | try { |
---|
61 | |
---|
62 | } catch(const Exception &exc) |
---|
63 | { ERROR(exc.displayText()); } |
---|
64 | } |
---|
65 | |
---|
66 | void xios_handle_isType_(XBool * _ret, const XHandle * const _hd, const XDType * const _dtype) |
---|
67 | { |
---|
68 | try { |
---|
69 | |
---|
70 | } catch(const Exception &exc) |
---|
71 | { ERROR(exc.displayText()); } |
---|
72 | } |
---|
73 | |
---|
74 | void xios_handle_isId_(XBool * _ret, const XHandle * const _hd, const XString * const _id) |
---|
75 | { |
---|
76 | try { |
---|
77 | |
---|
78 | } catch(const Exception &exc) |
---|
79 | { ERROR(exc.displayText()); } |
---|
80 | } |
---|
81 | |
---|
82 | void xios_handle_isGroup_(XBool * _ret, const XHandle * const _hd) |
---|
83 | { |
---|
84 | try { |
---|
85 | |
---|
86 | } catch(const Exception &exc) |
---|
87 | { ERROR(exc.displayText()); } |
---|
88 | } |
---|
89 | |
---|
90 | void xios_handle_isElement_(XBool * _ret, const XHandle * const _hd) |
---|
91 | { |
---|
92 | try { |
---|
93 | |
---|
94 | } catch(const Exception &exc) |
---|
95 | { ERROR(exc.displayText()); } |
---|
96 | } |
---|
97 | |
---|
98 | /* ********************************************************** */ |
---|
99 | /* XML INTERFACE */ |
---|
100 | /* ********************************************************** */ |
---|
101 | |
---|
102 | void xios_xml_parse_file_(XString _filename) |
---|
103 | { |
---|
104 | try { |
---|
105 | std::string __filename = stringXtoStd(_filename); |
---|
106 | std::ifstream __istr( __filename.c_str() , std::ifstream::in ); |
---|
107 | |
---|
108 | // On commence la lecture du flux de donnée xml. |
---|
109 | XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); |
---|
110 | |
---|
111 | // On parse le fichier xml noeud par noeud |
---|
112 | // (ie on construit dynamiquement notre arbre d'objets). |
---|
113 | XMLParser::Parse(node); |
---|
114 | |
---|
115 | } catch(const Exception &exc) |
---|
116 | { ERROR(exc.displayText()); } |
---|
117 | } |
---|
118 | |
---|
119 | void xios_xml_parse_string_(XString _xmlcontent) |
---|
120 | { |
---|
121 | try { |
---|
122 | std::string __xmlcontent = stringXtoStd(_xmlcontent); |
---|
123 | std::istringstream __istr(__xmlcontent); |
---|
124 | |
---|
125 | // On commence la lecture du flux de donnée xml. |
---|
126 | XMLNode node = XMLNode::CreateNode(__istr, Context::GetRootName()); |
---|
127 | |
---|
128 | // On parse le fichier xml noeud par noeud |
---|
129 | // (ie on construit dynamiquement notre arbre d'objets). |
---|
130 | XMLParser::Parse(node); |
---|
131 | |
---|
132 | } catch(const Exception &exc) |
---|
133 | { ERROR(exc.displayText()); } |
---|
134 | } |
---|
135 | |
---|
136 | /* ********************************************************** */ |
---|
137 | /* MAIN ENTRY */ |
---|
138 | /* ********************************************************** */ |
---|
139 | |
---|
140 | void main_c_(void) // voué à disparaître |
---|
141 | { /* Ne rien faire de plus */ } |
---|