75 :
public ordered_field_operators<value_t,
76 equality_comparable<value_t, balance_t,
77 additive<value_t, balance_t,
78 multiplicative<value_t, balance_t,
79 ordered_field_operators<value_t, amount_t,
80 ordered_field_operators<value_t, double,
81 ordered_field_operators<value_t, unsigned long,
82 ordered_field_operators<value_t, long> > > > > > > >
180 : type(
rhs.type), refc(0) {
184 storage_t& operator=(
const storage_t&
rhs);
191 void acquire()
const {
192 DEBUG(
"value.storage.refcount",
193 "Acquiring " <<
this <<
", refc now " << refc + 1);
197 void release()
const {
198 DEBUG(
"value.storage.refcount",
199 "Releasing " <<
this <<
", refc now " << refc - 1);
213 DEBUG(
"value.storage.refcount",
"Destroying " <<
this);
243 if (storage && storage->refc > 1)
244 storage =
new storage_t(*storage.get());
343 template <
typename T>
369 if (! (
this == &
val || storage ==
val.storage))
370 storage =
val.storage;
381 template <
typename T>
385 template <
typename T>
389 template <
typename T>
426 temp.in_place_round();
440 temp.in_place_truncate();
447 temp.in_place_floor();
454 temp.in_place_ceiling();
461 temp.in_place_unround();
468 temp.in_place_reduce();
475 temp.in_place_unreduce();
510 return storage ? storage->type :
VOID;
555 return boost::get<bool>(storage->data);
559 return boost::get<bool>(storage->data);
563 storage =
val ? true_value : false_value;
572 return boost::get<datetime_t>(storage->data);
576 return boost::get<datetime_t>(storage->data);
589 return boost::get<date_t>(storage->data);
593 return boost::get<date_t>(storage->data);
606 return boost::get<long>(storage->data);
610 return boost::get<long>(storage->data);
623 return boost::get<amount_t>(storage->data);
627 return boost::get<amount_t>(storage->data);
641 return *boost::get<balance_t *>(storage->data);
645 return *boost::get<balance_t *>(storage->data);
659 return boost::get<string>(storage->data);
663 return boost::get<string>(storage->data);
668 VERIFY(boost::get<string>(storage->data) ==
val);
673 VERIFY(boost::get<string>(storage->data) ==
val);
682 VERIFY(boost::get<mask_t>(storage->data).valid());
683 return boost::get<mask_t>(storage->data);
687 VERIFY(boost::get<mask_t>(storage->data).valid());
688 return boost::get<mask_t>(storage->data);
705 return *boost::get<sequence_t *>(storage->data);
709 return *boost::get<sequence_t *>(storage->data);
724 return boost::get<scope_t *>(storage->data);
740 template <
typename T>
743 boost::get<boost::any>(storage->data).type() ==
typeid(T));
748 return boost::get<boost::any>(storage->data);
750 template <
typename T>
756 return boost::get<boost::any>(storage->data);
758 template <
typename T>
766 template <
typename T>
769 storage->data = boost::any(
val);
899 sequence_t::iterator
end() {
904 sequence_t::const_iterator
begin()
const {
908 sequence_t::const_iterator
end()
const {
939 void dump(std::ostream& out,
const bool relaxed =
true)
const;
947#define NULL_VALUE (value_t())
953#define VALUE_OR_ZERO(val) ((val).is_null() ? value_t(0L) : (val))
954#define SIMPLIFIED_VALUE_OR_ZERO(val) \
955 ((val).is_null() ? value_t(0L) : (val).simplified())
967 std::ostringstream buf;
968 val.print(buf, 20, 20,
true);
#define TRACE_CTOR(cls, args)
Regular expression masking.
#define AMOUNT_PRINT_NO_FLAGS
An amount may be output to a stream using the ‘print’ method.
#define DECLARE_EXCEPTION(name, kind)
Basic type for adding multiple commodities together.
void put_value(property_tree::ptree &pt, const value_t &value)
value_t mask_value(const string &str)
boost::gregorian::date date_t
value_t string_value(const string &str="")
std::ostream & operator<<(std::ostream &out, const account_t &account)
value_t scope_value(scope_t *val)
boost::posix_time::ptime datetime_t
value_t & add_or_set_value(value_t &lhs, const T &rhs)
bool sort_value_is_less_than(const std::list< sort_value_t > &left_values, const std::list< sort_value_t > &right_values)
string value_context(const value_t &val)
Encapsulate infinite-precision commoditized amounts.
A wrapper around amount_t allowing addition of multiple commodities.
Dynamic type representing various numeric types.
const value_t & operator[](const std::size_t index) const
void set_boolean(const bool val)
value_t & operator-=(const value_t &val)
void print(std::ostream &out, const int first_width=-1, const int latter_width=-1, const uint_least8_t flags=0x00) const
Printing methods.
value_t strip_annotations(const keep_details_t &what_to_keep) const
value_t(const string &val, bool literal=false)
const boost::any & as_any() const
value_t(const double val)
string label(optional< type_t > the_type=none) const
Informational methods.
const datetime_t & as_datetime() const
string & as_string_lval()
value_t casted(type_t cast_type) const
Dynamic typing conversion methods.
amount_t & as_amount_lval()
const date_t & as_date() const
sequence_t to_sequence() const
value_t(const date_t &val)
const annotation_t & annotation() const
datetime_t & as_datetime_lval()
void set_mask(const string &val)
annotation_t & annotation()
sequence_t::iterator end()
bool is_less_than(const value_t &val) const
void set_long(const long val)
bool is_scope() const
Dealing with scope pointers.
scope_t * as_scope() const
const long & as_long() const
const balance_t & as_balance() const
const mask_t & as_mask() const
sequence_t::iterator iterator
sequence_t::const_iterator begin() const
void set_datetime(const datetime_t &val)
void set_string(const char *val="")
bool operator==(const T &amt) const
std::size_t to_size_t() const
value_t & operator+=(const value_t &val)
Binary arithmetic operators.
void push_back(const value_t &val)
value_t operator-() const
value_t ceilinged() const
const string & as_string() const
sequence_t & as_sequence_lval()
void set_scope(scope_t *val)
void set_date(const date_t &val)
void set_balance(const balance_t &val)
sequence_t::const_iterator end() const
bool operator<(const T &amt) const
boost::any & as_any_lval()
bool is_boolean() const
Data manipulation methods.
type_t
type_t gives the type of the data contained or referenced by a value_t object.
datetime_t to_datetime() const
bool is_type(type_t _type) const
value_t & operator[](const std::size_t index)
Collection-style access methods for SEQUENCE values.
value_t(const datetime_t &val)
bool is_equal_to(const value_t &val) const
Comparison operators.
const amount_t & as_amount() const
void set_any(const boost::any &val)
value_t value(const datetime_t &moment=datetime_t(), const commodity_t *in_terms_of=NULL) const
const sequence_t & as_sequence() const
sequence_t::iterator begin()
void set_sequence(const sequence_t &val)
bool is_any() const
Dealing with any type at all is bit involved because we actually deal with typed object.
value_t simplified() const
value_t & operator/=(const value_t &val)
void in_place_roundto(int places)
balance_t & as_balance_lval()
void annotate(const annotation_t &details)
Annotated commodity methods.
balance_t to_balance() const
value_t negated() const
Unary arithmetic operators.
value_t & operator=(const value_t &val)
amount_t to_amount() const
void push_front(const value_t &val)
bool has_annotation() const
bool is_greater_than(const value_t &val) const
bool valid() const
Debugging methods.
void set_amount(const amount_t &val)
const bool & as_boolean() const
value_t(const char *val, bool literal=false)
value_t(const mask_t &val)
void set_mask(const mask_t &val)
bool operator>(const T &amt) const
value_t(const amount_t &val)
value_t(const unsigned long val)
sequence_t::difference_type difference_type
void in_place_cast(type_t cast_type)
value_t(const sequence_t &val)
value_t exchange_commodities(const std::string &commodities, const bool add_prices=false, const datetime_t &moment=datetime_t())
void dump(std::ostream &out, const bool relaxed=true) const
value_t(const balance_t &val)
sequence_t::const_iterator const_iterator
ptr_deque< value_t > sequence_t
The sequence_t member type abstracts the type used to represent a resizable "array" of value_t object...
value_t(const value_t &val)
Assignment and copy operators.
value_t truncated() const
void set_string(const string &val="")
bool to_boolean() const
Data conversion methods.
value_t unrounded() const
value_t roundto(int places) const
value_t unreduced() const
value_t & operator*=(const value_t &val)
friend void intrusive_ptr_add_ref(value_t::storage_t *storage_ptr)
friend void intrusive_ptr_release(value_t::storage_t *storage_ptr)