LibOFX

build/libofx-0.10.0/lib/context.cpp
1
5 /***************************************************************************
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 ***************************************************************************/
13 #include <config.h>
14 #include "context.hh"
15
16 using namespace std;
17
18
19
20 LibofxContext::LibofxContext()
21 : _current_file_type(OFX)
22 , _statusCallback(0)
23 , _accountCallback(0)
24 , _securityCallback(0)
25 , _transactionCallback(0)
26 , _statementCallback(0)
27 , _positionCallback(0)
28 , _statementData(0)
29 , _accountData(0)
30 , _transactionData(0)
31 , _securityData(0)
32 , _statusData(0)
33 , _positionData(0)
34 {
35
36 }
37
38
39
40 LibofxContext::~LibofxContext()
41 {
42 }
43
44
45
46 LibofxFileFormat LibofxContext::currentFileType() const
47 {
48 return _current_file_type;
49 }
50
51
52
53 void LibofxContext::setCurrentFileType(LibofxFileFormat t)
54 {
55 _current_file_type = t;
56 }
57
58
59
60 int LibofxContext::statementCallback(const struct OfxStatementData data)
61 {
62 if (_statementCallback)
63 return _statementCallback(data, _statementData);
64 return 0;
65 }
66
67
68
69 int LibofxContext::accountCallback(const struct OfxAccountData data)
70 {
71 if (_accountCallback)
72 return _accountCallback(data, _accountData);
73 return 0;
74 }
75
76
77
78 int LibofxContext::transactionCallback(const struct OfxTransactionData data)
79 {
80 if (_transactionCallback)
81 return _transactionCallback(data, _transactionData);
82 return 0;
83 }
84
85
86
87 int LibofxContext::securityCallback(const struct OfxSecurityData data)
88 {
89 if (_securityCallback)
90 return _securityCallback(data, _securityData);
91 return 0;
92 }
93
94
95
96 int LibofxContext::statusCallback(const struct OfxStatusData data)
97 {
98 if (_statusCallback)
99 return _statusCallback(data, _statusData);
100 return 0;
101 }
102
103 int LibofxContext::positionCallback(const struct OfxPositionData data)
104 {
105 if (_positionCallback)
106 return _positionCallback(data, _positionData);
107 return 0;
108 }
109
110
111 void LibofxContext::setStatusCallback(LibofxProcStatusCallback cb,
112 void *user_data)
113 {
114 _statusCallback = cb;
115 _statusData = user_data;
116 }
117
118
119
120 void LibofxContext::setAccountCallback(LibofxProcAccountCallback cb,
121 void *user_data)
122 {
123 _accountCallback = cb;
124 _accountData = user_data;
125 }
126
127
128
129 void LibofxContext::setSecurityCallback(LibofxProcSecurityCallback cb,
130 void *user_data)
131 {
132 _securityCallback = cb;
133 _securityData = user_data;
134 }
135
136
137
138 void LibofxContext::setTransactionCallback(LibofxProcTransactionCallback cb,
139 void *user_data)
140 {
141 _transactionCallback = cb;
142 _transactionData = user_data;
143 }
144
145
146
147 void LibofxContext::setStatementCallback(LibofxProcStatementCallback cb,
148 void *user_data)
149 {
150 _statementCallback = cb;
151 _statementData = user_data;
152 }
153
154 void LibofxContext::setPositionCallback(LibofxProcPositionCallback cb,
155 void *user_data)
156 {
157 _positionCallback = cb;
158 _positionData = user_data;
159 }
160
161
162
163
164
165
166
169 LibofxContextPtr libofx_get_new_context()
170 {
171 return new LibofxContext();
172 }
173
174 int libofx_free_context( LibofxContextPtr libofx_context_param)
175 {
176 delete (LibofxContext *)libofx_context_param;
177 return 0;
178 }
179
180
181
182 void libofx_set_dtd_dir(LibofxContextPtr libofx_context,
183 const char *s)
184 {
185 ((LibofxContext*)libofx_context)->setDtdDir(s);
186 }
187
188
189
190
191
192
193 extern "C" {
194 void ofx_set_status_cb(LibofxContextPtr ctx,
195 LibofxProcStatusCallback cb,
196 void *user_data)
197 {
198 ((LibofxContext*)ctx)->setStatusCallback(cb, user_data);
199 }
200
201
202 void ofx_set_account_cb(LibofxContextPtr ctx,
203 LibofxProcAccountCallback cb,
204 void *user_data)
205 {
206 ((LibofxContext*)ctx)->setAccountCallback(cb, user_data);
207 }
208
209
210
211 void ofx_set_security_cb(LibofxContextPtr ctx,
212 LibofxProcSecurityCallback cb,
213 void *user_data)
214 {
215 ((LibofxContext*)ctx)->setSecurityCallback(cb, user_data);
216 }
217
218
219
220 void ofx_set_transaction_cb(LibofxContextPtr ctx,
221 LibofxProcTransactionCallback cb,
222 void *user_data)
223 {
224 ((LibofxContext*)ctx)->setTransactionCallback(cb, user_data);
225 }
226
227
228
229 void ofx_set_statement_cb(LibofxContextPtr ctx,
230 LibofxProcStatementCallback cb,
231 void *user_data)
232 {
233 ((LibofxContext*)ctx)->setStatementCallback(cb, user_data);
234 }
235
236
237 void ofx_set_position_cb(LibofxContextPtr ctx,
238 LibofxProcPositionCallback cb,
239 void *user_data)
240 {
241 ((LibofxContext*)ctx)->setPositionCallback(cb, user_data);
242 }
243
244
245
246
247 }
248
249
250
251
252
253
254
255
256
257
OfxAccountData
An abstraction of an account.
Definition: inc/libofx.h:276
ofx_set_position_cb
void ofx_set_position_cb(LibofxContextPtr ctx, LibofxProcPositionCallback cb, void *user_data)
Definition: build/libofx-0.10.0/lib/context.cpp:237
OfxPositionData
An abstraction of a security position held in an account.
Definition: inc/libofx.h:1161
std
OFX
Definition: inc/libofx.h:129
LibofxContext
Definition: build/libofx-0.10.0/lib/context.hh:25
LibofxProcAccountCallback
int(* LibofxProcAccountCallback)(const struct OfxAccountData data, void *account_data)
The callback function for the OfxAccountData stucture.
Definition: inc/libofx.h:349
libofx_get_new_context
LibofxContextPtr libofx_get_new_context()
Initialise the library and return a new context.
Definition: build/libofx-0.10.0/lib/context.cpp:169
LibofxProcStatementCallback
int(* LibofxProcStatementCallback)(const struct OfxStatementData data, void *statement_data)
The callback function for the OfxStatementData stucture.
Definition: inc/libofx.h:1142
ofx_set_statement_cb
void ofx_set_statement_cb(LibofxContextPtr ctx, LibofxProcStatementCallback cb, void *user_data)
Definition: build/libofx-0.10.0/lib/context.cpp:229
ofx_set_status_cb
void ofx_set_status_cb(LibofxContextPtr ctx, LibofxProcStatusCallback cb, void *user_data)
Definition: build/libofx-0.10.0/lib/context.cpp:194
ofx_set_account_cb
void ofx_set_account_cb(LibofxContextPtr ctx, LibofxProcAccountCallback cb, void *user_data)
Definition: build/libofx-0.10.0/lib/context.cpp:202
LibofxProcTransactionCallback
int(* LibofxProcTransactionCallback)(const struct OfxTransactionData data, void *transaction_data)
The callback function for the OfxTransactionData stucture.
Definition: inc/libofx.h:1046
LibofxProcPositionCallback
int(* LibofxProcPositionCallback)(const struct OfxPositionData data, void *position_data)
The callback function for the OfxPositionData stucture.
Definition: inc/libofx.h:1270
OfxStatusData
An abstraction of an OFX STATUS element.
Definition: inc/libofx.h:214
ofx_set_security_cb
void ofx_set_security_cb(LibofxContextPtr ctx, LibofxProcSecurityCallback cb, void *user_data)
Definition: build/libofx-0.10.0/lib/context.cpp:211
OfxSecurityData
An abstraction of a security, such as a stock, mutual fund, etc.
Definition: inc/libofx.h:358
ofx_set_transaction_cb
void ofx_set_transaction_cb(LibofxContextPtr ctx, LibofxProcTransactionCallback cb, void *user_data)
Definition: build/libofx-0.10.0/lib/context.cpp:220
LibofxProcSecurityCallback
int(* LibofxProcSecurityCallback)(const struct OfxSecurityData data, void *security_data)
The callback function for the OfxSecurityData stucture.
Definition: inc/libofx.h:620
LibofxProcStatusCallback
int(* LibofxProcStatusCallback)(const struct OfxStatusData data, void *status_data)
The callback function for the OfxStatusData stucture.
Definition: inc/libofx.h:263
OfxTransactionData
An abstraction of a transaction in an account.
Definition: inc/libofx.h:682
LibofxFileFormat
LibofxFileFormat
Definition: inc/libofx.h:126
libofx_free_context
int libofx_free_context(LibofxContextPtr)
Free all ressources used by this context.
Definition: build/libofx-0.10.0/lib/context.cpp:174
OfxStatementData
An abstraction of an account statement.
Definition: inc/libofx.h:1057