From ca8f702a1b18f2f114cd580abe59f03fb85e4803 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Fri, 9 Mar 2012 03:19:38 -0600 Subject: Added amount_t::commodity_ptr() --- src/amount.cc | 9 +++++++-- src/amount.h | 1 + test/regress/25A099C9.test | 12 ++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/amount.cc b/src/amount.cc index c80ca14e..d1aa1655 100644 --- a/src/amount.cc +++ b/src/amount.cc @@ -867,10 +867,15 @@ bool amount_t::fits_in_long() const return mpfr_fits_slong_p(tempf, GMP_RNDN); } -commodity_t& amount_t::commodity() const +commodity_t * amount_t::commodity_ptr() const { return (has_commodity() ? - *commodity_ : *commodity_pool_t::current_pool->null_commodity); + commodity_ : commodity_pool_t::current_pool->null_commodity); +} + +commodity_t& amount_t::commodity() const +{ + return *commodity_ptr(); } bool amount_t::has_commodity() const diff --git a/src/amount.h b/src/amount.h index 09256b5d..7bf4fe51 100644 --- a/src/amount.h +++ b/src/amount.h @@ -533,6 +533,7 @@ public: number() returns a commodity-less version of an amount. This is useful for accessing just the numeric portion of an amount. */ + commodity_t * commodity_ptr() const; commodity_t& commodity() const; bool has_commodity() const; diff --git a/test/regress/25A099C9.test b/test/regress/25A099C9.test index 48b6814e..c43deb21 100644 --- a/test/regress/25A099C9.test +++ b/test/regress/25A099C9.test @@ -2,16 +2,16 @@ test -f $sourcepath/src/amount.h reg -> 7 __ERROR__ While parsing file "$sourcepath/src/amount.h", line 66: Error: No quantity specified for amount -While parsing file "$sourcepath/src/amount.h", line 731: +While parsing file "$sourcepath/src/amount.h", line 732: Error: Invalid date/time: line amount_t amoun -While parsing file "$sourcepath/src/amount.h", line 737: +While parsing file "$sourcepath/src/amount.h", line 738: Error: Invalid date/time: line string amount_ -While parsing file "$sourcepath/src/amount.h", line 743: +While parsing file "$sourcepath/src/amount.h", line 744: Error: Invalid date/time: line string amount_ -While parsing file "$sourcepath/src/amount.h", line 749: +While parsing file "$sourcepath/src/amount.h", line 750: Error: Invalid date/time: line string amount_ -While parsing file "$sourcepath/src/amount.h", line 755: +While parsing file "$sourcepath/src/amount.h", line 756: Error: Invalid date/time: line std::ostream& -While parsing file "$sourcepath/src/amount.h", line 762: +While parsing file "$sourcepath/src/amount.h", line 763: Error: Invalid date/time: line std::istream& end test -- cgit v1.2.3