39 memset(&data, 0,
sizeof(data));
42 OfxPositionContainer::~OfxPositionContainer()
47 if (identifier ==
"UNIQUEID")
49 strncpy(data.unique_id, value.c_str(),
sizeof(data.unique_id));
50 data.unique_id_valid =
true;
52 else if (identifier ==
"UNIQUEIDTYPE")
54 strncpy(data.unique_id_type, value.c_str(),
sizeof(data.unique_id_type));
55 data.unique_id_type_valid =
true;
57 else if (identifier ==
"HELDINACCT")
61 data.heldinaccount_type = data.OFX_HELDINACCT_CASH;
62 data.heldinaccount_type_valid =
true;
64 else if (value ==
"MARGIN")
66 data.heldinaccount_type = data.OFX_HELDINACCT_MARGIN;
67 data.heldinaccount_type_valid =
true;
69 else if (value ==
"SHORT")
71 data.heldinaccount_type = data.OFX_HELDINACCT_SHORT;
72 data.heldinaccount_type_valid =
true;
74 else if (value ==
"OTHER")
76 data.heldinaccount_type = data.OFX_HELDINACCT_OTHER;
77 data.heldinaccount_type_valid =
true;
80 else if (identifier ==
"POSTYPE")
84 data.position_type = data.OFX_POSITION_SHORT;
85 data.position_type_valid =
true;
87 else if (value ==
"LONG")
89 data.position_type = data.OFX_POSITION_LONG;
90 data.position_type_valid =
true;
93 else if (identifier ==
"UNITS")
96 data.units_valid =
true;
98 else if (identifier ==
"UNITPRICE")
101 data.unit_price_valid =
true;
103 else if (identifier ==
"MKTVAL")
106 data.market_value_valid =
true;
108 else if (identifier ==
"DTPRICEASOF")
111 data.date_unit_price_valid =
true;
113 else if (identifier ==
"CURRATE")
116 data.currency_ratio_valid =
true;
118 else if (identifier ==
"CURSYM")
120 strncpy(data.currency, value.c_str(),
sizeof(data.currency));
121 data.currency_valid =
true;
123 else if (identifier ==
"CURRENCY")
125 data.amounts_are_foreign_currency =
false;
126 data.amounts_are_foreign_currency_valid =
true;
128 else if (identifier ==
"ORIGCURRENCY")
130 data.amounts_are_foreign_currency =
true;
131 data.amounts_are_foreign_currency_valid =
true;
133 else if (identifier ==
"MEMO")
135 strncpy(data.memo, value.c_str(),
sizeof(data.memo));
136 data.memo_valid =
true;
138 else if (identifier ==
"INV401KSOURCE")
140 if (value ==
"PRETAX")
142 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_PRETAX;
143 data.inv_401k_source_valid =
true;
145 else if (value ==
"AFTERTAX")
147 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_AFTERTAX;
148 data.inv_401k_source_valid =
true;
150 else if (value ==
"MATCH")
152 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_MATCH;
153 data.inv_401k_source_valid =
true;
155 else if (value ==
"PROFITSHARING")
157 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_PROFITSHARING;
158 data.inv_401k_source_valid =
true;
160 else if (value ==
"ROLLOVER")
162 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_ROLLOVER;
163 data.inv_401k_source_valid =
true;
165 else if (value ==
"OTHERVEST")
167 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_OTHERVEST;
168 data.inv_401k_source_valid =
true;
170 else if (value ==
"OTHERNONVEST")
172 data.inv_401k_source = data.OFX_401K_POSN_SOURCE_OTHERNONVEST;
173 data.inv_401k_source_valid =
true;
184 if (data.unique_id_valid ==
true && MainContainer != NULL)
186 data.security_data_ptr = MainContainer->find_security(data.unique_id);
187 if (data.security_data_ptr != NULL)
189 data.security_data_valid =
true;
192 libofx_context->positionCallback(data);
196 void OfxPositionContainer::add_account(
OfxAccountData * account_data)
198 if (account_data->account_id_valid ==
true)
200 data.account_ptr = account_data;
201 strncpy(data.account_id, account_data->
account_id, OFX_ACCOUNT_ID_LENGTH);
202 data.account_id_valid =
true;
208 if (MainContainer != NULL)
210 return MainContainer->add_container(
this);
void add_attribute(const string identifier, const string value)
Add data to a container object.
An abstraction of an account.
double ofxamount_to_double(const string ofxamount)
Convert OFX amount of money to double float.
A generic container for an OFX SGML element. Every container inherits from OfxGenericContainer.
char account_id[OFX_ACCOUNT_ID_LENGTH]
Various simple functions for type conversion & al.
virtual int gen_event()
Generate libofx.h events.
LibOFX internal object code.
virtual void add_attribute(const string identifier, const string value)
Add data to a container object.
time_t ofxdate_to_time_t(const string ofxdate)
Convert a C++ string containing a time in OFX format to a C time_t.
virtual int add_to_main_tree()
Add this container to the main tree.
Message IO functionality.
The root container. Created by the <OFX> OFX element or by the export functions.