summaryrefslogtreecommitdiff
path: root/src/value.cc
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2011-10-06 22:07:01 -0700
committerCraig Earls <enderw88@gmail.com>2011-10-06 22:07:01 -0700
commitb400d65be082165f44e769605aa6a78133cf6d9a (patch)
tree27b18ee35a5c4f60a10cf4f626e15ac30276040b /src/value.cc
parente9ccb012c2c5ffe0e9f4916ee859bda95d9d4248 (diff)
parentf0791bbd7297e737d9e13d0b0bb21473b173b2a7 (diff)
downloadfork-ledger-b400d65be082165f44e769605aa6a78133cf6d9a.tar.gz
fork-ledger-b400d65be082165f44e769605aa6a78133cf6d9a.tar.bz2
fork-ledger-b400d65be082165f44e769605aa6a78133cf6d9a.zip
Merge remote branch 'upstream/next' into next
Diffstat (limited to 'src/value.cc')
-rw-r--r--src/value.cc26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/value.cc b/src/value.cc
index c34792b2..1ecfffe7 100644
--- a/src/value.cc
+++ b/src/value.cc
@@ -333,7 +333,7 @@ value_t& value_t::operator+=(const value_t& val)
for (; i != end(); i++, j++)
*i += *j;
} else {
- add_error_context(_("While adding %1 to %2:") << *this << val);
+ add_error_context(_("While adding %1 to %2:") << val << *this);
throw_(value_error, _("Cannot add sequences of different lengths"));
}
} else {
@@ -446,7 +446,7 @@ value_t& value_t::operator+=(const value_t& val)
break;
}
- add_error_context(_("While adding %1 to %2:") << *this << val);
+ add_error_context(_("While adding %1 to %2:") << val << *this);
throw_(value_error, _("Cannot add %1 to %2") << val.label() << label());
return *this;
@@ -465,7 +465,7 @@ value_t& value_t::operator-=(const value_t& val)
for (; i != end(); i++, j++)
*i -= *j;
} else {
- add_error_context(_("While subtracting %1 to %2:") << *this << val);
+ add_error_context(_("While subtracting %1 from %2:") << val << *this);
throw_(value_error, _("Cannot subtract sequences of different lengths"));
}
} else {
@@ -588,7 +588,7 @@ value_t& value_t::operator-=(const value_t& val)
break;
}
- add_error_context(_("While subtracting %1 from %2:") << *this << val);
+ add_error_context(_("While subtracting %1 from %2:") << val << *this);
throw_(value_error, _("Cannot subtract %1 from %2") << val.label() << label());
return *this;
@@ -670,7 +670,7 @@ value_t& value_t::operator*=(const value_t& val)
break;
}
- add_error_context(_("While multiplying %1 with %2:") << *this << val);
+ add_error_context(_("While multiplying %1 with %2:") << val << *this);
throw_(value_error, _("Cannot multiply %1 with %2") << label() << val.label());
return *this;
@@ -748,7 +748,7 @@ value_t& value_t::operator/=(const value_t& val)
break;
}
- add_error_context(_("While dividing %1 by %2:") << *this << val);
+ add_error_context(_("While dividing %1 by %2:") << val << *this);
throw_(value_error, _("Cannot divide %1 by %2") << label() << val.label());
return *this;
@@ -760,7 +760,7 @@ bool value_t::is_equal_to(const value_t& val) const
switch (type()) {
case VOID:
return val.type() == VOID;
-
+
case BOOLEAN:
if (val.is_boolean())
return as_boolean() == val.as_boolean();
@@ -834,7 +834,7 @@ bool value_t::is_equal_to(const value_t& val) const
break;
}
- add_error_context(_("While comparing equality of %1 to %2:") << *this << val);
+ add_error_context(_("While comparing equality of %1 and %2:") << *this << val);
throw_(value_error, _("Cannot compare %1 to %2") << label() << val.label());
return *this;
@@ -1263,8 +1263,8 @@ void value_t::in_place_cast(type_t cast_type)
}
add_error_context(_("While converting %1:") << *this);
- throw_(value_error,
- _("Cannot convert %1 to %2") << label() << label(cast_type));
+ throw_(value_error, _("Cannot convert %1 to %2")
+ << label() << label(cast_type));
}
void value_t::in_place_negate()
@@ -1721,11 +1721,13 @@ string value_t::label(optional<type_t> the_type) const
return _("<invalid>");
}
-void value_t::print(std::ostream& out,
+void value_t::print(std::ostream& _out,
const int first_width,
const int latter_width,
const uint_least8_t flags) const
{
+ std::ostringstream out;
+
if (first_width > 0 &&
(! is_amount() || as_amount().is_zero()) &&
! is_balance() && ! is_string()) {
@@ -1821,6 +1823,8 @@ void value_t::print(std::ostream& out,
add_error_context(_("While printing %1:") << *this);
throw_(value_error, _("Cannot print %1") << label());
}
+
+ _out << out.str();
}
void value_t::dump(std::ostream& out, const bool relaxed) const