LibOFX: context.cpp Source File

LibOFX

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files

- File List
- Globals

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