本文整理汇总了C++中XmlParser::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlParser::getAttribute方法的具体用法?C++ XmlParser::getAttribute怎么用?C++ XmlParser::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlParser
的用法示例。
在下文中一共展示了XmlParser::getAttribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
//.........这里部分代码省略.........