has_tag and get_tag now take an 'inherit' parameter
This commit is contained in:
parent
5f989f7d9f
commit
b80be82b8d
4 changed files with 35 additions and 24 deletions
|
|
@ -37,7 +37,7 @@ namespace ledger {
|
||||||
|
|
||||||
bool item_t::use_effective_date = false;
|
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);
|
DEBUG("item.meta", "Checking if item has tag: " << tag);
|
||||||
if (! metadata) {
|
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,
|
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) {
|
if (metadata) {
|
||||||
foreach (const string_map::value_type& data, *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;
|
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);
|
DEBUG("item.meta", "Getting item tag: " << tag);
|
||||||
if (metadata) {
|
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,
|
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) {
|
if (metadata) {
|
||||||
foreach (const string_map::value_type& data, *metadata) {
|
foreach (const string_map::value_type& data, *metadata) {
|
||||||
|
|
|
||||||
16
src/item.h
16
src/item.h
|
|
@ -149,13 +149,17 @@ public:
|
||||||
return ! (*this == xact);
|
return ! (*this == xact);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool has_tag(const string& tag) const;
|
virtual bool has_tag(const string& tag,
|
||||||
virtual bool has_tag(const mask_t& tag_mask,
|
bool inherit = true) const;
|
||||||
const optional<mask_t>& value_mask = none) 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 string& tag,
|
||||||
virtual optional<value_t> get_tag(const mask_t& tag_mask,
|
bool inherit = true) const;
|
||||||
const optional<mask_t>& value_mask = none) 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
|
virtual string_map::iterator
|
||||||
set_tag(const string& tag,
|
set_tag(const string& tag,
|
||||||
|
|
|
||||||
18
src/post.cc
18
src/post.cc
|
|
@ -39,40 +39,42 @@
|
||||||
|
|
||||||
namespace ledger {
|
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))
|
if (item_t::has_tag(tag))
|
||||||
return true;
|
return true;
|
||||||
if (xact)
|
if (inherit && xact)
|
||||||
return xact->has_tag(tag);
|
return xact->has_tag(tag);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool post_t::has_tag(const mask_t& tag_mask,
|
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))
|
if (item_t::has_tag(tag_mask, value_mask))
|
||||||
return true;
|
return true;
|
||||||
if (xact)
|
if (inherit && xact)
|
||||||
return xact->has_tag(tag_mask, value_mask);
|
return xact->has_tag(tag_mask, value_mask);
|
||||||
return false;
|
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))
|
if (optional<value_t> value = item_t::get_tag(tag))
|
||||||
return value;
|
return value;
|
||||||
if (xact)
|
if (inherit && xact)
|
||||||
return xact->get_tag(tag);
|
return xact->get_tag(tag);
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
|
||||||
optional<value_t> post_t::get_tag(const mask_t& tag_mask,
|
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))
|
if (optional<value_t> value = item_t::get_tag(tag_mask, value_mask))
|
||||||
return value;
|
return value;
|
||||||
if (xact)
|
if (inherit && xact)
|
||||||
return xact->get_tag(tag_mask, value_mask);
|
return xact->get_tag(tag_mask, value_mask);
|
||||||
return none;
|
return none;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/post.h
16
src/post.h
|
|
@ -99,13 +99,17 @@ public:
|
||||||
TRACE_DTOR(post_t);
|
TRACE_DTOR(post_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool has_tag(const string& tag) const;
|
virtual bool has_tag(const string& tag,
|
||||||
virtual bool has_tag(const mask_t& tag_mask,
|
bool inherit = true) const;
|
||||||
const optional<mask_t>& value_mask = none) 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 string& tag,
|
||||||
virtual optional<value_t> get_tag(const mask_t& tag_mask,
|
bool inherit = true) const;
|
||||||
const optional<mask_t>& value_mask = none) 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 value_date() const;
|
||||||
virtual date_t date() const;
|
virtual date_t date() const;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue