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 \
|
||||||
|
|
|
||||||
122
configure.in
122
configure.in
|
|
@ -55,31 +55,31 @@ AC_CACHE_CHECK(
|
||||||
[AC_LANG_PUSH(C++)
|
[AC_LANG_PUSH(C++)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <sys/types.h>
|
[[#include <sys/types.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>]],
|
#include <stdio.h>]],
|
||||||
[[int status, pfd[2];
|
[[int status, pfd[2];
|
||||||
status = pipe(pfd);
|
status = pipe(pfd);
|
||||||
status = fork();
|
status = fork();
|
||||||
if (status < 0) {
|
if (status < 0) {
|
||||||
;
|
;
|
||||||
} else if (status == 0) {
|
} else if (status == 0) {
|
||||||
char *arg0;
|
char *arg0;
|
||||||
|
|
||||||
status = dup2(pfd[0], STDIN_FILENO);
|
status = dup2(pfd[0], STDIN_FILENO);
|
||||||
|
|
||||||
close(pfd[1]);
|
close(pfd[1]);
|
||||||
close(pfd[0]);
|
close(pfd[0]);
|
||||||
|
|
||||||
execlp("", arg0, (char *)0);
|
execlp("", arg0, (char *)0);
|
||||||
perror("execl");
|
perror("execl");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
close(pfd[0]);
|
close(pfd[0]);
|
||||||
}]])],
|
}]])],
|
||||||
[pipes_avail=true],
|
[pipes_avail=true],
|
||||||
[pipes_avail=false])
|
[pipes_avail=false])
|
||||||
AC_LANG_POP])
|
AC_LANG_POP])
|
||||||
|
|
@ -119,26 +119,26 @@ AC_CACHE_CHECK(
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <boost/date_time/posix_time/posix_time.hpp>
|
[[#include <boost/date_time/posix_time/posix_time.hpp>
|
||||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||||
#include <boost/date_time/local_time_adjustor.hpp>
|
#include <boost/date_time/local_time_adjustor.hpp>
|
||||||
#include <boost/date_time/time_duration.hpp>
|
#include <boost/date_time/time_duration.hpp>
|
||||||
|
|
||||||
using namespace boost::posix_time;
|
using namespace boost::posix_time;
|
||||||
using namespace boost::date_time;
|
using namespace boost::date_time;
|
||||||
|
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
inline ptime time_to_system_local(const ptime& when) {
|
inline ptime time_to_system_local(const ptime& when) {
|
||||||
struct std::tm tm_gmt = to_tm(when);
|
struct std::tm tm_gmt = to_tm(when);
|
||||||
return from_time_t(mktime(&tm_gmt));
|
return from_time_t(mktime(&tm_gmt));
|
||||||
}]],
|
}]],
|
||||||
[[ptime t10 = ptime(boost::gregorian::from_string("2007-01-15"),
|
[[ptime t10 = ptime(boost::gregorian::from_string("2007-01-15"),
|
||||||
ptime::time_duration_type());
|
ptime::time_duration_type());
|
||||||
|
|
||||||
ptime t12 = time_to_system_local(t10);
|
ptime t12 = time_to_system_local(t10);
|
||||||
|
|
||||||
return t10 != t12;]])],
|
return t10 != t12;]])],
|
||||||
[boost_date_time_cpplib_avail=true],
|
[boost_date_time_cpplib_avail=true],
|
||||||
[boost_date_time_cpplib_avail=false])
|
[boost_date_time_cpplib_avail=false])
|
||||||
AC_LANG_POP
|
AC_LANG_POP
|
||||||
|
|
@ -159,8 +159,8 @@ AC_CACHE_CHECK(
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <boost/filesystem/path.hpp>]],
|
[[#include <boost/filesystem/path.hpp>]],
|
||||||
[[boost::filesystem::path this_path("Hello");]])],
|
[[boost::filesystem::path this_path("Hello");]])],
|
||||||
[boost_filesystem_cpplib_avail=true],
|
[boost_filesystem_cpplib_avail=true],
|
||||||
[boost_filesystem_cpplib_avail=false])
|
[boost_filesystem_cpplib_avail=false])
|
||||||
AC_LANG_POP
|
AC_LANG_POP
|
||||||
|
|
@ -233,8 +233,8 @@ if [test x$ofx = xtrue ]; then
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <libofx.h>]],
|
[[#include <libofx.h>]],
|
||||||
[[LibofxContextPtr libofx_context = libofx_get_new_context();]])],
|
[[LibofxContextPtr libofx_context = libofx_get_new_context();]])],
|
||||||
[libofx_avail=true],
|
[libofx_avail=true],
|
||||||
[libofx_avail=false])
|
[libofx_avail=false])
|
||||||
AC_LANG_POP
|
AC_LANG_POP
|
||||||
|
|
@ -271,16 +271,16 @@ if [test x$python = xtrue ]; then
|
||||||
LIBS="-lboost_python$BOOST_SUFFIX -lpython$PYTHON_VERSION $LIBS"
|
LIBS="-lboost_python$BOOST_SUFFIX -lpython$PYTHON_VERSION $LIBS"
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <boost/python.hpp>
|
[[#include <boost/python.hpp>
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
class foo {};
|
class foo {};
|
||||||
BOOST_PYTHON_MODULE(samp) {
|
BOOST_PYTHON_MODULE(samp) {
|
||||||
class_< foo > ("foo") ;
|
class_< foo > ("foo") ;
|
||||||
}]],
|
}]],
|
||||||
[[return 0]])],
|
[[return 0]])],
|
||||||
[boost_python_cpplib_avail=true],
|
[boost_python_cpplib_avail=true],
|
||||||
[boost_python_cpplib_avail=false])
|
[boost_python_cpplib_avail=false])
|
||||||
AC_LANG_POP
|
AC_LANG_POP
|
||||||
LIBS=$boost_python_save_libs])
|
LIBS=$boost_python_save_libs])
|
||||||
|
|
||||||
|
|
@ -306,16 +306,16 @@ AC_CACHE_CHECK(
|
||||||
AC_LANG_PUSH(C++)
|
AC_LANG_PUSH(C++)
|
||||||
AC_LINK_IFELSE(
|
AC_LINK_IFELSE(
|
||||||
[AC_LANG_PROGRAM(
|
[AC_LANG_PROGRAM(
|
||||||
[[#include <cppunit/CompilerOutputter.h>
|
[[#include <cppunit/CompilerOutputter.h>
|
||||||
#include <cppunit/TestResult.h>
|
#include <cppunit/TestResult.h>
|
||||||
#include <cppunit/TestResultCollector.h>
|
#include <cppunit/TestResultCollector.h>
|
||||||
#include <cppunit/TestRunner.h>
|
#include <cppunit/TestRunner.h>
|
||||||
#include <cppunit/TextTestProgressListener.h>
|
#include <cppunit/TextTestProgressListener.h>
|
||||||
#include <cppunit/BriefTestProgressListener.h>
|
#include <cppunit/BriefTestProgressListener.h>
|
||||||
#include <cppunit/XmlOutputter.h>
|
#include <cppunit/XmlOutputter.h>
|
||||||
#include <cppunit/extensions/TestFactoryRegistry.h>]],
|
#include <cppunit/extensions/TestFactoryRegistry.h>]],
|
||||||
[[CPPUNIT_NS::TestResult controller;
|
[[CPPUNIT_NS::TestResult controller;
|
||||||
CPPUNIT_NS::TestResultCollector result;]])],
|
CPPUNIT_NS::TestResultCollector result;]])],
|
||||||
[cppunit_avail=true],
|
[cppunit_avail=true],
|
||||||
[cppunit_avail=false])
|
[cppunit_avail=false])
|
||||||
AC_LANG_POP
|
AC_LANG_POP
|
||||||
|
|
|
||||||
|
|
@ -358,7 +358,7 @@ bool run_hooks(std::list<T>& list, Data& item, bool post) {
|
||||||
typedef std::list<entry_t *> entries_list;
|
typedef std::list<entry_t *> entries_list;
|
||||||
typedef std::list<auto_entry_t *> auto_entries_list;
|
typedef std::list<auto_entry_t *> auto_entries_list;
|
||||||
typedef std::list<period_entry_t *> period_entries_list;
|
typedef std::list<period_entry_t *> period_entries_list;
|
||||||
typedef std::list<path> path_list;
|
typedef std::list<path> path_list;
|
||||||
typedef std::list<string> strings_list;
|
typedef std::list<string> strings_list;
|
||||||
|
|
||||||
class journal_t
|
class journal_t
|
||||||
|
|
|
||||||
|
|
@ -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 {
|
||||||
|
|
|
||||||
|
|
@ -60,19 +60,19 @@ DECLARE_EXCEPTION(balance_error);
|
||||||
*/
|
*/
|
||||||
class balance_t
|
class balance_t
|
||||||
: public equality_comparable<balance_t,
|
: public equality_comparable<balance_t,
|
||||||
equality_comparable<balance_t, amount_t,
|
equality_comparable<balance_t, amount_t,
|
||||||
equality_comparable<balance_t, double,
|
equality_comparable<balance_t, double,
|
||||||
equality_comparable<balance_t, unsigned long,
|
equality_comparable<balance_t, unsigned long,
|
||||||
equality_comparable<balance_t, long,
|
equality_comparable<balance_t, long,
|
||||||
additive<balance_t,
|
additive<balance_t,
|
||||||
additive<balance_t, amount_t,
|
additive<balance_t, amount_t,
|
||||||
additive<balance_t, double,
|
additive<balance_t, double,
|
||||||
additive<balance_t, unsigned long,
|
additive<balance_t, unsigned long,
|
||||||
additive<balance_t, long,
|
additive<balance_t, long,
|
||||||
multiplicative<balance_t, amount_t,
|
multiplicative<balance_t, amount_t,
|
||||||
multiplicative<balance_t, double,
|
multiplicative<balance_t, double,
|
||||||
multiplicative<balance_t, unsigned long,
|
multiplicative<balance_t, unsigned long,
|
||||||
multiplicative<balance_t, long> > > > > > > > > > > > > >
|
multiplicative<balance_t, long> > > > > > > > > > > > > >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::map<const commodity_t *, amount_t> amounts_map;
|
typedef std::map<const commodity_t *, amount_t> amounts_map;
|
||||||
|
|
|
||||||
|
|
@ -56,24 +56,24 @@
|
||||||
namespace ledger {
|
namespace ledger {
|
||||||
|
|
||||||
class balance_pair_t
|
class balance_pair_t
|
||||||
: public equality_comparable<balance_pair_t,
|
: public balance_t,
|
||||||
equality_comparable<balance_pair_t, balance_t,
|
public equality_comparable<balance_pair_t,
|
||||||
equality_comparable<balance_pair_t, amount_t,
|
equality_comparable<balance_pair_t, balance_t,
|
||||||
equality_comparable<balance_pair_t, double,
|
equality_comparable<balance_pair_t, amount_t,
|
||||||
equality_comparable<balance_pair_t, unsigned long,
|
equality_comparable<balance_pair_t, double,
|
||||||
equality_comparable<balance_pair_t, long,
|
equality_comparable<balance_pair_t, unsigned long,
|
||||||
additive<balance_pair_t,
|
equality_comparable<balance_pair_t, long,
|
||||||
additive<balance_pair_t, balance_t,
|
additive<balance_pair_t,
|
||||||
additive<balance_pair_t, amount_t,
|
additive<balance_pair_t, balance_t,
|
||||||
additive<balance_pair_t, double,
|
additive<balance_pair_t, amount_t,
|
||||||
additive<balance_pair_t, unsigned long,
|
additive<balance_pair_t, double,
|
||||||
additive<balance_pair_t, long,
|
additive<balance_pair_t, unsigned long,
|
||||||
multiplicative<balance_pair_t, amount_t,
|
additive<balance_pair_t, long,
|
||||||
multiplicative<balance_pair_t, balance_t,
|
multiplicative<balance_pair_t, amount_t,
|
||||||
multiplicative<balance_pair_t, double,
|
multiplicative<balance_pair_t, balance_t,
|
||||||
multiplicative<balance_pair_t, unsigned long,
|
multiplicative<balance_pair_t, double,
|
||||||
multiplicative2<balance_pair_t, long, balance_t
|
multiplicative<balance_pair_t, unsigned long,
|
||||||
> > > > > > > > > > > > > > > > >
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -256,7 +256,7 @@ inline std::ostream& operator<<(std::ostream& out, const annotation_t& details)
|
||||||
class annotated_commodity_t
|
class annotated_commodity_t
|
||||||
: public commodity_t,
|
: public commodity_t,
|
||||||
public equality_comparable<annotated_commodity_t,
|
public equality_comparable<annotated_commodity_t,
|
||||||
equality_comparable2<annotated_commodity_t, commodity_t,
|
equality_comparable2<annotated_commodity_t, commodity_t,
|
||||||
noncopyable> >
|
noncopyable> >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,12 @@ namespace xml {
|
||||||
|
|
||||||
class value_t
|
class value_t
|
||||||
: public ordered_field_operators<value_t,
|
: public ordered_field_operators<value_t,
|
||||||
ordered_field_operators<value_t, balance_pair_t,
|
ordered_field_operators<value_t, balance_pair_t,
|
||||||
ordered_field_operators<value_t, balance_t,
|
ordered_field_operators<value_t, balance_t,
|
||||||
ordered_field_operators<value_t, amount_t,
|
ordered_field_operators<value_t, amount_t,
|
||||||
ordered_field_operators<value_t, double,
|
ordered_field_operators<value_t, double,
|
||||||
ordered_field_operators<value_t, unsigned long,
|
ordered_field_operators<value_t, unsigned long,
|
||||||
ordered_field_operators<value_t, long> > > > > > >
|
ordered_field_operators<value_t, long> > > > > > >
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<value_t> sequence_t;
|
typedef std::vector<value_t> sequence_t;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ void export_commodity()
|
||||||
scope().attr("COMMODITY_STYLE_BUILTIN") = COMMODITY_STYLE_BUILTIN;
|
scope().attr("COMMODITY_STYLE_BUILTIN") = COMMODITY_STYLE_BUILTIN;
|
||||||
|
|
||||||
class_< commodity_t, bases<>,
|
class_< commodity_t, bases<>,
|
||||||
commodity_t, boost::noncopyable > ("commodity", no_init)
|
commodity_t, boost::noncopyable > ("commodity", no_init)
|
||||||
.def(self == self)
|
.def(self == self)
|
||||||
|
|
||||||
.def("drop_flags", &commodity_t::drop_flags)
|
.def("drop_flags", &commodity_t::drop_flags)
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,7 @@ struct register_optional_to_python : public boost::noncopyable
|
||||||
{
|
{
|
||||||
return boost::python::incref
|
return boost::python::incref
|
||||||
(value ? boost::python::to_python_value<T>()(*value) :
|
(value ? boost::python::to_python_value<T>()(*value) :
|
||||||
boost::python::detail::none());
|
boost::python::detail::none());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -145,11 +145,11 @@ struct to_py_tuple{
|
||||||
typedef mpl::int_< tuples::length< TTuple >::value > length_type;
|
typedef mpl::int_< tuples::length< TTuple >::value > length_type;
|
||||||
|
|
||||||
static PyObject* convert(const TTuple& c_tuple){
|
static PyObject* convert(const TTuple& c_tuple){
|
||||||
list values;
|
list values;
|
||||||
//add all c_tuple items to "values" list
|
//add all c_tuple items to "values" list
|
||||||
convert_impl( c_tuple, values, mpl::int_< 0 >(), length_type() );
|
convert_impl( c_tuple, values, mpl::int_< 0 >(), length_type() );
|
||||||
//create Python tuple from the list
|
//create Python tuple from the list
|
||||||
return incref( python::tuple( values ).ptr() );
|
return incref( python::tuple( values ).ptr() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -157,8 +157,8 @@ private:
|
||||||
template< int index, int length >
|
template< int index, int length >
|
||||||
static void
|
static void
|
||||||
convert_impl( const TTuple &c_tuple, list& values, mpl::int_< index >, mpl::int_< length > ) {
|
convert_impl( const TTuple &c_tuple, list& values, mpl::int_< index >, mpl::int_< length > ) {
|
||||||
values.append( c_tuple.template get< index >() );
|
values.append( c_tuple.template get< index >() );
|
||||||
convert_impl( c_tuple, values, details::increment_index<index>(), length_type() );
|
convert_impl( c_tuple, values, details::increment_index<index>(), length_type() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< int length >
|
template< int length >
|
||||||
|
|
@ -179,48 +179,48 @@ struct from_py_sequence{
|
||||||
static void*
|
static void*
|
||||||
convertible(PyObject* py_obj){
|
convertible(PyObject* py_obj){
|
||||||
|
|
||||||
if( !PySequence_Check( py_obj ) ){
|
if( !PySequence_Check( py_obj ) ){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( !PyObject_HasAttrString( py_obj, "__len__" ) ){
|
if( !PyObject_HasAttrString( py_obj, "__len__" ) ){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
python::object py_sequence( handle<>( borrowed( py_obj ) ) );
|
python::object py_sequence( handle<>( borrowed( py_obj ) ) );
|
||||||
|
|
||||||
if( tuples::length< TTuple >::value != len( py_sequence ) ){
|
if( tuples::length< TTuple >::value != len( py_sequence ) ){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( convertible_impl( py_sequence, mpl::int_< 0 >(), length_type() ) ){
|
if( convertible_impl( py_sequence, mpl::int_< 0 >(), length_type() ) ){
|
||||||
return py_obj;
|
return py_obj;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
construct( PyObject* py_obj, converter::rvalue_from_python_stage1_data* data){
|
construct( PyObject* py_obj, converter::rvalue_from_python_stage1_data* data){
|
||||||
typedef converter::rvalue_from_python_storage<TTuple> storage_t;
|
typedef converter::rvalue_from_python_storage<TTuple> storage_t;
|
||||||
storage_t* the_storage = reinterpret_cast<storage_t*>( data );
|
storage_t* the_storage = reinterpret_cast<storage_t*>( data );
|
||||||
void* memory_chunk = the_storage->storage.bytes;
|
void* memory_chunk = the_storage->storage.bytes;
|
||||||
TTuple* c_tuple = new (memory_chunk) TTuple();
|
TTuple* c_tuple = new (memory_chunk) TTuple();
|
||||||
data->convertible = memory_chunk;
|
data->convertible = memory_chunk;
|
||||||
|
|
||||||
python::object py_sequence( handle<>( borrowed( py_obj ) ) );
|
python::object py_sequence( handle<>( borrowed( py_obj ) ) );
|
||||||
construct_impl( py_sequence, *c_tuple, mpl::int_< 0 >(), length_type() );
|
construct_impl( py_sequence, *c_tuple, mpl::int_< 0 >(), length_type() );
|
||||||
}
|
}
|
||||||
|
|
||||||
static TTuple to_c_tuple( PyObject* py_obj ){
|
static TTuple to_c_tuple( PyObject* py_obj ){
|
||||||
if( !convertible( py_obj ) ){
|
if( !convertible( py_obj ) ){
|
||||||
throw std::runtime_error( "Unable to construct boost::tuples::tuple from Python object!" );
|
throw std::runtime_error( "Unable to construct boost::tuples::tuple from Python object!" );
|
||||||
}
|
}
|
||||||
TTuple c_tuple;
|
TTuple c_tuple;
|
||||||
python::object py_sequence( handle<>( borrowed( py_obj ) ) );
|
python::object py_sequence( handle<>( borrowed( py_obj ) ) );
|
||||||
construct_impl( py_sequence, c_tuple, mpl::int_< 0 >(), length_type() );
|
construct_impl( py_sequence, c_tuple, mpl::int_< 0 >(), length_type() );
|
||||||
return c_tuple;
|
return c_tuple;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -229,34 +229,34 @@ private:
|
||||||
static bool
|
static bool
|
||||||
convertible_impl( const python::object& py_sequence, mpl::int_< index >, mpl::int_< length > ){
|
convertible_impl( const python::object& py_sequence, mpl::int_< index >, mpl::int_< length > ){
|
||||||
|
|
||||||
typedef typename tuples::element< index, TTuple>::type element_type;
|
typedef typename tuples::element< index, TTuple>::type element_type;
|
||||||
|
|
||||||
object element = py_sequence[index];
|
object element = py_sequence[index];
|
||||||
extract<element_type> type_checker( element );
|
extract<element_type> type_checker( element );
|
||||||
if( !type_checker.check() ){
|
if( !type_checker.check() ){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return convertible_impl( py_sequence, details::increment_index<index>(), length_type() );
|
return convertible_impl( py_sequence, details::increment_index<index>(), length_type() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< int length >
|
template< int length >
|
||||||
static bool
|
static bool
|
||||||
convertible_impl( const python::object& py_sequence, mpl::int_< length >, mpl::int_< length > ){
|
convertible_impl( const python::object& py_sequence, mpl::int_< length >, mpl::int_< length > ){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< int index, int length >
|
template< int index, int length >
|
||||||
static void
|
static void
|
||||||
construct_impl( const python::object& py_sequence, TTuple& c_tuple, mpl::int_< index >, mpl::int_< length > ){
|
construct_impl( const python::object& py_sequence, TTuple& c_tuple, mpl::int_< index >, mpl::int_< length > ){
|
||||||
|
|
||||||
typedef typename tuples::element< index, TTuple>::type element_type;
|
typedef typename tuples::element< index, TTuple>::type element_type;
|
||||||
|
|
||||||
object element = py_sequence[index];
|
object element = py_sequence[index];
|
||||||
c_tuple.template get< index >() = extract<element_type>( element );
|
c_tuple.template get< index >() = extract<element_type>( element );
|
||||||
|
|
||||||
construct_impl( py_sequence, c_tuple, details::increment_index<index>(), length_type() );
|
construct_impl( py_sequence, c_tuple, details::increment_index<index>(), length_type() );
|
||||||
}
|
}
|
||||||
|
|
||||||
template< int length >
|
template< int length >
|
||||||
|
|
@ -272,8 +272,8 @@ void register_tuple(){
|
||||||
to_python_converter< TTuple, to_py_tuple<TTuple> >();
|
to_python_converter< TTuple, to_py_tuple<TTuple> >();
|
||||||
|
|
||||||
converter::registry::push_back( &from_py_sequence<TTuple>::convertible
|
converter::registry::push_back( &from_py_sequence<TTuple>::convertible
|
||||||
, &from_py_sequence<TTuple>::construct
|
, &from_py_sequence<TTuple>::construct
|
||||||
, type_id<TTuple>() );
|
, type_id<TTuple>() );
|
||||||
};
|
};
|
||||||
|
|
||||||
} } //boost::python
|
} } //boost::python
|
||||||
|
|
|
||||||
|
|
@ -1210,7 +1210,7 @@ value_t xpath_t::op_t::calc(scope_t& scope)
|
||||||
case ATTR_NAME:
|
case ATTR_NAME:
|
||||||
if (optional<value_t&> value =
|
if (optional<value_t&> value =
|
||||||
kind == ATTR_ID ? current_xml_node(scope).get_attr(as_name()) :
|
kind == ATTR_ID ? current_xml_node(scope).get_attr(as_name()) :
|
||||||
current_xml_node(scope).get_attr(as_string()))
|
current_xml_node(scope).get_attr(as_string()))
|
||||||
return *value;
|
return *value;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -83,9 +83,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void define(const string& name, ptr_op_t def) = 0;
|
virtual void define(const string& name, ptr_op_t def) = 0;
|
||||||
void define(const string& name, const value_t& val);
|
void define(const string& name, const value_t& val);
|
||||||
virtual ptr_op_t lookup(const string& name) = 0;
|
virtual ptr_op_t lookup(const string& name) = 0;
|
||||||
value_t resolve(const string& name) {
|
value_t resolve(const string& name) {
|
||||||
return lookup(name)->calc(*this);
|
return lookup(name)->calc(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,7 +175,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void define(const string& name, ptr_op_t def);
|
virtual void define(const string& name, ptr_op_t def);
|
||||||
void define(const string& name, const value_t& val) {
|
void define(const string& name, const value_t& val) {
|
||||||
scope_t::define(name, val);
|
scope_t::define(name, val);
|
||||||
}
|
}
|
||||||
virtual ptr_op_t lookup(const string& name);
|
virtual ptr_op_t lookup(const string& name);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue