LibOFX: ofx_container_statement.cpp Source File

LibOFX

- 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                : benoitg@coeus.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   {
    00054     strncpy(data.currency, value.c_str(), OFX_CURRENCY_LENGTH);
    00055     data.currency_valid = true;
    00056   }
    00057   else if (identifier == "MKTGINFO")
    00058   {
    00059     strncpy(data.marketing_info, value.c_str(), OFX_MARKETING_INFO_LENGTH);
    00060     data.marketing_info_valid = true;
    00061   }
    00062   else if (identifier == "DTSTART")
    00063   {
    00064     data.date_start = ofxdate_to_time_t(value);
    00065     data.date_start_valid = true;
    00066   }
    00067   else if (identifier == "DTEND")
    00068   {
    00069     data.date_end = ofxdate_to_time_t(value);
    00070     data.date_end_valid = true;
    00071   }
    00072   else
    00073   {
    00074     OfxGenericContainer::add_attribute(identifier, value);
    00075   }
    00076 }//end OfxStatementContainer::add_attribute()
    00077
    00078 void OfxStatementContainer::add_balance(OfxBalanceContainer* ptr_balance_container)
    00079 {
    00080   if (ptr_balance_container->tag_identifier == "LEDGERBAL")
    00081   {
    00082     data.ledger_balance = ptr_balance_container->amount;
    00083     data.ledger_balance_valid = ptr_balance_container->amount_valid;
    00084   }
    00085   else if (ptr_balance_container->tag_identifier == "AVAILBAL")
    00086   {
    00087     data.available_balance = ptr_balance_container->amount;
    00088     data.available_balance_valid = ptr_balance_container->amount_valid;
    00089   }
    00090   else
    00091   {
    00092     message_out(ERROR, "OfxStatementContainer::add_balance(): the balance has unknown tag_identifier: " + ptr_balance_container->tag_identifier);
    00093   }
    00094 }
    00095
    00096
    00097 int  OfxStatementContainer::add_to_main_tree()
    00098 {
    00099   if (MainContainer != NULL)
    00100   {
    00101     return MainContainer->add_container(this);
    00102   }
    00103   else
    00104   {
    00105     return false;
    00106   }
    00107 }
    00108
    00109 int  OfxStatementContainer::gen_event()
    00110 {
    00111   libofx_context->statementCallback(data);
    00112   return true;
    00113 }
    00114
    00115
    00116 void OfxStatementContainer::add_account(OfxAccountData * account_data)
    00117 {
    00118   if (account_data->account_id_valid == true)
    00119   {
    00120     data.account_ptr = account_data;
    00121     strncpy(data.account_id, account_data->account_id, OFX_ACCOUNT_ID_LENGTH);
    00122     data.account_id_valid = true;
    00123   }
    00124 }
    00125 /*void OfxStatementContainer::add_transaction(const OfxTransactionData transaction_data)
    00126 {
    00127   transaction_queue.push(transaction_data);
    00128 }*/