diff options
author | John Wiegley <johnw@newartisans.com> | 2008-07-26 23:55:06 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-07-26 23:55:06 -0400 |
commit | 9b7725ee181617b2e0ea13189837b0724ab964b8 (patch) | |
tree | c69dd5865a7c6e32ff824984a914924450ca4947 /amount.cc | |
parent | 7848dbd7f76e580760b585eba3f67cf3a4ebaed9 (diff) | |
download | fork-ledger-9b7725ee181617b2e0ea13189837b0724ab964b8.tar.gz fork-ledger-9b7725ee181617b2e0ea13189837b0724ab964b8.tar.bz2 fork-ledger-9b7725ee181617b2e0ea13189837b0724ab964b8.zip |
Added a simple optimization to the way amount strings are parsed.
Diffstat (limited to 'amount.cc')
-rw-r--r-- | amount.cc | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1062,7 +1062,7 @@ void parse_annotations(std::istream& in, amount_t& price, << " tag " << tag); } -void amount_t::parse(std::istream& in, unsigned char flags) +bool amount_t::parse(std::istream& in, unsigned char flags) { // The possible syntax for an amount is: // @@ -1114,8 +1114,12 @@ void amount_t::parse(std::istream& in, unsigned char flags) } } - if (quant.empty()) - throw new amount_error("No quantity specified for amount"); + if (quant.empty()) { + if (flags & AMOUNT_PARSE_SOFT_FAIL) + return false; + else + throw new amount_error("No quantity specified for amount"); + } _init(); @@ -1205,6 +1209,8 @@ void amount_t::parse(std::istream& in, unsigned char flags) if (! (flags & AMOUNT_PARSE_NO_REDUCE)) reduce(); + + return true; } void amount_t::reduce() @@ -1215,7 +1221,7 @@ void amount_t::reduce() } } -void amount_t::parse(const std::string& str, unsigned char flags) +bool amount_t::parse(const std::string& str, unsigned char flags) { std::istringstream stream(str); parse(stream, flags); |