小编Sep*_*est的帖子

RapidXML 保存到文件中

我用谷歌搜索了一下,在将xml_document<>文档保存在.xml文件中时遇到问题。这段代码将把Chess Games Notations 保存为 XML 文件,我将把它放入一个压缩文件中,以便向其中添加多媒体文件。因此,有人可以为 XML 中存储的每个游戏添加音频评论。

#ifndef _FILEREADER_HPP
#define _FILE_READER_HPP

#include<fstream>
#include"rapidxml.hpp"
#include"Notation.h"


namespace pgnx
{
    class FileWriter
    {
        std::map<unsigned int, Tournament> data;
        std::ofstream file;
        std::string fn;
        rapidxml::xml_document<> doc;
    protected:
        void save();
    public:
        FileWriter(char* filename);
        FileWriter();
        ~FileWriter(){}
        void prepare();
        void insertTournament(Tournament);
        //Operators
        FileWriter& operator+(Tournament rhs);
        FileWriter& operator=(std::map<unsigned int, Tournament> rhs);
        FileWriter& operator=(pgnx::FileWriter rhs);
        Tournament& operator[](unsigned int index);
    };
}

#endif
Run Code Online (Sandbox Code Playgroud)

和功能

void FileWriter::prepare()
{
    using namespace rapidxml;
    xml_node<>* decl = doc.allocate_node(node_declaration);
    decl->append_attribute(doc.allocate_attribute("version", "1.0"));
    decl->append_attribute(doc.allocate_attribute("encoding", …
Run Code Online (Sandbox Code Playgroud)

rapidxml visual-c++

1
推荐指数
1
解决办法
5550
查看次数

标签 统计

rapidxml ×1

visual-c++ ×1