mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
DOM: Migrated from Nibbler to Lexer
This commit is contained in:
parent
f6ae39cb82
commit
abd4cfc4ed
1 changed files with 18 additions and 18 deletions
28
src/DOM.cpp
28
src/DOM.cpp
|
@ -30,6 +30,7 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Variant.h>
|
#include <Variant.h>
|
||||||
|
#include <Lexer.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <ISO8601.h>
|
#include <ISO8601.h>
|
||||||
#include <shared.h>
|
#include <shared.h>
|
||||||
|
@ -193,26 +194,25 @@ bool getDOM (const std::string& name, const Task& task, Variant& value)
|
||||||
auto elements = split (name, '.');
|
auto elements = split (name, '.');
|
||||||
|
|
||||||
Task ref (task);
|
Task ref (task);
|
||||||
Nibbler n (elements[0]);
|
Lexer lexer (elements[0]);
|
||||||
n.save ();
|
std::string token;
|
||||||
int id;
|
Lexer::Type type;
|
||||||
std::string uuid;
|
if (lexer.token (token, type))
|
||||||
|
|
||||||
// If elements[0] is a UUID, load that task (if necessary), and clobber ref.
|
|
||||||
if (n.getPartialUUID (uuid) && n.depleted ())
|
|
||||||
{
|
{
|
||||||
if (uuid != ref.get ("uuid"))
|
if (type == Lexer::Type::uuid &&
|
||||||
context.tdb2.get (uuid, ref);
|
token.length () == elements[0].length ())
|
||||||
|
{
|
||||||
|
if (token != ref.get ("uuid"))
|
||||||
|
context.tdb2.get (token, ref);
|
||||||
|
|
||||||
// Eat elements[0]/UUID.
|
// Eat elements[0]/UUID.
|
||||||
elements.erase (elements.begin ());
|
elements.erase (elements.begin ());
|
||||||
}
|
}
|
||||||
else
|
else if (type == Lexer::Type::number &&
|
||||||
|
token.find ('.') == std::string::npos)
|
||||||
{
|
{
|
||||||
// If elements[0] is a ID, load that task (if necessary), and clobber ref.
|
auto id = strtol (token.c_str (), NULL, 10);
|
||||||
if (n.getInt (id) && n.depleted ())
|
if (id && id != ref.id)
|
||||||
{
|
|
||||||
if (id != ref.id)
|
|
||||||
context.tdb2.get (id, ref);
|
context.tdb2.get (id, ref);
|
||||||
|
|
||||||
// Eat elements[0]/ID.
|
// Eat elements[0]/ID.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue