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


C++ XmlParser::loadFile方法代码示例

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


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

示例1: getPath

void Driver::getPath(char xmlFile[20])
{
	p.loadFile(xmlFile);
	p.get_cloud_path(cpath);
	p.get_mobile_path(mpath);
	p.get_local_path(lpath);
}
开发者ID:pictgroup5,项目名称:secure,代码行数:7,代码来源:driver.cpp

示例2: loadMesh

void TesterTool::loadMesh(const string& xmlFile,
                          const string& binaryFile,
                          vector<AttributeT>& attribs,
                          vector<GroupT>& groups)
{
    XmlParser xml;
    xml.loadFile(xmlFile);

    ifstream fin(binaryFile.c_str(), ios::binary);

    xml.pushTag("Mesh");
    {
        int numVertices = xml.getAttribute("Vertices", "count", 0);
        int numAtributes = xml.getAttribute("Vertices", "attributes", 0);

        xml.pushTag("Vertices");
        {
            for(int i = 0; i < numAtributes; ++i)
            {
                AttributeT attrib;

                std::string tmpAttribName = xml.getAttribute("Attribute", "name", "", i);
                attrib.name = new char[tmpAttribName.length()+1];
                attrib.name[tmpAttribName.length()] = 0;
                memcpy(attrib.name, tmpAttribName.c_str(), tmpAttribName.size());

                attrib.size = xml.getAttribute("Attribute", "size", 0, i);
                attrib.count = numVertices * attrib.size;
                attrib.values = new float[attrib.count];

                for(int j = 0; j < numVertices; ++j)
                {
                    for(int k = 0; k < attrib.size; ++k)
                    {
                        float val = 0.0f;

                        fin.read((char *)(&val), sizeof(val));

                        attrib.values[j*attrib.size + k] = val;
                    }
                }

                attribs.push_back(attrib);
            }
        }
        xml.popTag();

        int numGroups = xml.getAttribute("Triangles", "groups", 0);
        string typeIndices = xml.getAttribute("Triangles", "type", "");

        xml.pushTag("Triangles");
        {
            for(int i = 0; i < numGroups; ++i)
            {
                GroupT group;
                group.type = new char[typeIndices.length()+1];
                group.type[typeIndices.length()] = 0;
                memcpy(group.type, typeIndices.c_str(), typeIndices.size());

                std::string tmpGrName = xml.getAttribute("Group", "name", "", i);
                group.name = new char[tmpGrName.length()+1];
                group.name[tmpGrName.length()] = 0;
                memcpy(group.name, tmpGrName.c_str(), tmpGrName.size());

                group.count = xml.getAttribute("Group", "count", 0, i);

                int numBytes = 0;

                if(string(group.type).compare("UNSIGNED_BYTE") == 0)
                {
                    numBytes = group.count * 3 * static_cast<int>(sizeof(unsigned char));
                }
                else if(string(group.type).compare("UNSIGNED_SHORT") == 0)
                {
                    numBytes = group.count * 3 * static_cast<int>(sizeof(unsigned short));
                }
                else if(string(group.type).compare("UNSIGNED_INT") == 0)
                {
                    numBytes = group.count * 3 * static_cast<int>(sizeof(unsigned int));
                }

                group.numBytes = numBytes;
                group.bytes = new unsigned char[numBytes];

                for(int j = 0; j < group.count*3; ++j)
                {
                    unsigned char val = 0;

                    fin.read((char *)(&val), sizeof(val));

                    group.bytes[j] = val;
                }

                groups.push_back(group);

            }
        }
        xml.popTag();
    }
    xml.popTag();
//.........这里部分代码省略.........
开发者ID:mengxipeng1122,项目名称:assembly3d,代码行数:101,代码来源:TesterTool.cpp


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