1 #line 2 "src/Dbo/Commodities/Commodities.cpp"
5 #include "../Glb/Core.h"
7 #include "../../3rd/RapidXML/rapidxml.hpp"
23 buffer =
new char[size];
55 Wt::Dbo::Transaction t(
GCW::app()-> gnucashew_session() );
63 catch( std::exception & e )
65 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << e.what() << std::endl;
87 std::vector< Commodity_t > retVal;
94 inFile.open( wApp-> docRoot() +
"/iso-4217-currencies.xml" );
99 inFile.seekg( 0, std::ios::end );
100 std::streampos length = inFile.tellg();
101 inFile.seekg( 0, std::ios::beg );
114 DynBuf db(((
int)length)+10000);
115 inFile.read( db.buffer, length );
118 db.buffer[length] = 0;
124 rapidxml::xml_document<> doc;
127 doc.parse<0>( db.buffer );
129 catch( std::exception & err )
131 std::cout << __FILE__ <<
":" << __LINE__ <<
" " << err.what() << std::endl;
135 auto _processCurrency = [&]( rapidxml::xml_node<> * topNode )
137 for(
auto node = topNode-> first_node(); node; node = node-> next_sibling() )
141 node-> first_attribute(
"isocode" )-> value(),
142 node-> first_attribute(
"fullname" )-> value(),
143 node-> first_attribute(
"unitname" )-> value(),
144 node-> first_attribute(
"partname" )-> value(),
145 node-> first_attribute(
"namespace" )-> value(),
146 node-> first_attribute(
"exchange-code" )-> value(),
147 node-> first_attribute(
"parts-per-unit" )-> value(),
148 node-> first_attribute(
"smallest-fraction" )-> value(),
149 node-> first_attribute(
"local-symbol" )-> value()
152 retVal.push_back( commodity );
158 for(
auto node = doc.first_node(); node; node = node-> next_sibling() )
160 if( std::string(node->
name()) ==
"currencylist" )
161 _processCurrency( node );
const Wt::WFormModel::Field name
const Wt::WFormModel::Field cusip
const Wt::WFormModel::Field fullname
const Wt::WFormModel::Field nameSpace
const Wt::WFormModel::Field guid
const Wt::WFormModel::Field fraction
const Wt::WFormModel::Field mnemonic
const Wt::WFormModel::Field quote_source
const Wt::WFormModel::Field quote_tz
const Wt::WFormModel::Field quote_flag
auto byGuid(const std::string &_guid) -> Item::Ptr
Load Account by GUID.
auto getIso4217Commodities() -> std::vector< Commodity_t >
Get Commodities.
auto load(const std::string &_guid) -> Item::Ptr
Load Account by GUID.