summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2007-05-01 04:36:49 +0000
committerJohn Wiegley <johnw@newartisans.com>2008-04-13 03:38:35 -0400
commite92bcf411d2e9a55969303ba3893a017152d7c18 (patch)
treee7b52d09751de39c86ede91f88a2fcf24facfb27 /src/value.cc
parent50a9caf302936ba6f61bbe05b4718f199d0d584c (diff)
downloadfork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.tar.gz
fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.tar.bz2
fork-ledger-e92bcf411d2e9a55969303ba3893a017152d7c18.zip
Started using boost::optional<T>.
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc45
1 files changed, 4 insertions, 41 deletions
diff --git a/src/value.cc b/src/value.cc
index 74a3bd8f..7956af12 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -117,10 +117,10 @@ void value_t::destroy()
((balance_pair_t *)data)->~balance_pair_t();
break;
case STRING:
- delete *(string **) data;
+ checked_delete(*(string **) data);
break;
case SEQUENCE:
- delete *(sequence_t **) data;
+ checked_delete(*(sequence_t **) data);
break;
default:
break;
@@ -1820,43 +1820,6 @@ void value_t::in_place_negate()
}
}
-void value_t::in_place_abs()
-{
- switch (type) {
- case BOOLEAN:
- break;
- case INTEGER:
- if (*((long *) data) < 0)
- *((long *) data) = - *((long *) data);
- break;
- case DATETIME:
- break;
- case AMOUNT:
- ((amount_t *) data)->abs();
- break;
- case BALANCE:
- ((balance_t *) data)->abs();
- break;
- case BALANCE_PAIR:
- ((balance_pair_t *) data)->abs();
- break;
- case STRING:
- throw_(value_error, "Cannot take the absolute value of a string");
- case XML_NODE:
- *this = (*(xml::node_t **) data)->to_value();
- in_place_abs();
- break;
- case POINTER:
- throw_(value_error, "Cannot take the absolute value of a pointer");
- case SEQUENCE:
- throw_(value_error, "Cannot take the absolute value of a sequence");
-
- default:
- assert(0);
- break;
- }
-}
-
value_t value_t::value(const moment_t& moment) const
{
switch (type) {
@@ -2188,7 +2151,7 @@ value_t value_t::cost() const
return value_t();
}
-value_t& value_t::add(const amount_t& amount, const amount_t * tcost)
+value_t& value_t::add(const amount_t& amount, const optional<amount_t>& tcost)
{
switch (type) {
case BOOLEAN:
@@ -2337,7 +2300,7 @@ value_context::value_context(const value_t& _bal,
value_context::~value_context() throw()
{
- delete bal;
+ checked_delete(bal);
}
void value_context::describe(std::ostream& out) const throw()