- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

# ofx_container_statement.cpp

Go to the documentation of this file.

    00001 /***************************************************************************
    00002          ofx_container_statement.cpp
    00003                              -------------------
    00004     copyright            : (C) 2002 by Benoit Grégoire
    00005     email                : bock@step.polymtl.ca
    00006 ***************************************************************************/
    00011 /***************************************************************************
    00012  *                                                                         *
    00013  *   This program is free software; you can redistribute it and/or modify  *
    00014  *   it under the terms of the GNU General Public License as published by  *
    00015  *   the Free Software Foundation; either version 2 of the License, or     *
    00016  *   (at your option) any later version.                                   *
    00017  *                                                                         *
    00018  ***************************************************************************/
    00019
    00020 #ifdef HAVE_CONFIG_H
    00021 #include <config.h>
    00022 #endif
    00023
    00024 #include <string>
    00025 #include "messages.hh"
    00026 #include "libofx.h"
    00027 #include "ofx_containers.hh"
    00028 #include "ofx_utilities.hh"
    00029
    00030 extern OfxMainContainer * MainContainer;
    00031
    00032 /***************************************************************************
    00033  *                    OfxStatementContainer                                *
    00034  ***************************************************************************/
    00035
    00036 OfxStatementContainer::OfxStatementContainer(LibofxContext *p_libofx_context, OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
    00037   OfxGenericContainer(p_libofx_context, para_parentcontainer, para_tag_identifier)
    00038 {
    00039   memset(&data,0,sizeof(data));
    00040   type="STATEMENT";
    00041 }
    00042 OfxStatementContainer::~OfxStatementContainer()
    00043 {
    00044 /*  while(transaction_queue.empty()!=true)
    00045     {
    00046       ofx_proc_transaction_cb(transaction_queue.front());
    00047       transaction_queue.pop();
    00048     }*/
    00049 }
    00050 void OfxStatementContainer::add_attribute(const string identifier, const string value)
    00051 {
    00052   if(identifier=="CURDEF"){
    00053     strncpy(data.currency,value.c_str(),OFX_CURRENCY_LENGTH);
    00054     data.currency_valid=true;
    00055   }
    00056   else if(identifier=="MKTGINFO"){
    00057     strncpy(data.marketing_info,value.c_str(),OFX_MARKETING_INFO_LENGTH);
    00058     data.marketing_info_valid=true;
    00059   }
    00060   else if(identifier=="DTSTART"){
    00061     data.date_start = ofxdate_to_time_t(value);
    00062     data.date_start_valid = true;
    00063   }
    00064   else if(identifier=="DTEND"){
    00065     data.date_end = ofxdate_to_time_t(value);
    00066     data.date_end_valid = true;
    00067   }
    00068   else{
    00069     OfxGenericContainer::add_attribute(identifier, value);
    00070   }
    00071 }//end OfxStatementContainer::add_attribute()
    00072
    00073 void OfxStatementContainer::add_balance(OfxBalanceContainer* ptr_balance_container)
    00074 {
    00075   if(ptr_balance_container->tag_identifier=="LEDGERBAL"){
    00076     data.ledger_balance=ptr_balance_container->amount;
    00077     data.ledger_balance_valid=ptr_balance_container->amount_valid;
    00078   }
    00079   else if(ptr_balance_container->tag_identifier=="AVAILBAL"){
    00080     data.available_balance=ptr_balance_container->amount;
    00081     data.available_balance_valid=ptr_balance_container->amount_valid;
    00082   }
    00083   else{
    00084     message_out(ERROR,"OfxStatementContainer::add_balance(): the balance has unknown tag_identifier: "+ptr_balance_container->tag_identifier);
    00085   }
    00086 }
    00087
    00088
    00089 int  OfxStatementContainer::add_to_main_tree()
    00090 {
    00091   if(MainContainer != NULL)
    00092     {
    00093       return MainContainer->add_container(this);
    00094     }
    00095   else
    00096     {
    00097       return false;
    00098     }
    00099 }
    00100
    00101 int  OfxStatementContainer::gen_event()
    00102 {
    00103   libofx_context->statementCallback(data);
    00104   return true;
    00105 }
    00106
    00107
    00108 void OfxStatementContainer::add_account(OfxAccountData * account_data)
    00109 {
    00110   if(account_data->account_id_valid==true)
    00111     {
    00112       data.account_ptr = account_data;
    00113       strncpy(data.account_id,account_data->account_id,OFX_ACCOUNT_ID_LENGTH);
    00114       data.account_id_valid = true;
    00115     }
    00116 }
    00117 /*void OfxStatementContainer::add_transaction(const OfxTransactionData transaction_data)
    00118 {
    00119   transaction_queue.push(transaction_data);
    00120 }*/