diff --git a/src/CLI.cpp b/src/CLI.cpp index 0e08c339e..ba896584f 100644 --- a/src/CLI.cpp +++ b/src/CLI.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -307,6 +308,36 @@ bool CLI::canonicalize ( return false; } +//////////////////////////////////////////////////////////////////////////////// +// +tag --> tags _hastag_ tag +// -tag --> tags _notag_ tag +void CLI::unsweetenTags () +{ + std::vector reconstructed; + + std::vector ::iterator i; + for (i = _filter.begin (); i != _filter.end (); ++i) + { + Nibbler n (*i); + std::string tag; + std::string sign; + + if (n.getN (1, sign) && + (sign == "+" || sign == "-") && + n.getUntilEOS (tag) && + tag.find (' ') == std::string::npos) + { + reconstructed.push_back ("tags"); + reconstructed.push_back (sign == "+" ? "_hastag_" : "_notag_"); + reconstructed.push_back (tag); + } + else + reconstructed.push_back (*i); + } + + _filter = reconstructed; +} + //////////////////////////////////////////////////////////////////////////////// void CLI::dump (const std::string& label) const { diff --git a/src/CLI.h b/src/CLI.h index a61aa4144..35828c7ee 100644 --- a/src/CLI.h +++ b/src/CLI.h @@ -49,6 +49,7 @@ private: void categorize (); bool exactMatch (const std::string&, const std::string&) const; bool canonicalize (std::string&, const std::string&, const std::string&) const; + void unsweetenTags (); void dump (const std::string&) const; public: