has_tag and get_tag now take an 'inherit' parameter

This commit is contained in:
John Wiegley 2010-06-18 02:19:39 -04:00
parent 5f989f7d9f
commit b80be82b8d
4 changed files with 35 additions and 24 deletions

View file

@ -37,7 +37,7 @@ namespace ledger {
bool item_t::use_effective_date = false;
bool item_t::has_tag(const string& tag) const
bool item_t::has_tag(const string& tag, bool) const
{
DEBUG("item.meta", "Checking if item has tag: " << tag);
if (! metadata) {
@ -57,7 +57,7 @@ bool item_t::has_tag(const string& tag) const
}
bool item_t::has_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask) const
const optional<mask_t>& value_mask, bool) const
{
if (metadata) {
foreach (const string_map::value_type& data, *metadata) {
@ -72,7 +72,7 @@ bool item_t::has_tag(const mask_t& tag_mask,
return false;
}
optional<value_t> item_t::get_tag(const string& tag) const
optional<value_t> item_t::get_tag(const string& tag, bool) const
{
DEBUG("item.meta", "Getting item tag: " << tag);
if (metadata) {
@ -87,7 +87,8 @@ optional<value_t> item_t::get_tag(const string& tag) const
}
optional<value_t> item_t::get_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask) const
const optional<mask_t>& value_mask,
bool) const
{
if (metadata) {
foreach (const string_map::value_type& data, *metadata) {

View file

@ -149,13 +149,17 @@ public:
return ! (*this == xact);
}
virtual bool has_tag(const string& tag) const;
virtual bool has_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none) const;
virtual bool has_tag(const string& tag,
bool inherit = true) const;
virtual bool has_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none,
bool inherit = true) const;
virtual optional<value_t> get_tag(const string& tag) const;
virtual optional<value_t> get_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none) const;
virtual optional<value_t> get_tag(const string& tag,
bool inherit = true) const;
virtual optional<value_t> get_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none,
bool inherit = true) const;
virtual string_map::iterator
set_tag(const string& tag,

View file

@ -39,40 +39,42 @@
namespace ledger {
bool post_t::has_tag(const string& tag) const
bool post_t::has_tag(const string& tag, bool inherit) const
{
if (item_t::has_tag(tag))
return true;
if (xact)
if (inherit && xact)
return xact->has_tag(tag);
return false;
}
bool post_t::has_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask) const
const optional<mask_t>& value_mask,
bool inherit) const
{
if (item_t::has_tag(tag_mask, value_mask))
return true;
if (xact)
if (inherit && xact)
return xact->has_tag(tag_mask, value_mask);
return false;
}
optional<value_t> post_t::get_tag(const string& tag) const
optional<value_t> post_t::get_tag(const string& tag, bool inherit) const
{
if (optional<value_t> value = item_t::get_tag(tag))
return value;
if (xact)
if (inherit && xact)
return xact->get_tag(tag);
return none;
}
optional<value_t> post_t::get_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask) const
const optional<mask_t>& value_mask,
bool inherit) const
{
if (optional<value_t> value = item_t::get_tag(tag_mask, value_mask))
return value;
if (xact)
if (inherit && xact)
return xact->get_tag(tag_mask, value_mask);
return none;
}

View file

@ -99,13 +99,17 @@ public:
TRACE_DTOR(post_t);
}
virtual bool has_tag(const string& tag) const;
virtual bool has_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none) const;
virtual bool has_tag(const string& tag,
bool inherit = true) const;
virtual bool has_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none,
bool inherit = true) const;
virtual optional<value_t> get_tag(const string& tag) const;
virtual optional<value_t> get_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none) const;
virtual optional<value_t> get_tag(const string& tag,
bool inherit = true) const;
virtual optional<value_t> get_tag(const mask_t& tag_mask,
const optional<mask_t>& value_mask = none,
bool inherit = true) const;
virtual date_t value_date() const;
virtual date_t date() const;