CLI
- Implemented ::unsweetenTags, which resolves the syntactic sugar to an expression.
This commit is contained in:
31
src/CLI.cpp
31
src/CLI.cpp
@@ -27,6 +27,7 @@
|
|||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Nibbler.h>
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
#include <CLI.h>
|
#include <CLI.h>
|
||||||
#include <Color.h>
|
#include <Color.h>
|
||||||
@@ -307,6 +308,36 @@ bool CLI::canonicalize (
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// +tag --> tags _hastag_ tag
|
||||||
|
// -tag --> tags _notag_ tag
|
||||||
|
void CLI::unsweetenTags ()
|
||||||
|
{
|
||||||
|
std::vector <std::string> reconstructed;
|
||||||
|
|
||||||
|
std::vector <std::string>::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
|
void CLI::dump (const std::string& label) const
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ private:
|
|||||||
void categorize ();
|
void categorize ();
|
||||||
bool exactMatch (const std::string&, const std::string&) const;
|
bool exactMatch (const std::string&, const std::string&) const;
|
||||||
bool canonicalize (std::string&, 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;
|
void dump (const std::string&) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user