- When attributes are accessed via DOM references, the value extracted is now
  imbued with the attribute type.
This commit is contained in:
Paul Beckingham 2014-06-24 22:16:57 -04:00
parent f72aa7b02c
commit db6cecd2f3

View file

@ -245,10 +245,22 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
std::string canonical; std::string canonical;
if (task.size () && context.parser.canonicalize (canonical, "attribute", name)) 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)); value = Variant (task.get (canonical));
return true; return true;
} }
} }
}
else if (elements.size () > 1) else if (elements.size () > 1)
{ {
Task ref; Task ref;
@ -301,15 +313,20 @@ bool DOM::get (const std::string& name, const Task& task, Variant& value)
if (elements.size () == 2) if (elements.size () == 2)
{ {
Column* column = context.columns[canonical]; 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); 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); value = Variant ((time_t) Duration (ref.get (canonical)), Variant::type_duration);
else if (column->type () == "numeric")
value = Variant (ref.get_float (canonical));
else else
value = Variant (ref.get (canonical)); value = Variant (ref.get (canonical));
return true; return true;
} }
}
else if (elements.size () == 3) else if (elements.size () == 3)
{ {
// tags.<tag> // tags.<tag>