mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
move domSource to Eval, as it's an Eval source
This commit is contained in:
parent
6e9ad1048d
commit
db26a28bf9
4 changed files with 21 additions and 19 deletions
24
src/Eval.cpp
24
src/Eval.cpp
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <Eval.h>
|
#include <Eval.h>
|
||||||
|
#include <DOM.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
@ -34,7 +35,7 @@
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
|
|
||||||
extern Task& contextTask;
|
extern Task* contextTask;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Supported operators, borrowed from C++, particularly the precedence.
|
// Supported operators, borrowed from C++, particularly the precedence.
|
||||||
|
@ -101,6 +102,19 @@ static bool namedConstants (const std::string& name, Variant& value)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Support for evaluating DOM references (add with `e.AddSource(domSource)`)
|
||||||
|
bool domSource (const std::string& identifier, Variant& value)
|
||||||
|
{
|
||||||
|
if (getDOM (identifier, contextTask, value))
|
||||||
|
{
|
||||||
|
value.source (identifier);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
Eval::Eval ()
|
Eval::Eval ()
|
||||||
{
|
{
|
||||||
|
@ -299,10 +313,10 @@ void Eval::evaluatePostfixStack (
|
||||||
else if (token.first == "^") result = left ^ right;
|
else if (token.first == "^") result = left ^ right;
|
||||||
else if (token.first == "%") result = left % right;
|
else if (token.first == "%") result = left % right;
|
||||||
else if (token.first == "xor") result = left.operator_xor (right);
|
else if (token.first == "xor") result = left.operator_xor (right);
|
||||||
else if (token.first == "~") result = left.operator_match (right, contextTask);
|
else if (token.first == "~") result = left.operator_match (right, *contextTask);
|
||||||
else if (token.first == "!~") result = left.operator_nomatch (right, contextTask);
|
else if (token.first == "!~") result = left.operator_nomatch (right, *contextTask);
|
||||||
else if (token.first == "_hastag_") result = left.operator_hastag (right, contextTask);
|
else if (token.first == "_hastag_") result = left.operator_hastag (right, *contextTask);
|
||||||
else if (token.first == "_notag_") result = left.operator_notag (right, contextTask);
|
else if (token.first == "_notag_") result = left.operator_notag (right, *contextTask);
|
||||||
else
|
else
|
||||||
throw format ("Unsupported operator '{1}'.", token.first);
|
throw format ("Unsupported operator '{1}'.", token.first);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
#include <Variant.h>
|
#include <Variant.h>
|
||||||
|
|
||||||
|
bool domSource (const std::string&, Variant&);
|
||||||
|
|
||||||
class Eval
|
class Eval
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -39,18 +39,6 @@
|
||||||
// Context for DOM evaluations
|
// Context for DOM evaluations
|
||||||
const Task* contextTask = NULL;
|
const Task* contextTask = NULL;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
|
||||||
bool domSource (const std::string& identifier, Variant& value)
|
|
||||||
{
|
|
||||||
if (getDOM (identifier, contextTask, value))
|
|
||||||
{
|
|
||||||
value.source (identifier);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Take an input set of tasks and filter into a subset.
|
// Take an input set of tasks and filter into a subset.
|
||||||
void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output)
|
void Filter::subset (const std::vector <Task>& input, std::vector <Task>& output)
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
#include <Task.h>
|
#include <Task.h>
|
||||||
#include <Variant.h>
|
#include <Variant.h>
|
||||||
|
|
||||||
bool domSource (const std::string&, Variant&);
|
|
||||||
|
|
||||||
class Filter
|
class Filter
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue