diff options
Diffstat (limited to 'src/value.cc')
-rw-r--r-- | src/value.cc | 26 |
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 |