本文整理汇总了C++中XMLElement::Attribute方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLElement::Attribute方法的具体用法?C++ XMLElement::Attribute怎么用?C++ XMLElement::Attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLElement
的用法示例。
在下文中一共展示了XMLElement::Attribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Create_From_Stream
void cMushroom::Create_From_Stream(XMLElement* attributes)
{
int posx = 0, posy = 0;
int mushroom_type = TYPE_MUSHROOM_DEFAULT;
for (XMLElement* node = attributes->FirstChildElement(); node; node = node->NextSiblingElement())
{
const char* name = node->Attribute("name");
const char* value = node->Attribute("value");
if (!strcmp(name, "posx"))
{
posx = atoi(value);
}
else if (!strcmp(name, "posy"))
{
posy = atoi(value);
}
else if (!strcmp(name, "mushroom_type"))
{
mushroom_type = atoi(value);
}
}
Set_Pos(static_cast<float>(posx), static_cast<float>(posy));
Set_Type(static_cast<SpriteType>(mushroom_type));
}
示例2: LoadXml
bool UserXml::LoadXml(std::string file)
{
XMLDocument doc;
XMLError e = doc.LoadFile(file.c_str());
if (e != XML_SUCCESS) return false;
XMLElement* root = doc.RootElement();
if (!root) return false;
// clear
trks.clear(); trkmap.clear();
// tracks
const char* a; //int i=1; //0 = none
XMLElement* eTrk = root->FirstChildElement("track");
while (eTrk)
{
UserTrkInfo t;
a = eTrk->Attribute("n"); if (a) t.name = string(a);
a = eTrk->Attribute("date"); if (a) t.last = s2dt(a);
a = eTrk->Attribute("rate"); if (a) t.rating = s2i(a);
a = eTrk->Attribute("laps"); if (a) t.laps = s2i(a);
a = eTrk->Attribute("time"); if (a) t.time = s2r(a);
trks.push_back(t);
trkmap[t.name] = trks.size(); //i++;
eTrk = eTrk->NextSiblingElement("track");
}
return true;
}
示例3: LoadLink
string XMLHandler::LoadLink(string name)
{
XMLDocument doc;
doc.LoadFile("links.xml");
if( doc.Error() )
{
cout << "\nERROR:" << doc.ErrorID() << endl;
return "ERROR";
}
XMLElement* rootNode = doc.FirstChildElement("Links");
if (!rootNode) std::cout << "No Links element" << std::endl;
XMLElement* linkNode = rootNode->FirstChildElement("Link");
if(!linkNode) std::cout << "No link elements" << std::endl;
// Loop through XML
for( ; linkNode != NULL; linkNode = linkNode->NextSiblingElement() )
{
if( name == linkNode->Attribute("name") )
{
return linkNode->Attribute("url");
}
}
return "NOTFOUND";
}
示例4: readConfigXML
Stadium* Scanner::readConfigXML(string file)
{
string name, type, path;
double shot, move;
double npcVel, shotNpc, alturaObstaculo, freqTiro;
doc.LoadFile(file.data());
if(!doc.ErrorID())
{
XMLElement* arena = doc.FirstChildElement("aplicacao")->FirstChildElement("arquivoDaArena");
name = arena->Attribute("nome");
type = arena->Attribute("tipo");
path = arena->Attribute("caminho");
XMLElement* player = doc.FirstChildElement("aplicacao")->FirstChildElement("jogador");
player->QueryDoubleAttribute("velTiro",&shot);
player->QueryDoubleAttribute("vel",&move);
XMLElement* inimigo = doc.FirstChildElement("aplicacao")->FirstChildElement("inimigo");
inimigo->QueryDoubleAttribute("velTiro",&shotNpc);
inimigo->QueryDoubleAttribute("vel",&npcVel);
inimigo->QueryDoubleAttribute("freqTiro",&freqTiro);
XMLElement* obstacle = doc.FirstChildElement("aplicacao")->FirstChildElement("obstaculo");
obstacle->QueryDoubleAttribute("altura",&alturaObstaculo);
return readArenaSVG(path + name +"."+type,shot,move,shotNpc,npcVel,alturaObstaculo,freqTiro);
}else
{
cout << "Erro ao abrir o arquivo XML "<< file << "\n";
exit(1);
}
}
示例5: parseOPF
void Book::parseOPF(BLUnZip& zip)
{
std::string data = zip.ExtractToString(m_opf);
XMLDocument doc;
doc.Parse(data.c_str());
XMLElement* package = doc.FirstChildElement("package");
XMLElement* metadata = package->FirstChildElement("metadata");
XMLElement* manifest = package->FirstChildElement("manifest");
XMLElement* item = manifest->FirstChildElement("item");
m_title = metadata->FirstChildElement("dc:title")->GetText();
m_author = metadata->FirstChildElement("dc:creator")->GetText();
for(XMLElement* rfe = item; rfe != nullptr; rfe = rfe->NextSiblingElement("item"))
{
m_manifest.emplace(rfe->Attribute("id"), rfe->Attribute("href"));
}
XMLElement* spine = package->FirstChildElement("spine");
XMLElement* itemref = spine->FirstChildElement("itemref");
for (XMLElement* it = itemref; it != nullptr; it = it->NextSiblingElement("itemref"))
{
m_spine.push_back(it->Attribute("idref"));
}
}
示例6: getGeom
// Initialize a Geometry class given an XML element, return IQM file name
static Geometry getGeom(XMLElement *elGeom){
Geometry G;
XMLElement * trEl = check("Transform", elGeom);
vec3 T(safeAtoF(*trEl, "Tx"), safeAtoF(*trEl, "Ty"), safeAtoF(*trEl, "Tz"));
vec3 S(safeAtoF(*trEl, "Sx"), safeAtoF(*trEl, "Sy"), safeAtoF(*trEl, "Sz"));
vec3 R(safeAtoF(*trEl, "Rx"), safeAtoF(*trEl, "Ry"), safeAtoF(*trEl, "Rz"));
float rot = safeAtoF(*trEl, ("R"));
mat4 M = glm::translate(T) * glm::rotate(rot, R) * glm::scale(S);
// Create a Material
XMLElement * matEl = check("Material", elGeom);
float shininess(safeAtoF(*matEl, "shininess"));
float reflectivity(safeAtoF(*matEl, "reflectivity"));
vec4 diff(safeAtoF(*matEl, "Dr"), safeAtoF(*matEl, "Dg"), safeAtoF(*matEl, "Db"), safeAtoF(*matEl, "Da"));
vec4 spec(safeAtoF(*matEl, "Sr"), safeAtoF(*matEl, "Sg"), safeAtoF(*matEl, "Sb"), safeAtoF(*matEl, "Sa"));
Material mat(shininess, reflectivity, diff, spec);
if (matEl->Attribute("Texture"))
mat.SetTexMapSrc(matEl->Attribute("Texture"));
if (matEl->Attribute("Normal"))
mat.SetNrmMapSrc(matEl->Attribute("Normal"));
// Set values
G = Geometry("../Resources/IQM/" + string(elGeom->Attribute("fileName")));
G.leftMultM(M);
G.setMaterial(mat);
return G;
}
示例7: Create_From_Stream
void cEato::Create_From_Stream(XMLElement* attributes)
{
int posx = 0, posy = 0;
std::string image_dir = m_img_dir;
std::string direction = Get_Direction_Name(m_start_direction);
for (XMLElement* node = attributes->FirstChildElement(); node; node = node->NextSiblingElement())
{
const char* name = node->Attribute("name");
const char* value = node->Attribute("value");
if (!strcmp(name, "posx"))
{
posx = atoi(value);
}
else if (!strcmp(name, "posy"))
{
posy = atoi(value);
}
else if (!strcmp(name, "image_dir"))
{
image_dir = value;
}
else if (!strcmp(name, "direction"))
{
direction = value;
}
}
Set_Pos(static_cast<float>(posx), static_cast<float>(posy), 1);
Set_Image_Dir(image_dir.c_str());
Set_Direction(Get_Direction_Id(direction.c_str()));
}
示例8: SetId
void
GameObject::Load( XMLElement & e )
{
const char * attrib = e.Attribute("id");
if ( !attrib ) throw AttributeMissingException("Attribute id is missing!");
SetId(attrib);
attrib = e.Attribute("description");
if ( !attrib ) throw AttributeMissingException("Attribute description is missing!");
SetDescription(attrib);
attrib = e.Attribute("name");
if ( !attrib ) throw AttributeMissingException("Attribute name is missing!");
SetName(attrib);
attrib = e.Attribute("match");
if ( attrib)
{
SetNamePattern(attrib);
}
// Load properties
XMLElement *props = e.FirstChildElement("Properties");
if ( props ) LoadProperties( *props);
XMLElement *items = e.FirstChildElement("Items");
if ( items ) LoadItems(*items);
else g_Log << "There were no items...\n";
}
示例9: _configureSinusoidal
void CEnvironment::_configureSinusoidal ( void ){
/* Read components from XML file */
XMLDocument conf;
conf.LoadFile( m_sSourceFile.c_str() );
XMLElement* root = conf.FirstChildElement();
string elemName, attr;
SFreqCmp tmp_FC;
for( XMLElement* elem = root->FirstChildElement() ; elem != NULL ; elem = elem->NextSiblingElement() ){
elemName = elem->Value();
if ( elemName == "Cmp" ){
attr = elem->Attribute("period");
tmp_FC.period = atof( attr.c_str() ) / float ( m_nSampling );
attr = elem->Attribute("phase");
tmp_FC.phs = atof( attr.c_str() );
attr = elem->Attribute("amplitude");
tmp_FC.amp = m_fAmplitude * atof( attr.c_str() );
if ( tmp_FC.period > 0.0 ){
m_vInputSignal [ int ( float( m_nFFTsize ) / tmp_FC.period ) ] = tmp_FC;
m_vNCAmp [ int ( float( m_nFFTsize ) / tmp_FC.period ) ] = tmp_FC.amp;
}
else{
m_vInputSignal [ 0 ] = tmp_FC;
m_vNCAmp [ 0 ] = tmp_FC.amp;
}
}
}
return;
};
示例10: while
XMLElement * Utils::w(XMLElement * element, const char * name, const char * attribute, const char * value){
XMLElement * sibilingElement = element->NextSiblingElement(name);
while (sibilingElement != NULL && strcmp(sibilingElement->Attribute(attribute), value) != 0) {
sibilingElement = sibilingElement->NextSiblingElement(name);
}
return sibilingElement == NULL || strcmp(sibilingElement->Attribute(attribute), value) != 0 ? NULL : sibilingElement;
}
示例11: readHelicopterConfig
Helicopter XMLConfig::readHelicopterConfig(const char * path){
XMLDocument doc;
doc.LoadFile(path);
XMLElement* helicoptero = doc.FirstChildElement("aplicacao")->FirstChildElement("helicoptero");
Helicopter h = Helicopter(atof(helicoptero->Attribute("velTiro")),
atof(helicoptero->Attribute("velHelicoptero")),
atof(helicoptero->Attribute("tempoDeVoo")));
return h;
}
示例12:
int
CSettings::ParseOutputs(XMLElement *Outputs)
{
// Parse Outputs
XMLElement *Output = Outputs->FirstChildElement("output");
int NumberOfOutputs = 0;
while(Output)
{
OutputContainer OutputParse;
NumberOfOutputs++;
if(!Output->Attribute("name"))
{
Log.error("Output entry has no name\n");
return false;
}
// Check if there is a duplicate name
OutputParse.name = Output->Attribute("name");
for(list<OutputContainer>::iterator i=OutputsDB.begin(); i != OutputsDB.end(); ++i)
{
if(OutputParse.name.compare((*i).name) == 0)
{
Log.error("Duplicate output name [%s]\n", OutputParse.name.c_str());
return false;
}
}
OutputParse.type = Output->Attribute("type");
XMLNode *OutSettings = Output->FirstChild();
while(OutSettings)
{
if(OutSettings->Value() && OutSettings->ToElement()->GetText())
{
OutputParse.settings[OutSettings->Value()] = OutSettings->ToElement()->GetText();
Log.debug("parsed [%s]=[%s]", OutSettings->Value(), OutputParse.settings[OutSettings->Value()].c_str());
}
OutSettings = OutSettings->NextSibling();
}
OutputsDB.push_back(OutputParse);
Output = Output->NextSiblingElement("output");
}
Log.log("Parsed %d outputs\n", NumberOfOutputs);
return true;
}
示例13: readXMLDoc
TestData readXMLDoc() {
XMLDocument doc;
#ifdef WIN32
XMLCheckResult(doc.LoadFile("../../test/mpw_tests.xml"));
#else
XMLCheckResult(doc.LoadFile("mpw_tests.xml"));
#endif
TestData data;
XMLNode * pRoot = doc.FirstChild();
if (pRoot == 0) return data;
XMLElement * pListElement = pRoot->FirstChildElement("case");
TestData testData;
while (pListElement != 0) {
//We have a test case. Allocate memory for it.
TestCase testCase;
//Get the ID of this case
std::string id = pListElement->Attribute("id");
std::cout << "ID: " << id << std::endl;
//Now check if we have a parent.
const char* pParent = pListElement->Attribute("parent");
if (pParent) {
testCase = testData.at(pParent);
}
//Now fill in the data from this node.
XMLElement * pNodeListElement = pListElement->FirstChildElement();
while (pNodeListElement != 0) {
const char* name = pNodeListElement->Name();
const char* value = pNodeListElement->GetText();
if (value != 0) {
testCase[name] = value;
std::cout << name << ": " << testCase[name] << std::endl;
}
else {
testCase[name] = "";
std::cout << name << ": " << "null" << std::endl;
}
pNodeListElement = pNodeListElement->NextSiblingElement();
}
testData[id] = testCase;
pListElement = pListElement->NextSiblingElement("case");
}
return testData;
}
示例14: readEnemyHelicopter
Helicopter XMLConfig::readEnemyHelicopter(const char* path, float cx, float cy){
XMLDocument doc;
doc.LoadFile(path);
XMLElement* helicoptero = doc.FirstChildElement("aplicacao")->FirstChildElement("helicopteroInimigo");
Helicopter h =
Helicopter(atof(helicoptero->Attribute("freqTiro")),
atof(helicoptero->Attribute("velHelicoptero")),
cx,
cy);
// <helicopteroInimigo freqTiro="0.0001" velHelicoptero="0.1"></helicopteroInimigo>
return h;
}
示例15: LoadTriggersConfig
void TriggerManager::LoadTriggersConfig(const std::string& moduleDir, std::vector<TriggerParameters>& trigsParams)
{
trigsParams.clear();
std::string file(moduleDir + "triggersConfig.xml");
XMLDocument doc;
if(doc.LoadFile(file.c_str()) != XML_SUCCESS)
{
throw -1;
}
XMLElement* root = doc.RootElement();
// Look for first trigger
XMLElement* firstTrigger = root->FirstChildElement("Trigger");
// Read all triggers
for(XMLElement* trigger = firstTrigger; trigger != nullptr; trigger = trigger->NextSiblingElement())
{
TriggerParameters trigParams;
// Get trigger id
trigParams.sensorId = std::atoi(trigger->Attribute("sensorId"));
// Get trigger type
trigParams.type = Util::Enums::TriggerTypeFromString(trigger->Attribute("sensorType"));
// Read xml elements
XMLElement* threshold = trigger->FirstChildElement("Threshold");
XMLElement* scanTime = trigger->FirstChildElement("ScanTime");
XMLElement* maskTime = trigger->FirstChildElement("MaskTime");
XMLElement* response = trigger->FirstChildElement("Response");
trigParams.threshold = (short) std::atoi(threshold->GetText());
trigParams.scanTime = (unsigned int) std::atoi(scanTime->GetText());
trigParams.maskTime = std::atoi(maskTime->GetText());
trigParams.response = Util::Enums::CurveTypeFromString(response->GetText());
//XXX Reading only sensor type
LoadSensorsConfig(moduleDir, trigParams.sensorType);
//trigParams.sensorType = IO::SensorType::Hdd;
trigsParams.push_back(trigParams);
}
return;
}