Added serialization methods for most type
This allows journal_t objects to be completed serialized to disk and deserialized.
This commit is contained in:
parent
1b8811f997
commit
a757b19f51
22 changed files with 723 additions and 3 deletions
|
|
@ -232,6 +232,26 @@ public:
|
|||
return xdata_ && xdata_->has_flags(flags);
|
||||
}
|
||||
std::size_t children_with_flags(xdata_t::flags_t flags) const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<supports_flags<> >(*this);
|
||||
ar & boost::serialization::base_object<scope_t>(*this);
|
||||
ar & parent;
|
||||
ar & name;
|
||||
ar & note;
|
||||
ar & depth;
|
||||
ar & accounts;
|
||||
ar & posts;
|
||||
ar & _fullname;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const account_t& account);
|
||||
|
|
|
|||
|
|
@ -94,6 +94,20 @@ struct amount_t::bigint_t : public supports_flags<>
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & boost::serialization::base_object<supports_flags<> >(*this);
|
||||
ar & val;
|
||||
ar & prec;
|
||||
ar & refc;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
shared_ptr<commodity_pool_t> amount_t::current_pool;
|
||||
|
|
@ -1107,4 +1121,63 @@ bool amount_t::valid() const
|
|||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
|
||||
template<class Archive>
|
||||
void amount_t::serialize(Archive& ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & current_pool;
|
||||
ar & is_initialized;
|
||||
ar & quantity;
|
||||
ar & commodity_;
|
||||
}
|
||||
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
|
||||
} // namespace ledger
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, MP_INT& mpz, const unsigned int /* version */)
|
||||
{
|
||||
ar & mpz._mp_alloc;
|
||||
ar & mpz._mp_size;
|
||||
ar & mpz._mp_d;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, MP_RAT& mpq, const unsigned int /* version */)
|
||||
{
|
||||
ar & mpq._mp_num;
|
||||
ar & mpq._mp_den;
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, long unsigned int& integer,
|
||||
const unsigned int /* version */)
|
||||
{
|
||||
ar & make_binary_object(&integer, sizeof(long unsigned int));
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
BOOST_CLASS_EXPORT(ledger::annotated_commodity_t)
|
||||
|
||||
template void boost::serialization::serialize(boost::archive::binary_oarchive&,
|
||||
MP_INT&, const unsigned int);
|
||||
template void boost::serialization::serialize(boost::archive::binary_iarchive&,
|
||||
MP_RAT&, const unsigned int);
|
||||
template void boost::serialization::serialize(boost::archive::binary_iarchive&,
|
||||
long unsigned int&,
|
||||
const unsigned int);
|
||||
|
||||
template void ledger::amount_t::serialize(boost::archive::binary_oarchive&,
|
||||
const unsigned int);
|
||||
template void ledger::amount_t::serialize(boost::archive::binary_iarchive&,
|
||||
const unsigned int);
|
||||
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
|
|
|
|||
10
src/amount.h
10
src/amount.h
|
|
@ -691,6 +691,16 @@ public:
|
|||
|
||||
bool valid() const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */);
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
|
||||
/*@}*/
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -98,6 +98,21 @@ struct annotation_t : public supports_flags<>,
|
|||
assert(*this);
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<supports_flags<> >(*this);
|
||||
ar & price;
|
||||
ar & date;
|
||||
ar & tag;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
struct keep_details_t
|
||||
|
|
@ -136,6 +151,21 @@ struct keep_details_t
|
|||
return keep_price || keep_date || keep_tag;
|
||||
}
|
||||
bool keep_any(const commodity_t& comm) const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & keep_price;
|
||||
ar & keep_date;
|
||||
ar & keep_tag;
|
||||
ar & only_actuals;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out,
|
||||
|
|
@ -183,6 +213,22 @@ public:
|
|||
|
||||
virtual commodity_t& strip_annotations(const keep_details_t& what_to_keep);
|
||||
virtual void write_annotations(std::ostream& out) const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
explicit annotated_commodity_t() : ptr(NULL) {}
|
||||
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<commodity_t>(*this);
|
||||
ar & ptr;
|
||||
ar & details;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline annotated_commodity_t&
|
||||
|
|
|
|||
|
|
@ -523,6 +523,18 @@ public:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & amounts;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const balance_t& bal) {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,19 @@ struct price_point_t
|
|||
{
|
||||
datetime_t when;
|
||||
amount_t price;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & when;
|
||||
ar & price;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -78,7 +91,7 @@ class commodity_t
|
|||
public:
|
||||
class base_t : public noncopyable, public supports_flags<uint_least16_t>
|
||||
{
|
||||
base_t();
|
||||
base_t() {}
|
||||
|
||||
public:
|
||||
typedef std::map<const datetime_t, amount_t> history_map;
|
||||
|
|
@ -100,6 +113,18 @@ public:
|
|||
, const int indent = 0
|
||||
#endif
|
||||
) const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & prices;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
typedef std::map<commodity_t *, history_t> history_by_commodity_map;
|
||||
|
|
@ -126,6 +151,18 @@ public:
|
|||
|
||||
optional<history_t&>
|
||||
history(const optional<commodity_t&>& commodity = none);
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & histories;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
#define COMMODITY_STYLE_DEFAULTS 0x000
|
||||
|
|
@ -158,6 +195,25 @@ public:
|
|||
~base_t() {
|
||||
TRACE_DTOR(base_t);
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<supports_flags<uint_least16_t> >(*this);
|
||||
ar & symbol;
|
||||
ar & precision;
|
||||
ar & name;
|
||||
ar & note;
|
||||
ar & varied_history;
|
||||
ar & smaller;
|
||||
ar & larger;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
@ -330,6 +386,31 @@ public:
|
|||
}
|
||||
|
||||
bool valid() const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
supports_flags<uint_least16_t> temp_flags;
|
||||
|
||||
protected:
|
||||
explicit commodity_t()
|
||||
: delegates_flags<uint_least16_t>(temp_flags), parent_(NULL),
|
||||
annotated(false) {}
|
||||
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<delegates_flags<uint_least16_t> >(*this);
|
||||
ar & base;
|
||||
ar & parent_;
|
||||
ar & qualified_symbol;
|
||||
ar & mapping_key_;
|
||||
ar & annotated;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const commodity_t& comm) {
|
||||
|
|
|
|||
16
src/expr.h
16
src/expr.h
|
|
@ -163,6 +163,22 @@ public:
|
|||
void dump(std::ostream& out) const;
|
||||
|
||||
static value_t eval(const string& _expr, scope_t& scope);
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & ptr;
|
||||
ar & context;
|
||||
ar & str;
|
||||
if (Archive::is_loading::value)
|
||||
compiled = false;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const expr_t& expr);
|
||||
|
|
|
|||
22
src/flags.h
22
src/flags.h
|
|
@ -99,6 +99,17 @@ public:
|
|||
void drop_flags(const flags_t arg) {
|
||||
_flags = static_cast<T>(static_cast<U>(_flags) & static_cast<U>(~arg));
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & _flags;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -201,6 +212,17 @@ public:
|
|||
void drop_flags(const flags_t arg) {
|
||||
_flags.drop_flags(arg);
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */)
|
||||
{
|
||||
ar & _flags;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
#endif // _FLAGS_H
|
||||
|
|
|
|||
35
src/item.h
35
src/item.h
|
|
@ -79,6 +79,22 @@ struct position_t
|
|||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & pathname;
|
||||
ar & beg_pos;
|
||||
ar & beg_line;
|
||||
ar & end_pos;
|
||||
ar & end_line;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -176,6 +192,25 @@ public:
|
|||
virtual expr_t::ptr_op_t lookup(const string& name);
|
||||
|
||||
bool valid() const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<supports_flags<> >(*this);
|
||||
ar & boost::serialization::base_object<scope_t>(*this);
|
||||
ar & _state;
|
||||
ar & _date;
|
||||
ar & _date_eff;
|
||||
ar & note;
|
||||
ar & metadata;
|
||||
ar & pos;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
value_t get_comment(item_t& item);
|
||||
|
|
|
|||
|
|
@ -110,6 +110,22 @@ public:
|
|||
bool strict = false);
|
||||
|
||||
bool valid() const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & master;
|
||||
ar & basket;
|
||||
ar & xacts;
|
||||
ar & auto_xacts;
|
||||
ar & period_xacts;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
} // namespace ledger
|
||||
|
|
|
|||
19
src/mask.h
19
src/mask.h
|
|
@ -94,6 +94,25 @@ public:
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
string temp;
|
||||
if (Archive::is_loading::value) {
|
||||
ar & temp;
|
||||
*this = temp;
|
||||
} else {
|
||||
temp = expr.str();
|
||||
ar & temp;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline std::ostream& operator<<(std::ostream& out, const mask_t& mask) {
|
||||
|
|
|
|||
27
src/op.h
27
src/op.h
|
|
@ -290,6 +290,33 @@ public:
|
|||
|
||||
static ptr_op_t wrap_value(const value_t& val);
|
||||
static ptr_op_t wrap_functor(const function_t& fobj);
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & refc;
|
||||
ar & kind;
|
||||
if (Archive::is_loading::value || ! left_ || left_->kind != FUNCTION) {
|
||||
ar & left_;
|
||||
} else {
|
||||
ptr_op_t temp_op;
|
||||
ar & temp_op;
|
||||
}
|
||||
if (Archive::is_loading::value || kind == VALUE || kind == IDENT ||
|
||||
(kind > UNARY_OPERATORS &&
|
||||
(! has_right() || ! right()->is_function()))) {
|
||||
ar & data;
|
||||
} else {
|
||||
variant<ptr_op_t, value_t, string, function_t> temp_data;
|
||||
ar & temp_data;
|
||||
}
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline expr_t::ptr_op_t
|
||||
|
|
|
|||
18
src/pool.h
18
src/pool.h
|
|
@ -134,6 +134,24 @@ public:
|
|||
parse_price_expression(const std::string& str,
|
||||
const bool add_prices = true,
|
||||
const optional<datetime_t>& moment = none);
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & commodities;
|
||||
ar & null_commodity;
|
||||
ar & default_commodity;
|
||||
ar & keep_base;
|
||||
ar & price_db;
|
||||
ar & quote_leeway;
|
||||
ar & get_quotes;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
} // namespace ledger
|
||||
|
|
|
|||
17
src/post.h
17
src/post.h
|
|
@ -205,6 +205,23 @@ public:
|
|||
}
|
||||
|
||||
friend class xact_t;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<item_t>(*this);
|
||||
ar & xact;
|
||||
ar & account;
|
||||
ar & amount;
|
||||
ar & cost;
|
||||
ar & assigned_amount;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
} // namespace ledger
|
||||
|
|
|
|||
|
|
@ -94,6 +94,19 @@ public:
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & predicate;
|
||||
ar & what_to_keep;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
class query_lexer_t
|
||||
|
|
|
|||
66
src/scope.h
66
src/scope.h
|
|
@ -67,6 +67,16 @@ public:
|
|||
|
||||
virtual void define(const string&, expr_t::ptr_op_t) {}
|
||||
virtual expr_t::ptr_op_t lookup(const string& name) = 0;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive &, const unsigned int /* version */) {}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -100,6 +110,19 @@ public:
|
|||
return parent->lookup(name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<scope_t>(*this);
|
||||
ar & parent;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -127,6 +150,19 @@ public:
|
|||
virtual void define(const string& name, expr_t::ptr_op_t def);
|
||||
|
||||
virtual expr_t::ptr_op_t lookup(const string& name);
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<child_scope_t>(*this);
|
||||
ar & symbols;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -138,8 +174,6 @@ class call_scope_t : public child_scope_t
|
|||
{
|
||||
value_t args;
|
||||
|
||||
call_scope_t();
|
||||
|
||||
public:
|
||||
explicit call_scope_t(scope_t& _parent) : child_scope_t(_parent) {
|
||||
TRACE_CTOR(call_scope_t, "scope_t&");
|
||||
|
|
@ -182,6 +216,21 @@ public:
|
|||
bool empty() const {
|
||||
return args.size() == 0;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
explicit call_scope_t() {}
|
||||
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<child_scope_t>(*this);
|
||||
ar & args;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -215,6 +264,19 @@ public:
|
|||
return def;
|
||||
return child_scope_t::lookup(name);
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<child_scope_t>(*this);
|
||||
ar & grandchild;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -40,6 +40,26 @@
|
|||
#include "iterators.h"
|
||||
#include "filters.h"
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
//BOOST_IS_ABSTRACT(ledger::scope_t)
|
||||
BOOST_CLASS_EXPORT(ledger::scope_t)
|
||||
BOOST_CLASS_EXPORT(ledger::child_scope_t)
|
||||
BOOST_CLASS_EXPORT(ledger::symbol_scope_t)
|
||||
BOOST_CLASS_EXPORT(ledger::call_scope_t)
|
||||
BOOST_CLASS_EXPORT(ledger::account_t)
|
||||
BOOST_CLASS_EXPORT(ledger::item_t)
|
||||
BOOST_CLASS_EXPORT(ledger::post_t)
|
||||
BOOST_CLASS_EXPORT(ledger::xact_base_t)
|
||||
BOOST_CLASS_EXPORT(ledger::xact_t)
|
||||
BOOST_CLASS_EXPORT(ledger::auto_xact_t)
|
||||
BOOST_CLASS_EXPORT(ledger::period_xact_t)
|
||||
|
||||
template void ledger::journal_t::serialize(boost::archive::binary_oarchive&,
|
||||
const unsigned int);
|
||||
template void ledger::journal_t::serialize(boost::archive::binary_iarchive&,
|
||||
const unsigned int);
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
|
||||
namespace ledger {
|
||||
|
||||
void set_session_context(session_t * session)
|
||||
|
|
|
|||
|
|
@ -167,6 +167,80 @@ typedef std::ostream::pos_type ostream_pos_type;
|
|||
#include <boost/variant.hpp>
|
||||
#include <boost/version.hpp>
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
|
||||
#include <boost/archive/binary_iarchive.hpp>
|
||||
#include <boost/archive/binary_oarchive.hpp>
|
||||
|
||||
#include <boost/serialization/base_object.hpp>
|
||||
#include <boost/serialization/binary_object.hpp>
|
||||
#include <boost/serialization/optional.hpp>
|
||||
#include <boost/serialization/shared_ptr.hpp>
|
||||
#include <boost/serialization/variant.hpp>
|
||||
#include <boost/serialization/utility.hpp>
|
||||
#include <boost/serialization/export.hpp>
|
||||
#include <boost/serialization/level.hpp>
|
||||
#include <boost/serialization/string.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/deque.hpp>
|
||||
#include <boost/serialization/list.hpp>
|
||||
#include <boost/serialization/map.hpp>
|
||||
|
||||
#include <boost/date_time/posix_time/time_serialize.hpp>
|
||||
#include <boost/date_time/gregorian/greg_serialize.hpp>
|
||||
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::filesystem::path, boost::serialization::primitive_type)
|
||||
#ifndef BOOST_NO_STD_WSTRING
|
||||
BOOST_CLASS_IMPLEMENTATION(boost::filesystem::wpath, boost::serialization::primitive_type)
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace serialization {
|
||||
|
||||
template <class Archive, class String, class Traits>
|
||||
void serialize(Archive& ar, boost::filesystem::basic_path<String, Traits>& p,
|
||||
const unsigned int)
|
||||
{
|
||||
String s;
|
||||
if (Archive::is_saving::value)
|
||||
s = p.string();
|
||||
|
||||
ar & s;
|
||||
|
||||
if (Archive::is_loading::value)
|
||||
p = s;
|
||||
}
|
||||
|
||||
template <class Archive, class T>
|
||||
void serialize(Archive& ar, boost::intrusive_ptr<T>& ptr, const unsigned int)
|
||||
{
|
||||
if (Archive::is_saving::value) {
|
||||
T * p = ptr.get();
|
||||
ar & p;
|
||||
}
|
||||
else if (Archive::is_loading::value) {
|
||||
T * p;
|
||||
ar & p;
|
||||
ptr.reset(p);
|
||||
}
|
||||
}
|
||||
|
||||
template <class Archive, class T>
|
||||
void serialize(Archive&, boost::function<T>&, const unsigned int)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Archive>
|
||||
void serialize(Archive& ar, istream_pos_type& pos, const unsigned int)
|
||||
{
|
||||
ar & make_binary_object(&pos, sizeof(istream_pos_type));
|
||||
}
|
||||
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
|
||||
#if defined(HAVE_BOOST_PYTHON)
|
||||
|
||||
#include <boost/python.hpp>
|
||||
|
|
|
|||
32
src/times.h
32
src/times.h
|
|
@ -170,6 +170,19 @@ public:
|
|||
assert(0); return date_t();
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & quantum;
|
||||
ar & length;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
static date_t add_duration(const date_t& date,
|
||||
|
|
@ -244,6 +257,25 @@ public:
|
|||
}
|
||||
|
||||
date_interval_t& operator++();
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & start;
|
||||
ar & aligned;
|
||||
ar & skip_duration;
|
||||
ar & factor;
|
||||
ar & next;
|
||||
ar & duration;
|
||||
ar & end_of_duration;
|
||||
ar & end;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
void times_initialize();
|
||||
|
|
|
|||
12
src/utils.h
12
src/utils.h
|
|
@ -178,6 +178,18 @@ public:
|
|||
string(const char * str, size_type x);
|
||||
string(const char * str, size_type x, size_type y);
|
||||
~string() throw();
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<std::string>(*this);
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
inline string operator+(const string& __lhs, const string& __rhs)
|
||||
|
|
|
|||
28
src/value.h
28
src/value.h
|
|
@ -227,6 +227,20 @@ private:
|
|||
data = false;
|
||||
type = VOID;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & data;
|
||||
ar & type;
|
||||
ar & refc;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -896,6 +910,20 @@ public:
|
|||
* Debugging methods.
|
||||
*/
|
||||
bool valid() const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & true_value;
|
||||
ar & false_value;
|
||||
ar & storage;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
#define NULL_VALUE (value_t())
|
||||
|
|
|
|||
67
src/xact.h
67
src/xact.h
|
|
@ -80,6 +80,20 @@ public:
|
|||
|
||||
virtual bool finalize();
|
||||
virtual bool valid() const = 0;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<item_t>(*this);
|
||||
ar & journal;
|
||||
ar & posts;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -111,6 +125,20 @@ public:
|
|||
virtual expr_t::ptr_op_t lookup(const string& name);
|
||||
|
||||
virtual bool valid() const;
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<xact_base_t>(*this);
|
||||
ar & code;
|
||||
ar & payee;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -154,6 +182,19 @@ public:
|
|||
virtual bool valid() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<xact_base_t>(*this);
|
||||
ar & predicate;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -180,6 +221,18 @@ struct auto_xact_finalizer_t : public xact_finalizer_t
|
|||
}
|
||||
|
||||
virtual bool operator()(xact_t& xact, bool post);
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & journal;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
@ -218,6 +271,20 @@ class period_xact_t : public xact_base_t
|
|||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(HAVE_BOOST_SERIALIZATION)
|
||||
private:
|
||||
/** Serialization. */
|
||||
|
||||
friend class boost::serialization::access;
|
||||
|
||||
template<class Archive>
|
||||
void serialize(Archive & ar, const unsigned int /* version */) {
|
||||
ar & boost::serialization::base_object<xact_base_t>(*this);
|
||||
ar & period;
|
||||
ar & period_string;
|
||||
}
|
||||
#endif // HAVE_BOOST_SERIALIZATION
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue