mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
DOM
- When attributes are accessed via DOM references, the value extracted is now imbued with the attribute type.
This commit is contained in:
parent
f72aa7b02c
commit
db6cecd2f3
1 changed files with 26 additions and 9 deletions
21
src/DOM.cpp
21
src/DOM.cpp
|
@ -245,10 +245,22 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
|
|||
std::string canonical;
|
||||
if (task.size () && context.parser.canonicalize (canonical, "attribute", name))
|
||||
{
|
||||
Column* column = context.columns[canonical];
|
||||
if (column)
|
||||
{
|
||||
if (column->type () == "date")
|
||||
value = Variant (task.get_date (canonical), Variant::type_date);
|
||||
else if (column->type () == "duration")
|
||||
value = Variant ((time_t) Duration (task.get (canonical)), Variant::type_duration);
|
||||
else if (column->type () == "numeric")
|
||||
value = Variant (task.get_float (canonical));
|
||||
else
|
||||
value = Variant (task.get (canonical));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (elements.size () > 1)
|
||||
{
|
||||
Task ref;
|
||||
|
@ -301,15 +313,20 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
|
|||
if (elements.size () == 2)
|
||||
{
|
||||
Column* column = context.columns[canonical];
|
||||
if (column && column->type () == "date")
|
||||
if (column)
|
||||
{
|
||||
if (column->type () == "date")
|
||||
value = Variant (ref.get_date (canonical), Variant::type_date);
|
||||
else if (column && column->type () == "duration")
|
||||
else if (column->type () == "duration")
|
||||
value = Variant ((time_t) Duration (ref.get (canonical)), Variant::type_duration);
|
||||
else if (column->type () == "numeric")
|
||||
value = Variant (ref.get_float (canonical));
|
||||
else
|
||||
value = Variant (ref.get (canonical));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (elements.size () == 3)
|
||||
{
|
||||
// tags.<tag>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue