summaryrefslogtreecommitdiff
path: root/src/item.cc
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2009-02-04 03:34:37 -0400
committerJohn Wiegley <johnw@newartisans.com>2009-02-04 03:34:37 -0400
commit1cc33531ea7cf82e41b1ed49bf8ffc5afea084e4 (patch)
tree0ecd593b7ca164743bb9a4addf70ec76072288ce /src/item.cc
parent28da097fc245340b316539c5533d470d82f19965 (diff)
downloadfork-ledger-1cc33531ea7cf82e41b1ed49bf8ffc5afea084e4.tar.gz
fork-ledger-1cc33531ea7cf82e41b1ed49bf8ffc5afea084e4.tar.bz2
fork-ledger-1cc33531ea7cf82e41b1ed49bf8ffc5afea084e4.zip
Simplified the textual parser, and improved metadata support.
Diffstat (limited to 'src/item.cc')
-rw-r--r--src/item.cc30
1 files changed, 28 insertions, 2 deletions
diff --git a/src/item.cc b/src/item.cc
index 02983ba1..27d28782 100644
--- a/src/item.cc
+++ b/src/item.cc
@@ -71,6 +71,21 @@ void item_t::set_tag(const string& tag,
void item_t::parse_tags(const char * p)
{
+ if (char * b = std::strchr(p, '[')) {
+ if (char * e = std::strchr(p, ']')) {
+ char buf[256];
+ std::strncpy(buf, b + 1, e - b - 1);
+ buf[e - b - 1] = '\0';
+
+ if (char * p = std::strchr(buf, '=')) {
+ *p++ = '\0';
+ _date_eff = parse_date(p);
+ }
+ if (buf[0])
+ _date = parse_date(buf);
+ }
+ }
+
if (! std::strchr(p, ':'))
return;
@@ -99,6 +114,17 @@ void item_t::parse_tags(const char * p)
}
}
+void item_t::append_note(const char * p)
+{
+ if (note)
+ *note += p;
+ else
+ note = p;
+ *note += '\n';
+
+ parse_tags(p);
+}
+
namespace {
value_t get_status(item_t& item) {
return long(item.state());
@@ -325,9 +351,9 @@ string item_context(const item_t& item)
out << "While balancing item from \"" << item.pathname.string()
<< "\"";
- if (item.beg_line != (item.end_line - 1))
+ if (item.beg_line != item.end_line)
out << ", lines " << item.beg_line << "-"
- << (item.end_line - 1) << ":\n";
+ << item.end_line << ":\n";
else
out << ", line " << item.beg_line << ":\n";