00001 
00002 
00003 
00004 
00005 
00006 
00011 
00012 
00013 
00014 
00015 
00016 
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 
00034 
00035 
00036 
00037 OfxSecurityContainer::OfxSecurityContainer(OfxGenericContainer *para_parentcontainer, string para_tag_identifier):
00038   OfxGenericContainer(para_parentcontainer, para_tag_identifier)
00039 {
00040   memset(&data,0,sizeof(data));
00041   type="SECURITY";
00042 }
00043 OfxSecurityContainer::~OfxSecurityContainer()
00044 {
00045 }
00046 void OfxSecurityContainer::add_attribute(const string identifier, const string value)
00047 {
00048   if(identifier=="UNIQUEID"){
00049     strncpy(data.unique_id,value.c_str(), sizeof(data.unique_id));
00050     data.unique_id_valid = true;
00051   }
00052   else if(identifier=="UNIQUEIDTYPE"){
00053     strncpy(data.unique_id_type,value.c_str(), sizeof(data.unique_id_type));
00054     data.unique_id_type_valid = true;
00055   }
00056   else if(identifier=="SECNAME"){
00057     strncpy(data.secname,value.c_str(), sizeof(data.secname));
00058     data.secname_valid = true;
00059   }
00060   else if(identifier=="TICKER"){
00061     strncpy(data.ticker,value.c_str(), sizeof(data.ticker));
00062     data.ticker_valid = true;
00063   }
00064   else if(identifier=="UNITPRICE"){
00065     data.unitprice=ofxamount_to_double(value);
00066     data.unitprice_valid = true;
00067   }
00068   else if(identifier=="DTASOF"){
00069     data.date_unitprice = ofxdate_to_time_t(value);
00070     data.date_unitprice_valid = true;
00071   }
00072   else if(identifier=="CURDEF"){
00073     strncpy(data.currency,value.c_str(),OFX_CURRENCY_LENGTH);
00074     data.currency_valid=true;
00075   }
00076   else if(identifier=="MEMO" || identifier=="MEMO2"){
00077     strncpy(data.memo,value.c_str(), sizeof(data.memo));
00078     data.memo_valid = true;
00079  }
00080   else{
00081     
00082     OfxGenericContainer::add_attribute(identifier, value);
00083   }
00084 }
00085 int  OfxSecurityContainer::gen_event()
00086 {
00087   ofx_proc_security_cb(data);
00088   return true;
00089 }
00090 
00091 int  OfxSecurityContainer::add_to_main_tree()
00092 {
00093   if(MainContainer != NULL)
00094     {
00095       return MainContainer->add_container(this);
00096     }
00097   else
00098     {
00099       return false;
00100     }
00101 }
00102