mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-06 17:37:21 +02:00
Refactor getDOM to use a pointer for the optional context
It's possible to call getDOM without a contextual task. Previously, this was done by referencing a "dummy" task which necessitated a way to distinguish such dummy tasks. This switches to using a pointer and treating the NULL value as meaning there is no context. Note that this cannot use `std::optional<&Task>`, as optional does not support reference types.
This commit is contained in:
parent
3af5ceadc1
commit
2812a8c77a
11 changed files with 76 additions and 82 deletions
|
@ -36,7 +36,7 @@
|
|||
#include <utf8.h>
|
||||
#include <util.h>
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnProject::ColumnProject ()
|
||||
|
@ -121,7 +121,7 @@ void ColumnProject::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <format.h>
|
||||
#include <utf8.h>
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnRecur::ColumnRecur ()
|
||||
|
@ -108,7 +108,7 @@ void ColumnRecur::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
#include <utf8.h>
|
||||
#include <main.h>
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTags::ColumnTags ()
|
||||
|
@ -162,7 +162,7 @@ void ColumnTags::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeDate::ColumnTypeDate ()
|
||||
|
@ -213,7 +213,7 @@ void ColumnTypeDate::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeDuration::ColumnTypeDuration ()
|
||||
|
@ -55,7 +55,7 @@ void ColumnTypeDuration::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <Filter.h>
|
||||
#include <format.h>
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeNumeric::ColumnTypeNumeric ()
|
||||
|
@ -55,7 +55,7 @@ void ColumnTypeNumeric::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
e.evaluateInfixExpression (value, evaluatedValue);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
#define STRING_INVALID_MOD "The '{1}' attribute does not allow a value of '{2}'."
|
||||
|
||||
extern Task& contextTask;
|
||||
extern Task* contextTask;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
ColumnTypeString::ColumnTypeString ()
|
||||
|
@ -67,7 +67,7 @@ void ColumnTypeString::modify (Task& task, const std::string& value)
|
|||
{
|
||||
Eval e;
|
||||
e.addSource (domSource);
|
||||
contextTask = task;
|
||||
contextTask = &task;
|
||||
|
||||
Variant v;
|
||||
e.evaluateInfixExpression (value, v);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue