LibOFX: context.cpp Source File

LibOFX

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