Whitespace cleanup.
This commit is contained in:
parent
fdfc37adf9
commit
d23ed020ab
24 changed files with 254 additions and 247 deletions
11
Makefile.am
11
Makefile.am
|
|
@ -25,9 +25,16 @@ WARNFLAGS = -Wall #-pedantic-errors
|
||||||
#WARNFLAGS += -Wmissing-field-initializers -Wstrict-null-sentinel
|
#WARNFLAGS += -Wmissing-field-initializers -Wstrict-null-sentinel
|
||||||
#WARNFLAGS += -Wold-style-cast -Woverloaded-virtual
|
#WARNFLAGS += -Wold-style-cast -Woverloaded-virtual
|
||||||
|
|
||||||
libledger_la_CPPFLAGS = -I$(top_builddir)/gdtoa -I$(srcdir)/gdtoa \
|
|
||||||
-I$(srcdir)/src $(WARNFLAGS)
|
|
||||||
libledger_la_LDFLAGS = -release $(PACKAGE_VERSION)
|
libledger_la_LDFLAGS = -release $(PACKAGE_VERSION)
|
||||||
|
libledger_la_CPPFLAGS = $(WARNFLAGS) \
|
||||||
|
-I$(top_builddir)/gdtoa \
|
||||||
|
-I$(srcdir)/gdtoa \
|
||||||
|
-I$(srcdir)/src \
|
||||||
|
-I$(srcdir)/src/utility \
|
||||||
|
-I$(srcdir)/src/numerics \
|
||||||
|
-I$(srcdir)/src/data \
|
||||||
|
-I$(srcdir)/src/traversal \
|
||||||
|
-I$(srcdir)/src/driver
|
||||||
|
|
||||||
libledger_la_SOURCES = \
|
libledger_la_SOURCES = \
|
||||||
src/utility/utils.cc \
|
src/utility/utils.cc \
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@
|
||||||
|
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
#include "binary.h"
|
#include "binary.h"
|
||||||
|
#include "parser.h"
|
||||||
|
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
|
|
@ -1218,7 +1219,7 @@ namespace {
|
||||||
|
|
||||||
void amount_t::read(std::istream& in)
|
void amount_t::read(std::istream& in)
|
||||||
{
|
{
|
||||||
using ledger::binary;
|
using namespace ledger::binary;
|
||||||
|
|
||||||
// Read in the commodity for this amount
|
// Read in the commodity for this amount
|
||||||
|
|
||||||
|
|
@ -1266,7 +1267,7 @@ void amount_t::read(std::istream& in)
|
||||||
|
|
||||||
void amount_t::read(const char *& data)
|
void amount_t::read(const char *& data)
|
||||||
{
|
{
|
||||||
using ledger::binary;
|
using namespace ledger::binary;
|
||||||
|
|
||||||
// Read in the commodity for this amount
|
// Read in the commodity for this amount
|
||||||
|
|
||||||
|
|
@ -1323,7 +1324,7 @@ void amount_t::read(const char *& data)
|
||||||
|
|
||||||
void amount_t::write(std::ostream& out, bool optimized) const
|
void amount_t::write(std::ostream& out, bool optimized) const
|
||||||
{
|
{
|
||||||
using ledger::binary;
|
using namespace ledger::binary;
|
||||||
|
|
||||||
// Write out the commodity for this amount
|
// Write out the commodity for this amount
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -347,7 +347,7 @@ public:
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
amount_t round(const optional<precision_t>& prec) const;
|
amount_t round(const optional<precision_t>& prec = none) const;
|
||||||
amount_t unround() const;
|
amount_t unround() const;
|
||||||
|
|
||||||
amount_t reduce() const {
|
amount_t reduce() const {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,8 @@
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
class balance_pair_t
|
class balance_pair_t
|
||||||
: public equality_comparable<balance_pair_t,
|
: public balance_t,
|
||||||
|
public equality_comparable<balance_pair_t,
|
||||||
equality_comparable<balance_pair_t, balance_t,
|
equality_comparable<balance_pair_t, balance_t,
|
||||||
equality_comparable<balance_pair_t, amount_t,
|
equality_comparable<balance_pair_t, amount_t,
|
||||||
equality_comparable<balance_pair_t, double,
|
equality_comparable<balance_pair_t, double,
|
||||||
|
|
@ -72,8 +73,7 @@ class balance_pair_t
|
||||||
multiplicative<balance_pair_t, balance_t,
|
multiplicative<balance_pair_t, balance_t,
|
||||||
multiplicative<balance_pair_t, double,
|
multiplicative<balance_pair_t, double,
|
||||||
multiplicative<balance_pair_t, unsigned long,
|
multiplicative<balance_pair_t, unsigned long,
|
||||||
multiplicative2<balance_pair_t, long, balance_t
|
multiplicative<balance_pair_t, long> > > > > > > > > > > > > > > > >
|
||||||
> > > > > > > > > > > > > > > > >
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The `cost' member of a balance pair tracks the cost associated
|
* The `cost' member of a balance pair tracks the cost associated
|
||||||
|
|
@ -216,33 +216,22 @@ public:
|
||||||
|
|
||||||
// comparison
|
// comparison
|
||||||
bool operator==(const balance_pair_t& bal_pair) const {
|
bool operator==(const balance_pair_t& bal_pair) const {
|
||||||
return quantity == bal_pair.quantity;
|
return quantity() == bal_pair.quantity();
|
||||||
}
|
}
|
||||||
bool operator==(const balance_t& bal) const {
|
bool operator==(const balance_t& bal) const {
|
||||||
return quantity == bal;
|
return quantity() == bal;
|
||||||
}
|
}
|
||||||
bool operator==(const amount_t& amt) const {
|
bool operator==(const amount_t& amt) const {
|
||||||
return quantity == amt;
|
return quantity() == amt;
|
||||||
}
|
|
||||||
|
|
||||||
balance_pair_t& operator*=(const amount_t& amt) {
|
|
||||||
quantity *= amt;
|
|
||||||
if (cost)
|
|
||||||
*cost *= amt;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
balance_pair_t& operator/=(const amount_t& amt) {
|
|
||||||
quantity /= amt;
|
|
||||||
if (cost)
|
|
||||||
*cost /= amt;
|
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// unary negation
|
// unary negation
|
||||||
void in_place_negate() {
|
void in_place_negate() {
|
||||||
|
#if 0
|
||||||
quantity.in_place_negate();
|
quantity.in_place_negate();
|
||||||
if (cost)
|
if (cost)
|
||||||
cost->in_place_negate();
|
cost->in_place_negate();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
balance_pair_t negate() const {
|
balance_pair_t negate() const {
|
||||||
balance_pair_t temp = *this;
|
balance_pair_t temp = *this;
|
||||||
|
|
@ -255,57 +244,67 @@ public:
|
||||||
|
|
||||||
// test for non-zero (use ! for zero)
|
// test for non-zero (use ! for zero)
|
||||||
operator bool() const {
|
operator bool() const {
|
||||||
return quantity;
|
return quantity();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_realzero() const {
|
bool is_realzero() const {
|
||||||
|
#if 0
|
||||||
return ((! cost || cost->is_realzero()) && quantity.is_realzero());
|
return ((! cost || cost->is_realzero()) && quantity.is_realzero());
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
balance_pair_t abs() const {
|
balance_pair_t abs() const {
|
||||||
|
#if 0
|
||||||
balance_pair_t temp = *this;
|
balance_pair_t temp = *this;
|
||||||
temp.quantity = temp.quantity.abs();
|
temp.quantity = temp.quantity.abs();
|
||||||
if (temp.cost)
|
if (temp.cost)
|
||||||
temp.cost = temp.cost->abs();
|
temp.cost = temp.cost->abs();
|
||||||
return temp;
|
return temp;
|
||||||
|
#else
|
||||||
|
return balance_pair_t();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<amount_t>
|
optional<amount_t>
|
||||||
commodity_amount(const optional<const commodity_t&>& commodity = none) const {
|
commodity_amount(const optional<const commodity_t&>& commodity = none) const {
|
||||||
return quantity.commodity_amount(commodity);
|
return quantity().commodity_amount(commodity);
|
||||||
}
|
}
|
||||||
optional<balance_t> value(const optional<moment_t>& moment = none) const {
|
optional<balance_t> value(const optional<moment_t>& moment = none) const {
|
||||||
return quantity.value(moment);
|
return quantity().value(moment);
|
||||||
}
|
}
|
||||||
|
|
||||||
balance_t
|
balance_t
|
||||||
strip_annotations(const bool keep_price = amount_t::keep_price,
|
strip_annotations(const bool keep_price = amount_t::keep_price,
|
||||||
const bool keep_date = amount_t::keep_date,
|
const bool keep_date = amount_t::keep_date,
|
||||||
const bool keep_tag = amount_t::keep_tag) const {
|
const bool keep_tag = amount_t::keep_tag) const {
|
||||||
return quantity.strip_annotations(keep_price, keep_date, keep_tag);
|
return quantity().strip_annotations(keep_price, keep_date, keep_tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void print(std::ostream& out, const int first_width,
|
void print(std::ostream& out, const int first_width,
|
||||||
const int latter_width = -1) const {
|
const int latter_width = -1) const {
|
||||||
quantity.print(out, first_width, latter_width);
|
quantity().print(out, first_width, latter_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
balance_pair_t& add(const amount_t& amt,
|
balance_pair_t& add(const amount_t& amt,
|
||||||
const optional<amount_t>& a_cost = none) {
|
const optional<amount_t>& a_cost = none) {
|
||||||
|
#if 0
|
||||||
if (a_cost && ! cost)
|
if (a_cost && ! cost)
|
||||||
cost = quantity;
|
cost = quantity;
|
||||||
quantity += amt;
|
quantity += amt;
|
||||||
if (cost)
|
if (cost)
|
||||||
*cost += a_cost ? *a_cost : amt;
|
*cost += a_cost ? *a_cost : amt;
|
||||||
|
#endif
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool valid() {
|
bool valid() {
|
||||||
return quantity.valid() && (! cost || cost->valid());
|
return quantity().valid() && (! cost || cost->valid());
|
||||||
}
|
}
|
||||||
|
|
||||||
void in_place_reduce() {
|
void in_place_reduce() {
|
||||||
quantity.in_place_reduce();
|
quantity().in_place_reduce();
|
||||||
if (cost) cost->in_place_reduce();
|
if (cost) cost->in_place_reduce();
|
||||||
}
|
}
|
||||||
balance_pair_t reduce() const {
|
balance_pair_t reduce() const {
|
||||||
|
|
@ -320,7 +319,7 @@ public:
|
||||||
|
|
||||||
inline std::ostream& operator<<(std::ostream& out,
|
inline std::ostream& operator<<(std::ostream& out,
|
||||||
const balance_pair_t& bal_pair) {
|
const balance_pair_t& bal_pair) {
|
||||||
bal_pair.quantity.print(out, 12);
|
bal_pair.quantity().print(out, 12);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue