• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ XmlSerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: 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


示例2: 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


示例3: serializeSettings

bool serializeSettings(const PropertyOwner* po, const std::string& filename) {
    std::ofstream stream(filename.c_str(), std::ios_base::out);
    if (stream.fail()) {
        LWARNINGC("VoreenSettings", "Unable to open file " << filename << " for writing.");
        return false;
    }

    bool success = true;
    try {
        XmlSerializer xmlSerializer;
        po->serialize(xmlSerializer);
        xmlSerializer.write(stream);
        if (stream.bad()) {
            LWARNINGC("VoreenSettings", "Unable to write to file: " << filename);
            success = false;
        }
        stream.close();
    }
    catch (SerializationException &e) {
        LWARNINGC("VoreenSettings", "SerializationException: " << e.what());
        stream.close();
        success = false;
    }
    return success;
}
开发者ID:151706061,项目名称:Voreen,代码行数:25,代码来源:propertyowner.cpp


示例4: serialize

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


示例5: serialize

void LightSourceProperty::serialize(XmlSerializer& s) const {
    FloatVec4Property::serialize(s);
    s.serialize("Center", curCenter_);
    s.serialize("LightPos", lightPos_);
    s.serialize("FollowCam", followCam_);
    s.serialize("MaxDist", maxDist_);
}
开发者ID:151706061,项目名称:Voreen,代码行数:7,代码来源:lightsourceproperty.cpp


示例6: 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


示例7: tgtAssert

void TemplatePropertyTimeline<Camera>::serialize(XmlSerializer& s) const {
    tgtAssert(property_, "No property");
    s.serialize("activeOnRendering", activeOnRendering_);
    s.serialize("propertyOwner", property_->getOwner());
    s.serialize("propertyId", property_->getID());
    s.serialize("duration", duration_);
    s.serialize("timeline", timeline_);
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:8,代码来源:templatepropertytimeline.cpp


示例8:

void NumericProperty<T>::serialize(XmlSerializer& s) const {
    Property::serialize(s);

    s.serialize("value", value_);

    // serialize tracking mode, if it differs from default value
    if (!tracking_)
        s.serialize("tracking", tracking_);
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:9,代码来源:numericproperty.cpp


示例9: serialize

void OpenCLSource::serialize(XmlSerializer& s) const {
    s.serialize("programModified", programModified_);
    std::string relPath = tgt::FileSystem::relativePath(tgt::FileSystem::dirName(programFilename_),
        tgt::FileSystem::dirName(s.getDocumentPath()));
    std::string relProgramFilename = relPath + "/" + tgt::FileSystem::fileName(programFilename_);
    s.serialize("programFilename", relProgramFilename);
    if (programModified_)
        s.serialize("programSource", programSource_);
}
开发者ID:151706061,项目名称:Voreen,代码行数:9,代码来源:openclproperty.cpp


示例10: getHash

std::string Geometry::getHash() const {
    XmlSerializer s;
    s.setUseAttributes(true);
    serialize(s);

    std::stringstream stream;
    s.write(stream);
    return VoreenHash::getHash(stream.str());
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:9,代码来源:geometry.cpp


示例11: saveFile

void GeometrySave::saveFile() {
    XmlSerializer s;
    const Geometry* geometry = inport_.getData();
    s.serialize("Geometry", geometry);

    std::fstream stream(fileProp_.get().c_str(), std::ios::out);
    s.write(stream);
    stream.close();
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:9,代码来源:geometrysave.cpp


示例12: serialize

void VolumeURLProperty::serialize(XmlSerializer& s) const {
    Property::serialize(s);

    std::string relativeURL;
    if (!value_.empty()) {
        std::string basePath = tgt::FileSystem::dirName(s.getDocumentPath());
        relativeURL = VolumeURL::convertURLToRelativePath(value_, basePath);
    }
    s.serialize("url", relativeURL);
}
开发者ID:151706061,项目名称:Voreen,代码行数:10,代码来源:volumeurlproperty.cpp


示例13: serialize

void PropertyLink::serialize(XmlSerializer& s) const {
    // Serialize source property reference...
    s.serialize("SourceProperty", src_);

    // Serialize destination property reference...
    s.serialize("DestinationProperty", dest_);

    // Serialize link evaluator...
    s.serialize("Evaluator", evaluator_);
}
开发者ID:151706061,项目名称:Voreen,代码行数:10,代码来源:propertylink.cpp


示例14: serialize

void PlotEntitiesProperty::serialize(XmlSerializer& s) const {
    Property::serialize(s);

    s.serialize("entities", static_cast<int>(entities_));
    s.serialize("xCI", xColumnIndex_);
    s.serialize("yCI", yColumnIndex_);
    s.serialize("colorMap", colorMap_);
    s.serialize("plotEntitySettingsVector", value_, "plotEntitySettings");
    s.serialize("loadStrategy",static_cast<int>(loadStrategy_));
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:10,代码来源:plotentitiesproperty.cpp


示例15: serialize

void PlotCellValue::serialize(XmlSerializer& s) const {
    s.serialize("isValue", isValue());
    s.serialize("isTag", isTag());
    s.serialize("isHighlighted", isHighlighted());

    if (isTag())
        s.serialize("tag", getTag());
    if (isValue())
        s.serialize("value", getValue());
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:10,代码来源:plotcell.cpp


示例16: serialize

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


示例17: HELIUM_TRACE

/// Save the user configuration settings.
///
/// @return  True if the configuration was saved successfully, false if not.
bool ConfigPc::SaveUserConfig()
{
    HELIUM_TRACE( TRACE_INFO, TXT( "ConfigPc: Saving user configuration.\n" ) );

    Config& rConfig = Config::GetStaticInstance();

    Package* pConfigPackage = rConfig.GetUserConfigPackage();
    if( !pConfigPackage )
    {
        HELIUM_TRACE( TRACE_WARNING, TXT( "ConfigPc: No user configuration exists to save.\n" ) );

        return false;
    }

    Path userDataDirectory;
    if ( !File::GetUserDataDirectory( userDataDirectory ) )
    {
        HELIUM_TRACE( TRACE_WARNING, TXT( "ConfigPc: No user data directory could be determined.\n" ) );
        return false;
    }

    GameObjectPath configPackagePath = pConfigPackage->GetPath();

    Path packageFilePath( userDataDirectory + configPackagePath.ToFilePathString().GetData() + HELIUM_XML_PACKAGE_FILE_EXTENSION );

    HELIUM_TRACE( TRACE_INFO, TXT( "ConfigPc: Saving configuration to \"%s\".\n" ), *packageFilePath );

    XmlSerializer serializer;
    if( !serializer.Initialize( packageFilePath.c_str() ) )
    {
        HELIUM_TRACE(
            TRACE_ERROR,
            TXT( "ConfigPc: Failed to initialize package serializer for writing to \"%s\".\n" ),
            *packageFilePath );

        return false;
    }

    for( GameObject* pConfigObject = pConfigPackage->GetFirstChild();
         pConfigObject != NULL;
         pConfigObject = pConfigObject->GetNextSibling() )
    {
        if( !pConfigObject->IsPackage() )
        {
            RecursiveSerializeObject( serializer, pConfigObject );
        }
    }

    serializer.Shutdown();

    HELIUM_TRACE( TRACE_INFO, TXT( "ConfigPc: User configuration saved.\n" ) );

    return true;
}
开发者ID:euler0,项目名称:Helium,代码行数:57,代码来源:ConfigPc.cpp


示例18: serialize

void Workspace::serialize(XmlSerializer& s) const {
    s.serialize("version", version_);

    // Serialize network...
    s.serialize("ProcessorNetwork", network_);

    // Serialize animation...
    s.serialize("Animation", animation_);

    s.serialize("GlobalDescription", description_);
}
开发者ID:151706061,项目名称:Voreen,代码行数:11,代码来源:workspace.cpp


示例19:

void TransFunc1DKeys::serialize(XmlSerializer& s) const {
    TransFunc::serialize(s);

    // serialize keys...
    s.serialize("Keys", keys_, "key");

    // serialize thresholds...
    s.serialize("lower", lowerThreshold_);
    s.serialize("upper", upperThreshold_);

    s.serialize("domain", domain_);
}
开发者ID:emmaai,项目名称:fractalM,代码行数:12,代码来源:transfunc1dkeys.cpp


示例20: serialize

void DicomDict::serialize(XmlSerializer &s) const {
    //put DictEntries into a Vector
    std::vector<DicomDictEntry> entryVector;

    std::map<std::string,DicomDictEntry>::const_iterator it;
    for (it = entries_.begin(); it != entries_.end(); ++it) {
        entryVector.push_back(it->second);
    }

    //serialize this vector
    s.setUseAttributes(false);
    s.serialize("Dict", entryVector, "entry");
}
开发者ID:151706061,项目名称:Voreen,代码行数:13,代码来源:dicomdict.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ XmlTransaction类代码示例发布时间:2022-05-31
下一篇:
C++ XmlRpcValue类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap