当前位置: 首页>>代码示例>>C++>>正文


C++ XmlDeserializer类代码示例

本文整理汇总了C++中XmlDeserializer的典型用法代码示例。如果您正苦于以下问题:C++ XmlDeserializer类的具体用法?C++ XmlDeserializer怎么用?C++ XmlDeserializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了XmlDeserializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: deserialize

void Processor::deserialize(XmlDeserializer& s) {
    // meta data
    metaDataContainer_.deserialize(s);

    // misc settings
    s.deserialize("name", id_);
    guiName_ = id_;

    // deserialize properties
    PropertyOwner::deserialize(s);


    // ---
    // the following entities are static resources that should not be dynamically created by the serializer
    //
    const bool usePointerContentSerialization = s.getUsePointerContentSerialization();
    s.setUsePointerContentSerialization(true);

    // deserialize inports using a temporary map
    map<string, Port*> inportMap;
    for (vector<Port*>::const_iterator it = inports_.begin(); it != inports_.end(); ++it)
        inportMap[(*it)->getID()] = *it;
    try {
        s.deserialize("Inports", inportMap, "Port", "name");
    }
    catch (XmlSerializationNoSuchDataException& /*e*/){
        // port key missing => just ignore
        s.removeLastError();
    }

    // deserialize outports using a temporary map
    map<string, Port*> outportMap;
    for (vector<Port*>::const_iterator it = outports_.begin(); it != outports_.end(); ++it)
        outportMap[(*it)->getID()] = *it;
    try {
        s.deserialize("Outports", outportMap, "Port", "name");
    }
    catch (XmlSerializationNoSuchDataException& /*e*/){
        // port key missing => just ignore
        s.removeLastError();
    }

    // deserialize interaction handlers using a temporary map
    map<string, InteractionHandler*> handlerMap;
    const std::vector<InteractionHandler*>& handlers = getInteractionHandlers();
    for (vector<InteractionHandler*>::const_iterator it = handlers.begin(); it != handlers.end(); ++it)
        handlerMap[(*it)->getID()] = *it;
    try {
        s.deserialize("InteractionHandlers", handlerMap, "Handler", "name");
    }
    catch (XmlSerializationNoSuchDataException& /*e*/){
        // interaction handler key missing => just ignore
        s.removeLastError();
    }

    s.setUsePointerContentSerialization(usePointerContentSerialization);
    // --- static resources end ---

    firstProcessAfterDeserialization_ = true;
}
开发者ID:151706061,项目名称:Voreen,代码行数:60,代码来源:processor.cpp

示例2: testComplexSTL

/**
 * Tests serialization and deserialization of cascaded STL containers
 * like @c std::vector or @c std::map.
 */
void testComplexSTL() {
    std::map<int, std::string> m1, m2, m3;
    m2[1] = "one";
    m3[2] = "two";
    m3[3] = "three";

    std::vector<std::map<int, std::string> > v;
    v.push_back(m1);
    v.push_back(m2);
    v.push_back(m3);

    std::stringstream stream;

    XmlSerializer s;
    s.serialize("v", v);
    s.write(stream);

    // Reset all variables to default values...
    v.clear();
    test(v.size() == 0, "vector is not empty");

    XmlDeserializer d;
    d.read(stream);
    d.deserialize("v", v);

    test(v.size() == 3, "not all vector item deserialized");
    test(v[0].size() == 0, "incorrect size of first vector item");
    test(v[1].size() == 1, "incorrect size of second vector item");
    test(v[2].size() == 2, "incorrect size of third vector item");
    test(v[1][1] == "one", "first item of second vector item incorrect deserialized");
    test(v[2][2] == "two", "first item of thrid vector item incorrect deserialized");
    test(v[2][3] == "three", "second item of third vector item incorrect deserialized");
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:37,代码来源:serializertest.cpp

示例3: deserializeSettings

bool deserializeSettings(PropertyOwner* po, const std::string& filename) {
    std::ifstream stream;
    stream.open(filename.c_str(), std::ios_base::in);
    if(stream.fail()) {
        stream.close();
        return false;
    }
    else {
        XmlDeserializer xmlDeserializer;
        try {
            xmlDeserializer.read(stream);
            po->deserialize(xmlDeserializer);
            stream.close();
        }
        catch (XmlSerializationNoSuchDataException) {
            // no data present => ignore
            xmlDeserializer.removeLastError();
            return false;
        }
        catch (SerializationException &e) {
            LWARNINGC("VoreenSettingsDialog", std::string("Deserialization failed: ") + e.what());
            return false;
        }
    }
    return true;
}
开发者ID:151706061,项目名称:Voreen,代码行数:26,代码来源:propertyowner.cpp

示例4: testMap

/**
 * Tests serialization and deserialization of a @c std::map.
 */
void testMap() {
    std::map<int, std::string> m;
    m[1] = "one";
    m[2] = "two";
    m[3] = "three";

    std::stringstream stream;

    XmlSerializer s;
    s.serialize("m", m);
    s.write(stream);

    // Reset all variables to default values...
    m.clear();
    test(m.size() == 0, "map is not empty");

    XmlDeserializer d;
    d.read(stream);
    d.deserialize("m", m);

    test(m.size() == 3, "not all map items deserialized");
    test(m[1] == "one", "first pair incorrect deserialized");
    test(m[2] == "two", "second pair incorrect deserialized");
    test(m[3] == "three", "third pair incorrect deserialized");
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:28,代码来源:serializertest.cpp

示例5: testIAbstractSerializable

/**
 * Tests serialization and deserialization of pointers to abstract classes.
 */
void testIAbstractSerializable() {
    Abstract* a = new Specific();
    dynamic_cast<Specific*>(a)->i = 1;

    std::stringstream stream;

    AbstractFactory factory;

    XmlSerializer s;
    s.registerFactory(&factory);
    s.serialize("Abstract", a);
    s.write(stream);

    // Reset all variables to default values...
    delete a;
    a = 0;

    XmlDeserializer d;
    d.registerFactory(&factory);
    d.read(stream);
    d.deserialize("Abstract", a);

    test(a != 0, "a still null");
    Specific* specific = dynamic_cast<Specific*>(a);
    test(specific != 0, "cast to Specific* not possible");
    test(specific->i, 1, "a incorrect deserialized");

    delete a;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:32,代码来源:serializertest.cpp

示例6: deserialize

void VolumeURLListProperty::deserialize(XmlDeserializer& s) {
    Property::deserialize(s);

    std::vector<std::string> urlList = value_;
    std::map<std::string, bool> selectMap = selectionMap_;
    s.deserialize("VolumeURLs", urlList, "url");

    try {
        s.deserialize("Selection", selectMap, "entry", "url");
    }
    catch (SerializationException& e) {
        s.removeLastError();
        LWARNING("Failed to deserialize selection map: " << e.what());
    }

    // convert URLs to absolute path
    std::string basePath = tgt::FileSystem::dirName(s.getDocumentPath());
    for (size_t i=0; i<urlList.size(); i++) {
        std::string url = urlList[i];
        std::string urlConv = VolumeURL::convertURLToAbsolutePath(url, basePath);
        urlList[i] = urlConv;
        if (selectMap.find(url) != selectMap.end()) {
            bool selected = selectMap[url];
            selectMap.erase(url);
            selectMap.insert(std::pair<std::string, bool>(urlConv, selected));
        }
    }

    value_ = urlList;
    selectionMap_ = selectMap;

    invalidate();
}
开发者ID:151706061,项目名称:Voreen,代码行数:33,代码来源:volumeurllistproperty.cpp

示例7: deserialize

void VolumeHistogramIntensityGradient::deserialize(XmlDeserializer& s) {
    s.deserialize("values", histValues_);
    s.deserialize("maxValue", maxValue_);
    s.deserialize("significantRangeIntensity", significantRangeIntensity_);
    s.deserialize("significantRangeGradient", significantRangeGradient_);
    s.deserialize("scaleFactor", scaleFactor_);
}
开发者ID:MKLab-ITI,项目名称:gnorasi,代码行数:7,代码来源:histogram.cpp

示例8: deserialize

void FontProperty::deserialize(XmlDeserializer& s) {
    Property::deserialize(s);

    int fontSize;
    std::string fontName;
    std::string fontTypeName;
    tgt::Font::FontType fontType;
    std::string textAlignmentName;
    tgt::Font::TextAlignment textAlignment;
    std::string verticalTextAlignmentName;
    tgt::Font::VerticalTextAlignment verticalTextAlignment;
    float lineWidth;

    s.deserialize("fontType", fontTypeName);
    fontType = tgt::Font::getFontType(fontTypeName);
    s.deserialize("fontSize", fontSize);
    s.deserialize("fontName", fontName);
    fontName = tgt::FileSystem::fileName(fontName);
    s.deserialize("textAlignment", textAlignmentName);
    textAlignment = tgt::Font::getTextAlignment(textAlignmentName);
    s.deserialize("verticalTextAlignment", verticalTextAlignmentName);
    verticalTextAlignment = tgt::Font::getVerticalTextAlignment(verticalTextAlignmentName);
    s.deserialize("lineWidth", lineWidth);

    if (!fontName.empty() && fontType != tgt::Font::NIL) {
        delete value_;
        set(new tgt::Font(VoreenApplication::app()->getFontPath(fontName), fontSize, fontType, lineWidth, textAlignment, verticalTextAlignment));
    }
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:29,代码来源:fontproperty.cpp

示例9: deserialize

void Property::deserialize(XmlDeserializer& s) {
    if (serializeValue_)
        return;

    // deserialize level-of-detail, if available
    try {
        int lod;
        s.deserialize("lod", lod);
        lod_ = static_cast<LODSetting>(lod);
    }
    catch (XmlSerializationNoSuchDataException&) {
        s.removeLastError();
        lod_ = USER;
    }

    // deserialize gui name, if available
    try {
        std::string temp;
        s.deserialize("guiName", temp);
        guiName_ = temp;
    }
    catch (XmlSerializationNoSuchDataException&) {
        s.removeLastError();
    }

    metaDataContainer_.deserialize(s);
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:27,代码来源:property.cpp

示例10:

void PlotDataFitFunction::FittingValues::deserialize(XmlDeserializer& s){
    int value;
    s.deserialize("regressionType",value);
    regressionType = static_cast<FunctionLibrary::RegressionType>(value);
    s.deserialize("column",column);
    mse = -1;
    s.deserialize("Dimension",dimension);
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:8,代码来源:plotdatafitfunction.cpp

示例11: deserialize

void Animation::deserialize(XmlDeserializer& s) {
    s.deserialize("processors", processors_, "Processor");
    s.deserialize("undoSteps", undoSteps_);
    s.deserialize("fps", fps_);
    s.deserialize("duration", duration_);
    s.deserialize("currentTime", currentTime_);
    s.deserialize("isRendering", isRendering_);
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:8,代码来源:animation.cpp

示例12: deserialize

void OpenCLSource::deserialize(XmlDeserializer& s) {
    //current format:
    s.deserialize("programModified", programModified_);
    s.deserialize("programFilename", programFilename_);
    programFilename_ = tgt::FileSystem::absolutePath(
        tgt::FileSystem::dirName(s.getDocumentPath())) + "/" + programFilename_;
    if (programModified_)
        s.deserialize("programSource", programSource_);
}
开发者ID:151706061,项目名称:Voreen,代码行数:9,代码来源:openclproperty.cpp

示例13: deserialize

void OctreeBrickPoolManagerDiskLimitedRam::deserialize(XmlDeserializer& s) {
    OctreeBrickPoolManagerDisk::deserialize(s);

    s.deserialize("maxRamUsed", maxRamUsed_);
    s.deserialize("nextVirtualMemoryAddress", nextVirtualMemoryAddress_);

    //set brick vector of buffers in the ram
    brickBuffersInRAM_ = std::vector<brickBufferInRAM>(maxRamUsed_/getBrickBufferSizeInBytes(),brickBufferInRAM());
    bricksOfBuffersInUsage_ = std::vector<size_t>(maxRamUsed_/getBrickBufferSizeInBytes(),0);
}
开发者ID:emmaai,项目名称:fractalM,代码行数:10,代码来源:octreebrickpoolmanagerdisk.cpp

示例14: deserialize

void FaceGeometry::deserialize(XmlDeserializer& s) {
    s.deserialize("vertices", vertices_);
    try {
        s.deserialize("normal", normal_);
        normalIsSet_ = true;
    }
    catch (...) {
        s.removeLastError();
        normalIsSet_ = false;
    }
    setHasChanged(true);
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:12,代码来源:facegeometry.cpp

示例15: deserialize

void VolumeURLProperty::deserialize(XmlDeserializer& s) {
    std::string relativeURL;
    s.deserialize("url", relativeURL);
    if (relativeURL.empty())
        value_ = "";
    else {
        std::string basePath = tgt::FileSystem::dirName(s.getDocumentPath());
        value_ = VolumeURL::convertURLToAbsolutePath(relativeURL, basePath);
    }

    Property::deserialize(s);
}
开发者ID:151706061,项目名称:Voreen,代码行数:12,代码来源:volumeurlproperty.cpp


注:本文中的XmlDeserializer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。