build/libofx-0.10.0/lib/context.cpp
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <config.h>
#include "context.hh"
using namespace std;
LibofxContext::LibofxContext()
: _current_file_type(OFX)
, _statusCallback(0)
, _accountCallback(0)
, _securityCallback(0)
, _transactionCallback(0)
, _statementCallback(0)
, _positionCallback(0)
, _statementData(0)
, _accountData(0)
, _transactionData(0)
, _securityData(0)
, _statusData(0)
, _positionData(0)
{
}
LibofxContext::~LibofxContext()
{
}
LibofxFileFormat LibofxContext::currentFileType() const
{
return _current_file_type;
}
void LibofxContext::setCurrentFileType(LibofxFileFormat t)
{
_current_file_type = t;
}
int LibofxContext::statementCallback(const struct OfxStatementData data)
{
if (_statementCallback)
return _statementCallback(data, _statementData);
return 0;
}
int LibofxContext::accountCallback(const struct OfxAccountData data)
{
if (_accountCallback)
return _accountCallback(data, _accountData);
return 0;
}
int LibofxContext::transactionCallback(const struct OfxTransactionData data)
{
if (_transactionCallback)
return _transactionCallback(data, _transactionData);
return 0;
}
int LibofxContext::securityCallback(const struct OfxSecurityData data)
{
if (_securityCallback)
return _securityCallback(data, _securityData);
return 0;
}
int LibofxContext::statusCallback(const struct OfxStatusData data)
{
if (_statusCallback)
return _statusCallback(data, _statusData);
return 0;
}
int LibofxContext::positionCallback(const struct OfxPositionData data)
{
if (_positionCallback)
return _positionCallback(data, _positionData);
return 0;
}
void LibofxContext::setStatusCallback(LibofxProcStatusCallback cb,
void *user_data)
{
_statusCallback = cb;
_statusData = user_data;
}
void LibofxContext::setAccountCallback(LibofxProcAccountCallback cb,
void *user_data)
{
_accountCallback = cb;
_accountData = user_data;
}
void LibofxContext::setSecurityCallback(LibofxProcSecurityCallback cb,
void *user_data)
{
_securityCallback = cb;
_securityData = user_data;
}
void LibofxContext::setTransactionCallback(LibofxProcTransactionCallback cb,
void *user_data)
{
_transactionCallback = cb;
_transactionData = user_data;
}
void LibofxContext::setStatementCallback(LibofxProcStatementCallback cb,
void *user_data)
{
_statementCallback = cb;
_statementData = user_data;
}
void LibofxContext::setPositionCallback(LibofxProcPositionCallback cb,
void *user_data)
{
_positionCallback = cb;
_positionData = user_data;
}
LibofxContextPtr libofx_get_new_context()
{
return new LibofxContext();
}
int libofx_free_context( LibofxContextPtr libofx_context_param)
{
delete (LibofxContext *)libofx_context_param;
return 0;
}
void libofx_set_dtd_dir(LibofxContextPtr libofx_context,
const char *s)
{
((LibofxContext*)libofx_context)->setDtdDir(s);
}
extern "C" {
void ofx_set_status_cb(LibofxContextPtr ctx,
LibofxProcStatusCallback cb,
void *user_data)
{
((LibofxContext*)ctx)->setStatusCallback(cb, user_data);
}
void ofx_set_account_cb(LibofxContextPtr ctx,
LibofxProcAccountCallback cb,
void *user_data)
{
((LibofxContext*)ctx)->setAccountCallback(cb, user_data);
}
void ofx_set_security_cb(LibofxContextPtr ctx,
LibofxProcSecurityCallback cb,
void *user_data)
{
((LibofxContext*)ctx)->setSecurityCallback(cb, user_data);
}
void ofx_set_transaction_cb(LibofxContextPtr ctx,
LibofxProcTransactionCallback cb,
void *user_data)
{
((LibofxContext*)ctx)->setTransactionCallback(cb, user_data);
}
void ofx_set_statement_cb(LibofxContextPtr ctx,
LibofxProcStatementCallback cb,
void *user_data)
{
((LibofxContext*)ctx)->setStatementCallback(cb, user_data);
}
void ofx_set_position_cb(LibofxContextPtr ctx,
LibofxProcPositionCallback cb,
void *user_data)
{
((LibofxContext*)ctx)->setPositionCallback(cb, user_data);
}
}
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