- All attribute types (number, string, date, duration) are ѕpecifically
  handled, with no default cases.
This commit is contained in:
Paul Beckingham
2014-06-15 09:36:35 -04:00
parent 518f56b499
commit 65890bc8d4

View File

@@ -2054,60 +2054,56 @@ void Task::modify (modType type, bool text_required /* = false */)
v.cast (Variant::type_real); v.cast (Variant::type_real);
v.cast (Variant::type_string); v.cast (Variant::type_string);
set (name, v); set (name, v);
++modCount; ++modCount;
} }
// Try to use modify method, otherwise just continue to the final option. // String type columns may eval, or may not make sense to eval, and
else if (column->can_modify ()) // the best way to determine this is to try.
else if (column->type () == "string")
{ {
Eval e; std::string evaluated = value;
e.addSource (domSource); try
e.addSource (namedDates);
e.ambiguity (false);
contextTask = *this;
Variant v;
e.evaluateInfixExpression (value, v);
v.cast (Variant::type_string);
std::string value2 = v.get_string ();
// column->modify () contains the logic for the specific column
// and returns the appropriate value for (*this).set ()
if (column->validate (value2))
{ {
std::string col_value = column->modify (value); Eval e;
context.debug (label + name + " <-- " + col_value + " <-- " + value2 + " <-- " + value); e.addSource (domSource);
(*this).set (name, col_value); e.addSource (namedDates);
++modCount; e.ambiguity (false);
} contextTask = *this;
else
throw format (STRING_INVALID_MOD, name, value);
}
else
{
Eval e;
e.addSource (domSource);
e.addSource (namedDates);
e.ambiguity (false);
contextTask = *this;
Variant v; Variant v;
e.evaluateInfixExpression (value, v); e.evaluateInfixExpression (value, v);
v.cast (Variant::type_string); v.cast (Variant::type_string);
std::string value2 = v.get_string (); evaluated = v.get_string ();
}
catch (...) { /* NOP */ }
// Final default action // Final default action
if (column->validate (value2)) if (column->validate (evaluated))
{ {
context.debug (label + name + " <-- " + value2 + " <-- " + value); if (column->can_modify ())
(*this).set (name, value2); {
std::string col_value = column->modify (evaluated);
context.debug (label + name + " <-- " + col_value + " <-- " + evaluated + " <-- " + value);
(*this).set (name, col_value);
}
else
{
context.debug (label + name + " <-- " + evaluated + " <-- " + value);
(*this).set (name, evaluated);
}
++modCount; ++modCount;
} }
else else
throw format (STRING_INVALID_MOD, name, value); throw format (STRING_INVALID_MOD, name, value);
} }
else
throw format ("Unrecognized column type '{1}' for column '{2}'", column->type (), name);
// Warn about deprecated/obsolete attribute usage. // Warn about deprecated/obsolete attribute usage.
legacyAttributeCheck (name); legacyAttributeCheck (name);
} }