本文整理汇总了C++中TiXmlElement::QueryIntAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::QueryIntAttribute方法的具体用法?C++ TiXmlElement::QueryIntAttribute怎么用?C++ TiXmlElement::QueryIntAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::QueryIntAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPlayerColor
// Retrieves the color for player indicated in the 'controller' parameter from
// config file indicated in 'config_file' and returns it as type 'probe_color'.
// This functions will only load colors from the config file that are formatted
// in a 24 bit format. Because of this, when you use ConfigManager::SetPlayerColor()
// you must make sure it is saving a color that is formatted in a 24 bit format.
// Please note that even though this function loads a 24 bit color, it'll reformat
// it so where it is a 32 bit color that'll include the value in 'cAlpha'.
const probe_color ConfigManager::GetPlayerColor(int controller, Uint8 cAlpha)
{
Uint8 cRed;
Uint8 cGreen;
Uint8 cBlue;
TiXmlHandle docHandle( config_file );
TiXmlElement* key = docHandle.FirstChild( "Balder" ).FirstChild( "Player" ).Element();
while(key)
{
int c;
int result = key->QueryIntAttribute("controller",&c);
if (TIXML_SUCCESS == result){
if (controller == c){
TiXmlHandle h(key);
TiXmlElement *clrEl = h.FirstChild("Probe").FirstChild("Color").Element();
if (!clrEl) { return (probe_color)0;}
int colorSelected;
int gotColor = clrEl->QueryIntAttribute("probe_color", &colorSelected);
if (TIXML_SUCCESS == gotColor) {
if (colorSelected > 0xFFFFFF) colorSelected = 0xFFFFFF;
else if (colorSelected < 0) colorSelected = 0;
colorSelected = colorSelected << 8;
colorSelected += cAlpha;
return colorSelected;
}
}
}
key=key->NextSiblingElement("Player");
}
return 0;
}
示例2: getBusMappings
void HTContext::getBusMappings(std::map<int, int>& m)
{
TiXmlDocument doc("../mapping.xml");
if (!doc.LoadFile())
{
printf("GETBUSMAPPINGS: Unable to read config file!\n");
return;
}
TiXmlHandle handle(&doc);
TiXmlElement* curElem = handle.FirstChildElement().FirstChildElement("mapping").ToElement();
if (!curElem)
{
printf("GETBUSMAPPINGS: Unable to find \"mapping\" elements!\n");
return;
}
for (;curElem != 0; curElem = curElem->NextSiblingElement("mapping"))
{
int bus;
int address;
curElem->QueryIntAttribute("bus", &bus);
curElem->QueryIntAttribute("id", &address);
m.insert(std::pair<int, int>(bus, address));
printf("MAPPING: BUS: %i to ADDRESS: %i\n", bus, address);
}
}
示例3: GetBkgPingCheckOpt
BOOL GetBkgPingCheckOpt(PBBS_BKG_PINGCHECK_OPT pPingOpt)
{
TiXmlDocument doc;
const char *pszCustomDest = NULL;
bool bOperating = false;
int nBreakInt = 0;
int nPingInt = 0;
int nMaxCount = 0;
if( CheckValidXML(&doc) == FALSE )
{
return FALSE;
}
TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("BkgPingCheck");
pElem->QueryBoolAttribute("Operating", &bOperating);
pElem->QueryIntAttribute("BreakInterval", &nBreakInt);
pElem->QueryIntAttribute("PingInterval", &nPingInt);
pElem->QueryIntAttribute("MaxCheckCnt", &nMaxCount);
pszCustomDest = pElem->Attribute("CustomDestAddr");
pPingOpt->bOperating = bOperating;
pPingOpt->dwBreakInterval = nBreakInt;
pPingOpt->dwPingInterval = nPingInt;
pPingOpt->dwMaxCheckCount = nMaxCount;
mbstowcs(pPingOpt->tszCustomDestAddr, pszCustomDest, strlen(pszCustomDest));
return TRUE;
}
示例4: Read
bool ConfigManager::Read(const wxString& name, wxColour* ret)
{
wxString key(name);
TiXmlElement* e = AssertPath(key);
TiXmlHandle parentHandle(e);
TiXmlElement *c = (TiXmlElement *) parentHandle.FirstChild(cbU2C(key)).FirstChild("colour").Element();
if (c)
{
const char *isNull = c->Attribute("null");
if (isNull && strcmp(isNull, "true") == 0)
{
*ret = wxNullColour;
return true;
}
else
{
int r, g, b;
if (c->QueryIntAttribute("r", &r) == TIXML_SUCCESS
&& c->QueryIntAttribute("g", &g) == TIXML_SUCCESS
&& c->QueryIntAttribute("b", &b) == TIXML_SUCCESS)
{
ret->Set(r, g, b);
return true;
}
}
}
*ret = wxNullColour;
return false;
}
示例5: Deserialize
void FEPlayer::Deserialize(TiXmlDocument* _poXmlDoc, TiXmlElement* _poParent)
{
TiXmlElement* poElement = _poParent->FirstChildElement("Player");
if(poElement)
{
int isMovable, isDeletable;
poElement->QueryIntAttribute("is_movable", &isMovable);
poElement->QueryIntAttribute("is_deletable", &isDeletable);
if(isMovable)
AddFlags(EFEFlag_Movable);
else
RemoveFlags(EFEFlag_Movable);
if(isDeletable)
AddFlags(EFEFlag_Deletable);
else
RemoveFlags(EFEFlag_Deletable);
TiXmlElement* poPosElement = poElement->FirstChildElement("Position");
D_CHECK(poPosElement);
double x, y;
poPosElement->QueryDoubleAttribute("x", &x);
poPosElement->QueryDoubleAttribute("y", &y);
SetPosition(Vec3(x, y, 0.f));
SetColor(GetColor(m_id));
}
}
示例6: Init
void ObjectRef::Init(TiXmlNode *node)
{
TiXmlElement *element = node->ToElement();
if (element)
{
int intValue;
if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
id = intValue;
else
id = 0;
if (element->QueryIntAttribute("timeline", &intValue) == TIXML_SUCCESS)
timeline = intValue;
else
timeline = 0;
if (element->QueryIntAttribute("key", &intValue) == TIXML_SUCCESS)
key = intValue;
else
key = 0;
if (element->QueryIntAttribute("z_index", &intValue) == TIXML_SUCCESS)
z_index = intValue;
else
z_index = 0;
}
}
示例7: readAttributes
void GUI_Button::readAttributes(TiXmlElement* p_element)
{
TiXmlElement* e = p_element->FirstChildElement("Title");
if(e)
{
const char* p_title = e->GetText();
setTitle(p_title ? p_title : "");
}
e = p_element->FirstChildElement("Image");
if(e)
{
const char* p_imageFilename = e->GetText();
if(p_imageFilename) setImageFilename(localizeString(p_imageFilename));
e->QueryIntAttribute("u", &positionOnTexture.x);
e->QueryIntAttribute("v", &positionOnTexture.y);
e->QueryIntAttribute("u2", &clickedPositionOnTexture.x);
e->QueryIntAttribute("v2", &clickedPositionOnTexture.y);
}
e = p_element->FirstChildElement("ExtendedStyle");
if(e) style = 1;
}
示例8: ParseMessages
void SerializedMessageList::ParseMessages(TiXmlElement *root)
{
#ifdef KNET_USE_TINYXML
TiXmlElement *node = root->FirstChildElement("message");
while(node)
{
SerializedMessageDesc desc;
int success = node->QueryIntAttribute("id", (int*)&desc.id);
if (success == TIXML_NO_ATTRIBUTE)
{
KNET_LOG(LogError, "Error parsing message attribute 'id' as int!");
node = node->NextSiblingElement("message");
continue;
}
success = node->QueryIntAttribute("priority", (int*)&desc.priority);
if (success == TIXML_NO_ATTRIBUTE)
desc.priority = 0; // If priority not specified, use the default priority of zero - the lowest priority possible.
if (node->Attribute("name"))
desc.name = node->Attribute("name");
desc.reliable = ParseBool(node->Attribute("reliable"));
desc.inOrder = ParseBool(node->Attribute("inOrder"));
desc.data = ParseNode(node, 0);
// Work a slight convenience - if there is a single struct inside a single struct inside a single struct - jump straight through to the data.
messages.push_back(desc);
node = node->NextSiblingElement("message");
}
#else
throw NetException("kNet was built without TinyXml support! SerializedMessageList is not available!");
#endif
}
示例9: LoadActionsXML
bool LoadActionsXML(TiXmlHandle hActions, int enjoyments[], int enjoymentsMods[], int enjoymentsTemps[])
{
TiXmlElement* pActions = hActions.ToElement();
if (pActions == 0) return false;
for (int x = 0; x < NUM_ACTIONTYPES; ++x)
{
TiXmlElement* pAction = pActions->FirstChildElement(XMLifyString(actionTypeNames[x]));
// `J` a fix for the old WORKINTERN changed to WORKTRAINING
if (x == ACTION_WORKTRAINING && !pAction) pAction = pActions->FirstChildElement(XMLifyString("WORKINTERN"));
if (pAction)
{
int tempInt = 0;
if (pAction->Attribute("Enjoys")) pAction->QueryIntAttribute("Enjoys", &tempInt);
if (tempInt < -100) tempInt = -100; if (tempInt > 100) tempInt = 100;
enjoyments[x] = tempInt;
tempInt = 0;
if (pAction->Attribute("Mod")) pAction->QueryIntAttribute("Mod", &tempInt);
enjoymentsMods[x] = tempInt;
tempInt = 0;
if (pAction->Attribute("Temp")) pAction->QueryIntAttribute("Temp", &tempInt);
enjoymentsTemps[x] = tempInt;
}
}
return true;
}
示例10: loadCache
void ClassifierSVM::loadCache(TiXmlElement* settings, boost::filesystem::path file){
clearData();
svm = svm_load_model(file.c_str());
TiXmlElement* pScales = settings->FirstChildElement("scales");
if(!pScales){
throw "Bad cache file - no scales";
}
pScales->QueryIntAttribute("desc_len", &descLen);
scalesSub = new double[descLen];
scalesDiv = new double[descLen];
TiXmlElement* pValue = pScales->FirstChildElement("value");
while(pValue){
int d = -1;
pValue->QueryIntAttribute("idx", &d);
if(d == -1){
throw "Bad cache file - no idx for value";
}
pValue->QueryDoubleAttribute("sub", &scalesSub[d]);
pValue->QueryDoubleAttribute("div", &scalesDiv[d]);
pValue = pValue->NextSiblingElement();
}
TiXmlElement* pLabels = settings->FirstChildElement("labels");
if(!pLabels){
throw "Bad cache file - no labels";
}
pLabels->QueryIntAttribute("num", &numLabels);
}
示例11: importTemplate
void Graphe::importTemplate(QString & filename){
TiXmlDocument doc(filename.toStdString());
if(doc.LoadFile()){
//TiXmlHandle hDoc(&doc);
TiXmlElement * pRoot;
TiXmlElement * pChildren;
std::string temps;
TiXmlElement * pGraph;
pGraph = doc.FirstChildElement("Graph");
if(pGraph){
pRoot = pGraph->FirstChildElement("Nodes");
int i, x, y;
if(pRoot){
pChildren = pRoot->FirstChildElement("Node");
while(pChildren){
pChildren->QueryIntAttribute("id", &i);
if(i<n){
pChildren->QueryIntAttribute("x", &x);
pChildren->QueryIntAttribute("y", &y);
noeuds[i]= Noeud(x,y);
//qDebug()<<i;
if(pChildren->QueryStringAttribute("Label", &temps) == TIXML_SUCCESS){
//qDebug()<<QString(temps.c_str());
labels[i]= QString(temps.c_str());
}
}
pChildren = pChildren->NextSiblingElement("Node");
}
}
}
}
}
示例12: create_generator_from_node
GeneratorPtr Session::create_generator_from_node(TiXmlElement* element, Region* region){
fsom::DebugStream << "Attempting to create generator"<<std::endl;
GeneratorPtr gen = GeneratorPtr(new Generator(Generator::GEN_Sine,dspCreationStruct(region)));
TiXmlElement* basicInfoElement = element->FirstChildElement("BasicInfo");
if(basicInfoElement){
fsom::DebugStream << "Generator basic info found"<<std::endl;
int genType,noiseState;
std::string path = basicInfoElement->Attribute("Path");
basicInfoElement->QueryIntAttribute("GenType",&genType);
basicInfoElement->QueryIntAttribute("NoiseState",&noiseState);
Generator::GeneratorType type = Generator::GeneratorType(genType);
gen->set_generator_voice(type);
gen->set_noise_state(noiseState);
gen->set_file_path(path);
fsom::DebugStream << "noise state for gen set to "<<noiseState<<std::endl;
fsom::DebugStream << "gen type = "<<genType<<std::endl;
}
TiXmlElement * child = element->FirstChildElement("Parameter");
while(child){
fsom::DebugStream << "Parameter in generator found"<<std::endl;
ParameterPtr p = create_parameter_from_node(child, region);
gen->get_parameter(p->get_name())->set_value(p->get_value());
child = child->NextSiblingElement("Parameter");
}
return gen;
}
示例13: ReadFromXML
bool CSPropExcitation::ReadFromXML(TiXmlNode &root)
{
if (CSProperties::ReadFromXML(root)==false) return false;
TiXmlElement *prop = root.ToElement();
if (prop==NULL) return false;
int iHelp;
if (prop->QueryIntAttribute("Number",&iHelp)!=TIXML_SUCCESS) uiNumber=0;
else uiNumber=(unsigned int)iHelp;
if (prop->QueryIntAttribute("Type",&iExcitType)!=TIXML_SUCCESS) return false;
if (ReadVectorTerm(Excitation,*prop,"Excite",0.0)==false) return false;
ReadTerm(m_Frequency,*prop,"Frequency");
ReadTerm(Delay,*prop,"Delay");
TiXmlElement *weight = prop->FirstChildElement("Weight");
if (weight!=NULL)
{
ReadTerm(WeightFct[0],*weight,"X");
ReadTerm(WeightFct[1],*weight,"Y");
ReadTerm(WeightFct[2],*weight,"Z");
}
ReadVectorTerm(PropagationDir,*prop,"PropDir",0.0);
return true;
}
示例14: doc
// A font is specified by two files: a TGA file with the rendered
// chars for the font, and a XML file which contains global info
// about the font and the texture coordinates and width of each char
// The parameter fontName is the filename without extension.
// It is assumed that the files are "fontName.xml" and "fontName.tga"
bool
VSFontLib::load(std::string fontName)
{
// Test if image file exists
FILE *fp;
std::string s;
s = fontName + ".tga";
fp = fopen(s.c_str(),"r");
if (fp == NULL) {
VSResourceLib::sLogError.addMessage("Unable to find font texture: %s", s.c_str());
return false;
}
mFontTex = loadRGBATexture(s);
s = fontName + ".xml";
TiXmlDocument doc(s.c_str());
bool loadOK = doc.LoadFile();
if (!loadOK) {
VSResourceLib::sLogError.addMessage("Problem reading the XML font definition file: %s", s.c_str());
return false;
}
TiXmlHandle hDoc(&doc);
TiXmlHandle hRoot(0);
TiXmlElement *pElem;
pElem = hDoc.FirstChildElement().Element();
if (0 == pElem)
return false;
hRoot = TiXmlHandle(pElem);
pElem->QueryIntAttribute("numchars",&mNumChars);
if (mNumChars == 0)
return false;
hRoot = hRoot.FirstChild("characters");
pElem = hRoot.FirstChild("chardata").Element();
if (pElem)
pElem->QueryIntAttribute("hgt",&mHeight);
VSFLChar aChar;
int charCode, numChars = 0;
for(; 0 != pElem; pElem = pElem->NextSiblingElement(), ++numChars) {
pElem->QueryIntAttribute("char",&charCode);
pElem->QueryIntAttribute("wid",&(aChar.width));
pElem->QueryFloatAttribute("X1", &(aChar.x1));
pElem->QueryFloatAttribute("X2", &(aChar.x2));
pElem->QueryFloatAttribute("Y1", &(aChar.y1));
pElem->QueryFloatAttribute("Y2", &(aChar.y2));
pElem->QueryIntAttribute("A", &(aChar.A));
pElem->QueryIntAttribute("C", &(aChar.C));
mChars[(unsigned char)charCode] = aChar;
}
VSResourceLib::sLogInfo.addMessage("Font has %d chars", numChars);
return true;
}
示例15: GetExerciseData
BOOL CMExerciseList::GetExerciseData(const char *eid, TExerciseListItem &item)
{
BOOL ret = FALSE;
CMString sPath = CMGlobal::TheOne().GetUserDir() + L"examexercise.xml";
TiXmlDocument *pDoc = new TiXmlDocument(sPath);
if(!pDoc)
return ret;
if(CMFile::FileExist(sPath))
{
pDoc->LoadFile(TIXML_ENCODING_UTF8);
if(!pDoc->Error())
{
TiXmlElement *pRoot = pDoc->RootElement();
if(pRoot)
{
TiXmlElement* pQuestion = pRoot->FirstChildElement("question");
while(pQuestion)
{
const char* sid = pQuestion->Attribute("id");
if (strcmp(sid, eid) == 0)
{
int curindex = 0;
pQuestion->QueryIntAttribute("index", &curindex);
item.nCurIndex = curindex;
int rightcount = 0;
pQuestion->QueryIntAttribute("rightcount", &rightcount);
item.nRightCount = rightcount;
TiXmlElement* pItem = pQuestion->FirstChildElement("item");
int wrongcount = 0;
while (pItem)
{
int nWrong = 0;
pItem->Attribute("iswrong", &nWrong);
if (nWrong == 1) {
wrongcount++;
}
pItem = pItem->NextSiblingElement("item");
}
item.nWrongCount = wrongcount;
}
pQuestion = pQuestion->NextSiblingElement("question");
}
}
}
}
SAFEDELETE(pDoc);
return ret;
}