summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2010-06-18 02:19:39 -0400
committerJohn Wiegley <johnw@newartisans.com>2010-06-18 02:19:39 -0400
commitb80be82b8d4a3aaf226b00e7c12520318346ccea (patch)
tree54e77b05f0e732fe272e67b1aa0efea91797f145 /src
parent5f989f7d9f6f41df90b2272dfcc7c4332f12cfcb (diff)
downloadfork-ledger-b80be82b8d4a3aaf226b00e7c12520318346ccea.tar.gz
fork-ledger-b80be82b8d4a3aaf226b00e7c12520318346ccea.tar.bz2
fork-ledger-b80be82b8d4a3aaf226b00e7c12520318346ccea.zip
has_tag and get_tag now take an 'inherit' parameter
Diffstat (limited to 'src')
-rw-r--r--src/item.cc9
-rw-r--r--src/item.h18
-rw-r--r--src/post.cc18
-rw-r--r--src/post.h18
4 files changed, 37 insertions, 26 deletions
diff --git a/src/item.cc b/src/item.cc
index 4e9c7702..3845e4cb 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -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) {
diff --git a/src/item.h b/src/item.h
index 8018db9a..b7dde35f 100644
--- a/src/item.h
+++ b/src/item.h
@@ -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 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 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,
+ 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,
diff --git a/src/post.cc b/src/post.cc
index 7c42e3c5..4fc34892 100644
--- a/src/post.cc
+++ b/src/post.cc
@@ -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;
}
diff --git a/src/post.h b/src/post.h
index 7111ddef..e1535a46 100644
--- a/src/post.h
+++ b/src/post.h
@@ -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 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 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,
+ 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;