本文整理汇总了C++中XmlNode::getAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ XmlNode::getAttribute方法的具体用法?C++ XmlNode::getAttribute怎么用?C++ XmlNode::getAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XmlNode
的用法示例。
在下文中一共展示了XmlNode::getAttribute方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadGame
void Resource::loadGame(const XmlNode *rootNode, int index,const TechTree *techTree) {
vector<XmlNode *> resourceNodeList = rootNode->getChildList("Resource");
if(index < resourceNodeList.size()) {
XmlNode *resourceNode = resourceNodeList[index];
amount = resourceNode->getAttribute("amount")->getIntValue();
type = techTree->getResourceType(resourceNode->getAttribute("type")->getValue());
pos = Vec2i::strToVec2(resourceNode->getAttribute("pos")->getValue());
balance = resourceNode->getAttribute("balance")->getIntValue();
}
}
示例2: load
void MoveSkillType::load(const XmlNode *sn, const string &dir, const TechTree *tt, const UnitType *ft) {
SkillType::load(sn, dir, tt, ft);
XmlNode *visibleOnlyNode = sn->getOptionalChild("visible-only");
if (visibleOnlyNode) {
visibleOnly = visibleOnlyNode->getAttribute("value")->getBoolValue();
}
}
示例3: parseRomBlock
Glib::ustring MameXmlReader::parseRomBlock(XmlNode& node)
{
Glib::ustring crc;
/*
* Estructura de un bloque rom:
*
* <rom/disk name="" bios="" size="" crc="" md5="" sha1="" merge="" region="" offset="" status="baddump|nodump|good" date="" optional="yes/no" />
*
*/
// Obtenemos el nombre del set
node.getAttribute("crc", crc);
return crc;
}
示例4: loadGame
void Selection::loadGame(const XmlNode *rootNode, World *world) {
const XmlNode *selectionNode = rootNode->getChild("Selection");
factionIndex = selectionNode->getAttribute("factionIndex")->getIntValue();
teamIndex = selectionNode->getAttribute("teamIndex")->getIntValue();
if(selectionNode->hasAttribute("allowSharedTeamUnits") == true) {
allowSharedTeamUnits = (selectionNode->getAttribute("allowSharedTeamUnits")->getIntValue() != 0);
}
vector<XmlNode *> selectedUnitsNodeList = selectionNode->getChildList("selectedUnits");
for(unsigned int i = 0; i < selectedUnitsNodeList.size(); ++i) {
XmlNode *selectedUnitsNode = selectedUnitsNodeList[i];
int unitId = selectedUnitsNode->getAttribute("unitId")->getIntValue();
Unit *unit = world->findUnitById(unitId);
//assert(unit != NULL);
//printf("#1 Unit [%s], group: %d\n",unit->getType()->getName().c_str(),i);
selectedUnits.push_back(unit);
}
vector<XmlNode *> groupsNodeList = selectionNode->getChildList("groups");
for(unsigned int i = 0; i < groupsNodeList.size(); ++i) {
XmlNode *groupsNode = groupsNodeList[i];
vector<XmlNode *> selectedGroupsUnitsNodeList = groupsNode->getChildList("selectedUnits");
for(unsigned int j = 0; j < selectedGroupsUnitsNodeList.size(); ++j) {
XmlNode *selectedGroupsUnitsNode = selectedGroupsUnitsNodeList[j];
int unitId = selectedGroupsUnitsNode->getAttribute("unitId")->getIntValue();
Unit *unit = world->findUnitById(unitId);
//assert(unit != NULL);
//printf("Unit #2 [%s], group: %d\n",unit->getType()->getName().c_str(),i);
groups[i].push_back(unit);
}
}
}
示例5: loadGame
void Stats::loadGame(const XmlNode *rootNode) {
const XmlNode *statsNode = rootNode->getChild("Stats");
// PlayerStats playerStats[GameConstants::maxPlayers];
vector<XmlNode *> statsNodePlayerList = statsNode->getChildList("Player");
for(unsigned int i = 0; i < statsNodePlayerList.size(); ++i) {
XmlNode *statsNodePlayer = statsNodePlayerList[i];
PlayerStats &stat = playerStats[i];
// ControlType control;
stat.control = static_cast<ControlType>(statsNodePlayer->getAttribute("control")->getIntValue());
// float resourceMultiplier;
stat.resourceMultiplier = statsNodePlayer->getAttribute("resourceMultiplier")->getFloatValue();
// string factionTypeName;
stat.factionTypeName = statsNodePlayer->getAttribute("factionTypeName")->getValue();
// FactionPersonalityType personalityType;
stat.personalityType = static_cast<FactionPersonalityType>(statsNodePlayer->getAttribute("personalityType")->getIntValue());
// int teamIndex;
stat.teamIndex = statsNodePlayer->getAttribute("teamIndex")->getIntValue();
// bool victory;
stat.victory = statsNodePlayer->getAttribute("victory")->getIntValue() != 0;
// int kills;
stat.kills = statsNodePlayer->getAttribute("kills")->getIntValue();
// int enemykills;
stat.enemykills = statsNodePlayer->getAttribute("enemykills")->getIntValue();
// int deaths;
stat.deaths = statsNodePlayer->getAttribute("deaths")->getIntValue();
// int unitsProduced;
stat.unitsProduced = statsNodePlayer->getAttribute("unitsProduced")->getIntValue();
// int resourcesHarvested;
stat.resourcesHarvested = statsNodePlayer->getAttribute("resourcesHarvested")->getIntValue();
// string playerName;
stat.playerName = statsNodePlayer->getAttribute("playerName")->getValue();
// Vec3f playerColor;
stat.playerColor = Vec3f::strToVec3(statsNodePlayer->getAttribute("playerColor")->getValue());
}
// string description;
//statsNode->addAttribute("description",description, mapTagReplacements);
description = statsNode->getAttribute("description")->getValue();
// int factionCount;
factionCount = statsNode->getAttribute("factionCount")->getIntValue();
// int thisFactionIndex;
thisFactionIndex = statsNode->getAttribute("thisFactionIndex")->getIntValue();
//
// float worldTimeElapsed;
worldTimeElapsed = statsNode->getAttribute("worldTimeElapsed")->getFloatValue();
// int framesPlayed;
framesPlayed = statsNode->getAttribute("framesPlayed")->getIntValue();
// int framesToCalculatePlaytime;
framesToCalculatePlaytime = statsNode->getAttribute("framesToCalculatePlaytime")->getIntValue();
// int maxConcurrentUnitCount;
maxConcurrentUnitCount = statsNode->getAttribute("maxConcurrentUnitCount")->getIntValue();
// int totalEndGameConcurrentUnitCount;
totalEndGameConcurrentUnitCount = statsNode->getAttribute("totalEndGameConcurrentUnitCount")->getIntValue();
// bool isMasterserverMode;
}
示例6: parseGameBlock
bool MameXmlReader::parseGameBlock(DatSet& set, XmlNode& node)
{
Glib::ustring value;
XmlNode::iterator iter;
/*
* Estructura de un bloque game:
*
* <game name="" sourcefile="" isbios=yes/no isdevice=yes/no ismechanical=yes/no runnable="yes/no" cloneof="" romof="" sampleof="" >
* <description></description>
* <year></year>
* <manufacturer></manufacturer>
* <biosset />
* <rom />
* <disk />
* <device_ref />
* <sample />
* <chip />
* <display />
* <sound />
* <input service=yes/no tilt=yes/no players="" buttons="" coins=""></input>
* <dipswitch></dipswitch>
* <configuration></configuration>
* <port></port>
* <adjuster />
* <category></category> // Aparece en xml's viejos, pero nunca se usa
* <driver />
* <device></device>
* <slot></slot>
* <softwarelist />
* <ramoption />
* </game>
*
*/
set.name.clear();
set.description.clear();
set.year.clear();
set.manufacturer.clear();
set.clone_of.clear();
set.crc.clear();
set.players = 1;
node.getAttribute("name", set.name);
// Comprobamos si es un set bios y si debemos parserlos
node.getAttribute("isbios", value);
set.is_bios = (value == "yes" ? true : false);
node.getAttribute("cloneof", set.clone_of);
// Recorremos todos los nodos del set
for (iter = node.begin(); iter != node.end(); ++iter)
{
value = iter->getName();
if (value == "description")
{
iter->getContent(set.description);
}
else if (value == "year")
{
iter->getContent(set.year);
}
else if (value == "manufacturer")
{
iter->getContent(set.manufacturer);
}
else if ((value == "rom") && set.crc.empty())
{
set.crc = parseRomBlock(*iter);
}
else if (value == "input")
{
iter->getAttribute("players", set.players);
}
}
return true;
}