summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2012-03-09 03:19:38 -0600
committerJohn Wiegley <johnw@newartisans.com>2012-03-09 03:25:53 -0600
commitca8f702a1b18f2f114cd580abe59f03fb85e4803 (patch)
tree2f4e820ca842dbc9c39461acd767c2baad4f3236
parent628875b33c4f1cd202091c9347ef0176f8b688fa (diff)
downloadfork-ledger-ca8f702a1b18f2f114cd580abe59f03fb85e4803.tar.gz
fork-ledger-ca8f702a1b18f2f114cd580abe59f03fb85e4803.tar.bz2
fork-ledger-ca8f702a1b18f2f114cd580abe59f03fb85e4803.zip
Added amount_t::commodity_ptr()
-rw-r--r--src/amount.cc9
-rw-r--r--src/amount.h1
-rw-r--r--test/regress/25A099C9.test12
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