From cdd07be331db8d1d162f18efc9abadb8a93b0540 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 16 Jun 2009 00:51:11 -0400 Subject: [PATCH] Enhancement - Att::type - Implemented Att::type to discern attribute types to assist with type-specific modifier evaluation. - Fixed bug that required attributes to have specified values, whereas stating "name:" means no value for name. --- src/Att.cpp | 23 +++++++++++++++++++++-- src/Att.h | 1 + src/Context.cpp | 3 +-- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Att.cpp b/src/Att.cpp index 44ca8202e..8b736b994 100644 --- a/src/Att.cpp +++ b/src/Att.cpp @@ -392,6 +392,27 @@ bool Att::validMod (const std::string& mod) return false; } +//////////////////////////////////////////////////////////////////////////////// +// The type of an attribute is useful for modifier evaluation. +std::string type (const std::string& name) +{ + if (name == "due" || + name == "until" || + name == "start" || + name == "entry" || + name == "end") + return "date"; + + else if (name == "recur") + return "duration"; + + else if (name == "limit") + return "number"; + + else + return "text"; +} + //////////////////////////////////////////////////////////////////////////////// // // start --> name --> . --> mod --> : --> " --> value --> " --> end @@ -439,8 +460,6 @@ void Att::parse (Nibbler& n) { decode (mValue); } - else - throw std::string ("Missing attribute value"); // TODO i18n } else throw std::string ("Missing : after attribute name"); // TODO i18n diff --git a/src/Att.h b/src/Att.h index 8f956617b..f84db7d2e 100644 --- a/src/Att.h +++ b/src/Att.h @@ -49,6 +49,7 @@ public: static bool validNameValue (const std::string&, const std::string&, const std::string&); static bool validNameValue (std::string&, std::string&, std::string&); static bool validMod (const std::string&); + static std::string type (const std::string&); void parse (const std::string&); void parse (Nibbler&); bool match (const Att&) const; diff --git a/src/Context.cpp b/src/Context.cpp index cc370ec42..0fc640450 100644 --- a/src/Context.cpp +++ b/src/Context.cpp @@ -494,7 +494,6 @@ void Context::constructFilter () { foreach (att, task) { - // TODO this doesn't work. if (att->first == "description") { @@ -503,7 +502,7 @@ void Context::constructFilter () foreach (word, words) { filter.push_back (Att ("description", "has", *word)); - std::cout << "Context::constructFilter " << att->first << "=" << att->second.value () << std::endl; + std::cout << "Context::constructFilter " << att->first << "=" << *word << std::endl; } }