39 memset(&data, 0,
sizeof(data));
42 OfxPositionContainer::~OfxPositionContainer()
47 if (identifier ==
"UNIQUEID")
51 else if (identifier ==
"UNIQUEIDTYPE")
55 else if (identifier ==
"HELDINACCT")
59 ASSIGN(data.heldinaccount_type, data.OFX_HELDINACCT_CASH);
61 else if (value ==
"MARGIN")
63 ASSIGN(data.heldinaccount_type, data.OFX_HELDINACCT_MARGIN);
65 else if (value ==
"SHORT")
67 ASSIGN(data.heldinaccount_type, data.OFX_HELDINACCT_SHORT);
69 else if (value ==
"OTHER")
71 ASSIGN(data.heldinaccount_type, data.OFX_HELDINACCT_OTHER);
74 else if (identifier ==
"POSTYPE")
78 ASSIGN(data.position_type, data.OFX_POSITION_SHORT);
80 else if (value ==
"LONG")
82 ASSIGN(data.position_type, data.OFX_POSITION_LONG);
85 else if (identifier ==
"UNITS")
89 else if (identifier ==
"UNITPRICE")
93 else if (identifier ==
"MKTVAL")
97 else if (identifier ==
"DTPRICEASOF")
101 else if (identifier ==
"CURRATE")
105 else if (identifier ==
"CURSYM")
109 else if (identifier ==
"CURRENCY")
111 ASSIGN(data.amounts_are_foreign_currency,
false);
113 else if (identifier ==
"ORIGCURRENCY")
115 ASSIGN(data.amounts_are_foreign_currency,
true);
117 else if (identifier ==
"MEMO")
121 else if (identifier ==
"INV401KSOURCE")
123 if (value ==
"PRETAX")
125 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_PRETAX);
127 else if (value ==
"AFTERTAX")
129 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_AFTERTAX);
131 else if (value ==
"MATCH")
133 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_MATCH);
135 else if (value ==
"PROFITSHARING")
137 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_PROFITSHARING);
139 else if (value ==
"ROLLOVER")
141 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_ROLLOVER);
143 else if (value ==
"OTHERVEST")
145 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_OTHERVEST);
147 else if (value ==
"OTHERNONVEST")
149 ASSIGN(data.inv_401k_source, data.OFX_401K_POSN_SOURCE_OTHERNONVEST);
160 if (data.unique_id_valid ==
true && MainContainer != NULL)
162 data.security_data_ptr = MainContainer->find_security(data.unique_id);
163 if (data.security_data_ptr != NULL)
165 data.security_data_valid =
true;
168 libofx_context->positionCallback(data);
172 void OfxPositionContainer::add_account(OfxAccountData * account_data)
174 if (account_data->account_id_valid ==
true)
176 data.account_ptr = account_data;
177 ASSIGN_STRNCPY(data.account_id, std::string(account_data->account_id));
183 if (MainContainer != NULL)
185 return MainContainer->add_container(
this);
time_t ofxdate_to_time_t(const std::string &ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
virtual void add_attribute(const std::string identifier, const std::string value)
Add data to a container object.
virtual int gen_event()
Generate libofx.h events.
virtual int add_to_main_tree()
Add this container to the main tree.
double ofxamount_to_double(const std::string ofxamount)
Convert OFX amount of money to double float.
Various simple functions for type conversion & al.
#define ASSIGN_STRNCPY(DEST, VALUE)
LibOFX internal object code.
Message IO functionality.
void add_attribute(const std::string identifier, const std::string value)
Add data to a container object.
The root container. Created by the <OFX> OFX element or by the export functions.
#define ASSIGN(DEST, VALUE)