Ejemplo n.º 1
0
void FileDialogProperty::deserialize(XmlDeserializer& s) {
    Property::deserialize(s);

    // An empty serialized value does not necessarily mean that it wasn't set, but could also mean that it was the
    // same path as the document path passed during serialization, which makes the relative path empty.  We need an
    // extra bool to remember if this was the case.
    try {
        bool noPathSet;
        s.deserialize("noPathSet", noPathSet);
        if(noPathSet) {
            set("");
            return;
        }
    }
    catch (XmlSerializationNoSuchDataException) {
        s.removeLastError();
    }

    std::string value;
    s.deserialize("value", value);

    // convert path relative to the document's path to an absolute one
    if (!s.getDocumentPath().empty())
        value = tgt::FileSystem::absolutePath(tgt::FileSystem::dirName(s.getDocumentPath()) + "/" + value);

    try {
        set(value);
    }
    catch (Condition::ValidationFailed& e) {
        s.addError(e);
    }
}
Ejemplo n.º 2
0
void ColorMapProperty::deserialize(XmlDeserializer& s) {
    Property::deserialize(s);

    ColorMap cm = ColorMap::createColdHot();
    s.deserialize("colors", cm);
    try {
        value_ = cm;
    }
    catch (Condition::ValidationFailed& e) {
        s.addError(e);
    }
}
Ejemplo n.º 3
0
void OptionPropertyBase::deserialize(XmlDeserializer& s) {
    Property::deserialize(s);

    std::string id;
    s.deserialize("value", id);
    try {
        select(id);
    }
    catch (Condition::ValidationFailed& /*e*/) {
        s.addError("Invalid option value: " + id);
    }
}
Ejemplo n.º 4
0
void NumericProperty<T>::deserialize(XmlDeserializer& s) {
    Property::deserialize(s);

    // deserialize value
    T value;
    s.deserialize("value", value);
    try {
        set(value);
    }
    catch (Condition::ValidationFailed& e) {
        s.addError(e);
    }

    // deserialize tracking mode, if available
    try {
        s.deserialize("tracking", tracking_);
    }
    catch (XmlSerializationNoSuchDataException&) {
        s.removeLastError();
    }
}