diff options
author | John Wiegley <johnw@newartisans.com> | 2009-02-07 21:55:38 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2009-02-07 21:55:38 -0400 |
commit | 591ebbf1bd7fefc76e28a86efce5339034a1dbd5 (patch) | |
tree | 82429fc9ebd458dc69098471584bb7cc48e5de69 /src/commodity.cc | |
parent | fb5fc0e3f9c3a5dab25455bfe33956f7c893eaa9 (diff) | |
download | fork-ledger-591ebbf1bd7fefc76e28a86efce5339034a1dbd5.tar.gz fork-ledger-591ebbf1bd7fefc76e28a86efce5339034a1dbd5.tar.bz2 fork-ledger-591ebbf1bd7fefc76e28a86efce5339034a1dbd5.zip |
Moved parse_commodity_price into commodity_pool_t.
Diffstat (limited to 'src/commodity.cc')
-rw-r--r-- | src/commodity.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/commodity.cc b/src/commodity.cc index cfbab246..4b73b41f 100644 --- a/src/commodity.cc +++ b/src/commodity.cc @@ -988,4 +988,21 @@ commodity_t * commodity_pool_t::find_or_create(commodity_t& comm, return create(comm, details, name); } +void commodity_pool_t::parse_commodity_price(const char * optarg) +{ + char * equals = std::strchr(optarg, '='); + if (! equals) + return; + + optarg = skip_ws(optarg); + while (equals > optarg && std::isspace(*(equals - 1))) + equals--; + + std::string symbol(optarg, 0, equals - optarg); + amount_t price(equals + 1); + + if (commodity_t * commodity = commodity_t::find_or_create(symbol)) + commodity->add_price(datetime_t::now, price); +} + } // namespace ledger |