Mon, 23 Sep 2019 14:06:36 +0300
added regular expressions for the parser
#include "modelobject.h" static Uuid &getUuidForNewObject() { static Uuid running_uuid {0, 0}; incrementUuid(running_uuid); return running_uuid; } modelobjects::BaseObject::BaseObject() : id {getUuidForNewObject()} { } modelobjects::BaseObject::~BaseObject() { } bool modelobjects::BaseObject::hasColor() const { return false; } QVariant modelobjects::BaseObject::getProperty(Property id) const { Q_UNUSED(id); return {}; } auto modelobjects::BaseObject::setProperty(Property id, const QVariant& value) -> SetPropertyResult { Q_UNUSED(id) Q_UNUSED(value) return SetPropertyResult::PropertyNotHandled; } modelobjects::ColoredBaseObject::ColoredBaseObject(const Color color_index) : color_index{color_index} { } bool modelobjects::ColoredBaseObject::hasColor() const { return true; } QVariant modelobjects::ColoredBaseObject::getProperty(Property id) const { switch (id) { case Property::Color: return color_index.index; default: return BaseObject::getProperty(id); } } auto modelobjects::ColoredBaseObject::setProperty(Property id, const QVariant& value) -> SetPropertyResult { switch (id) { case Property::Color: { bool ok; const int value_int = value.toInt(&ok); if (ok) { color_index.index = value_int; return SetPropertyResult::Success; } else { return SetPropertyResult::InvalidValue; } } default: return BaseObject::setProperty(id, value); } }