本文整理汇总了C++中TiXmlElement::QueryValueAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::QueryValueAttribute方法的具体用法?C++ TiXmlElement::QueryValueAttribute怎么用?C++ TiXmlElement::QueryValueAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlElement
的用法示例。
在下文中一共展示了TiXmlElement::QueryValueAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TiXmlDocument
Progress::Progress(void)
{
Logger::DiagnosticOut() << "Loading progress record\n";
//Load XML
TiXmlDocument doc = TiXmlDocument("Progress.xml");
doc.LoadFile();
TiXmlElement* root = doc.FirstChildElement("Progress");
if(root)
{
TiXmlElement* record = root->FirstChildElement("Record");
int record_number = 0;
while(record)
{
std::string filename = "";
bool completed = false;
bool error = false;
error |= (record->QueryValueAttribute("Filename", &filename) != TIXML_SUCCESS);
error |= (record->QueryValueAttribute("Completed", &completed) != TIXML_SUCCESS);
if(error)
Logger::DiagnosticOut() << "Error parsing record number: " << record_number << ". Possible data: Filename:" << filename << ", completed: " << completed << "\n";
else
{
ProgressRecord pr;
pr.completed = completed;
progress_[filename] = pr;
}
record = record->NextSiblingElement("Record");
record_number++;
}
}
}
示例2: x
// Component transform
void
CEntityBuilder::buildTransform (TiXmlElement *pNode, Entity* e, Resources *pResource){
TiXmlElement *pChar = pNode->FirstChildElement("position");
if ( pChar) {
int x(0), y(0);
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "x", &x) &&
TIXML_SUCCESS == pChar->QueryValueAttribute( "y", &y) ) {
e->addComponent(new Transform((float) x, (float) y));
return;
}
}
LOG2ERR<<"Bad xml description for [Tranform] component\n";
throw "Bad xml description for [Tranform] component";
}
示例3: addCommonAttributes
void
CEntityBuilder::buildComponentResourcesImage( TiXmlElement *pNode, Entity *e, Resources *pResource ){
TiXmlElement *pChar = pNode->FirstChildElement("image");
if ( pChar) {
std::string alias;
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "alias", &alias)){
BVisual *image = pResource->makeImage( alias);
addCommonAttributes(pNode, pResource, image);
// std::string gui;
// if ( TIXML_SUCCESS == pNode->QueryValueAttribute( "gui", &gui)) {
// if (gui == "true") {
// image->setGUI(true);
// } else {
// image->setGUI(false);
// }
// }
// std::string center;
// if ( TIXML_SUCCESS == pNode->QueryValueAttribute( "center", ¢er)) {
// if (center == "false") {
// image->setCenter(0, 0);
// }
// }
// int zOrder;
// if ( TIXML_SUCCESS == pNode->QueryValueAttribute( "z-order", &zOrder)) {
// image->setZOrder(zOrder);
// }
e->addComponent( image);
return;
}
}
LOG2ERR<<"Bad kind for [Resources/Image] component\n";
throw "Bad kind for [Resources/Image] component";
}
示例4: loadDatabase
void ObjectLibrary::loadDatabase(string filename) {
TiXmlDocument doc(filename);
if (!doc.LoadFile()) {
Error::addMessage(Error::FILE_NOT_FOUND, LIBGENS_LIBRARY_ERROR_FILE + filename);
return;
}
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem;
TiXmlHandle hRoot(0);
pElem=hDoc.FirstChildElement().Element();
if (!pElem) {
Error::addMessage(Error::EXCEPTION, LIBGENS_LIBRARY_ERROR_FILE_ROOT);
return;
}
pElem=pElem->FirstChildElement();
for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
string entry_name="";
string category_name="";
string folder_name="";
entry_name = pElem->ValueStr();
pElem->QueryValueAttribute(LIBGENS_LIBRARY_NAME_ATTRIBUTE, &category_name);
pElem->QueryValueAttribute(LIBGENS_LIBRARY_FOLDER_ATTRIBUTE, &folder_name);
if ((entry_name==LIBGENS_LIBRARY_ENTRY) && category_name.size() && folder_name.size()) {
loadCategory(category_name, folder_name);
}
}
}
示例5: doc
/*
--------------------------------------------------------------------------------------------------
- get a text from file
--------------------------------------------------------------------------------------------------
*/
std::map<long, std::string> MapInfoXmlReader::LoadTextFile(const std::string &Filename)
{
std::map<long, std::string> res;
TiXmlDocument doc(Filename);
if (!doc.LoadFile())
return res;
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem;
// block: text attributes
{
pElem=hDoc.FirstChildElement().Element();
// should always have a valid root but handle gracefully if it does
if (!pElem)
return res;
// for each text
pElem=pElem->FirstChildElement("quotes");
pElem=pElem->FirstChildElement();
for(;pElem; pElem=pElem->NextSiblingElement())
{
long ctid = -1;
pElem->QueryValueAttribute("id", &ctid);
if(pElem->FirstChild())
res[ctid] = pElem->FirstChild()->Value();
}
}
return res;
}
示例6: configure
// configure the design matrix from an xml element
bool RtDesignMatrix::configure(TiXmlElement *designEle,
const RtConfig &config) {
string name;
TiXmlElement *optionElmt;
bool ret = true;
// iterate over options
for (TiXmlNode *option = 0;
(option = designEle->IterateChildren("option", option));) {
if (option->Type() != TiXmlNode::ELEMENT)
continue;
optionElmt = (TiXmlElement*) option;
if (TIXML_SUCCESS != optionElmt->QueryValueAttribute("name", &name)) {
continue;
}
// build the map between atrribute names and values
map<string, string> attr = RtConfig::getAttributeMap(*optionElmt);
// figure out which option we have and process it
if (!processOption(name, optionElmt->GetText(), attr)) {
ret = false;
}
}
return ret;
}
示例7: doc
EditorLevelDatabase::EditorLevelDatabase(string filename) {
TiXmlDocument doc(filename);
if (!doc.LoadFile()) {
LibGens::Error::addMessage(LibGens::Error::FILE_NOT_FOUND, (string)SONICGLVL_DATABASE_ERROR_FILE + filename);
return;
}
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem;
TiXmlHandle hRoot(0);
pElem=hDoc.FirstChildElement().Element();
if (!pElem) {
LibGens::Error::addMessage(LibGens::Error::EXCEPTION, SONICGLVL_DATABASE_ERROR_FILE_ROOT);
return;
}
pElem=pElem->FirstChildElement();
for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
string entry_name="";
string level_name="";
string geometry_name="";
string layout_merge_name="";
string slot_name="";
string game_name="";
entry_name = pElem->ValueStr();
pElem->QueryValueAttribute(SONICGLVL_DATABASE_NAME_ATTRIBUTE, &level_name);
pElem->QueryValueAttribute(SONICGLVL_DATABASE_GEOMETRY_ATTRIBUTE, &geometry_name);
pElem->QueryValueAttribute(SONICGLVL_DATABASE_MERGE_ATTRIBUTE, &layout_merge_name);
pElem->QueryValueAttribute(SONICGLVL_DATABASE_SLOT_ATTRIBUTE, &slot_name);
pElem->QueryValueAttribute(SONICGLVL_DATABASE_GAME_ATTRIBUTE, &game_name);
if (!game_name.size()) {
game_name = LIBGENS_LEVEL_GAME_STRING_GENERATIONS;
}
if ((entry_name==SONICGLVL_DATABASE_ENTRY) && level_name.size() && geometry_name.size()) {
EditorLevelEntry *entry=new EditorLevelEntry(level_name, geometry_name, layout_merge_name, slot_name, game_name);
entries.push_back(entry);
}
}
}
示例8: r
void
CEntityBuilder::buildComponentResourcesText( TiXmlElement *pNode, Entity *e, Resources *pResource){
std::string text, police;
int r(0), g(0), b(0), a(0);
TiXmlElement *pFontAttr = pNode->FirstChildElement( "text");
if ( pFontAttr){
// Warning : only text is accepted here! no formatted text like <b>hello</b>
text = pFontAttr->GetText();
}
pFontAttr = pNode->FirstChildElement( "police");
if( pFontAttr){
pFontAttr->QueryValueAttribute( "name", &police);
}
pFontAttr = pNode->FirstChildElement( "color");
if ( pFontAttr){
pFontAttr->QueryValueAttribute( "r", &r);
pFontAttr->QueryValueAttribute( "g", &g);
pFontAttr->QueryValueAttribute( "b", &b);
pFontAttr->QueryValueAttribute( "a", &a);
}
if ( !text.empty() && !police.empty()){
BVisual *textVis = NULL;
// Color is defined
if ( pFontAttr) {
textVis = pResource->makeText( text, police, CPColor(r, g, b, a));
}
else {
textVis = pResource->makeText( text, police);
}
addCommonAttributes(pNode, pResource, textVis);
// int zOrder;
// if ( TIXML_SUCCESS == pNode->QueryValueAttribute( "z-order", &zOrder)) {
// textVis->setZOrder(zOrder);
// }
e->addComponent(textVis);
}
}
示例9: Scriptable
// Component Scriptable
void
CEntityBuilder::buildScriptable( TiXmlElement *pNode, Entity *e, Resources*){
TiXmlElement *pChar = pNode->FirstChildElement("script");
std::string script;
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "name", &script)){
e->addComponent( new Scriptable( script));
return;
}
LOG2ERR<<"Bad xml description for [Scriptable] component\n";
throw "Bad xml description for [Scriptable] component";
}
示例10:
void
CEntityBuilder::buildComponentResourcesAudio( TiXmlElement *pNode, Entity *e, Resources *pResource ){
TiXmlElement *pChar = pNode->FirstChildElement("audio");
if ( pChar) {
std::string alias;
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "alias", &alias)){
bool looping = false;
std::string loop;
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "loop", &loop)) {
if (loop == "true") {
looping = true;
}
}
Audio *audio = pResource->makeAudio( alias, looping);
e->addComponent( audio);
return;
}
}
LOG2ERR<<"Bad kind for [Resources/Audio] component\n";
throw "Bad kind for [Resources/Audio] component";
}
示例11: isUnique
void
CEntityBuilder::BuildEntity( TiXmlElement *pParent, EntityManager &em, Resources *pResources){
// Create entity (new id)
Entity *ent = em.createEntity();
if ( !ent){
LOG2ERR<<"Could not create entity\n";
throw "Could not create entity";
}
TiXmlElement* pChilds = pParent->FirstChildElement( "tags");
if ( pChilds ){
// Add tags
for(pChilds=pChilds->FirstChildElement( "tag" ); pChilds; pChilds = pChilds->NextSiblingElement() ){
std::string name;
if ( TIXML_SUCCESS == pChilds->QueryValueAttribute( "name", &name))
{
std::string unique;
bool isUnique(false);
if ( TIXML_SUCCESS == pChilds->QueryValueAttribute( "unique", &unique) ){
isUnique = ( unique=="true");
}
em.tagEntity( ent, name, isUnique);
}
}
}
// Add components
pChilds = pParent->FirstChildElement( "components");
if ( pChilds ){
for( pChilds=pChilds->FirstChildElement( "component" ); pChilds; pChilds = pChilds->NextSiblingElement() ){
std::string type;
if ( TIXML_SUCCESS == pChilds->QueryValueAttribute( "type", &type)){
//LOG2 <<name<<"\n";
buildComponents(pChilds, type, ent, pResources);
}
else {
LOG2ERR<<"Attribute [type] not found\n";
}
}
}
}
示例12: Animated
// Component Animated
void
CEntityBuilder::buildAnimated(TiXmlElement *pNode, Entity *e, Resources*){
TiXmlElement *pChar = pNode->FirstChildElement("image");
if ( pChar ){
std::string name;
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "name", &name)){
e->addComponent( new Animated( name));
return;
}
}
LOG2ERR<<"Bad xml description for [Animated] component\n";
throw "Bad xml description for [Animated] component";
}
示例13: nickname
// Component Character
void
CEntityBuilder::buildCharacter ( TiXmlElement *pNode, Entity *e, Resources*){
if ( pNode ){
// Check nickname to identify entity
std::string nickname ("XXX");
pNode->QueryValueAttribute( "nickname", &nickname);
// Parse stats
TiXmlElement *pChar = pNode->FirstChildElement("stats");
if ( pChar ){
Character *character = new Character( nickname);
for(; pChar; pChar= pChar->NextSiblingElement()){
std::string name;
long value(0);
if ( TIXML_SUCCESS == pChar->QueryValueAttribute( "name", &name) &&
TIXML_SUCCESS == pChar->QueryValueAttribute( "value", &value)){
buildStats( character, name, CVariant( value));
}
}
e->addComponent( character);
}
}
}
示例14: GetElementAttributeByTagName
string GetElementAttributeByTagName(TiXmlElement* root,const string& name,
const string& attribute)
{
if (root == NULL) return string("");
string strValue("");
TiXmlElement* toFind = GetElementByTagName(root,name);
if (toFind != NULL)
{
toFind->QueryValueAttribute(attribute,&strValue);
}
return strValue;
}
示例15: LoadBindings
void PlayerAI::LoadBindings()
{
TiXmlDocument doc("Controls.xml");
bool xml_error = false;
if(doc.LoadFile())
{
TiXmlElement* root = doc.FirstChildElement("Controls");
if(root)
{
TiXmlElement* player = root->FirstChildElement("PlayerBindings");
while(player)
{
int player_id = 0;
if(player->QueryIntAttribute("id", &player_id) == TIXML_SUCCESS)
{
TiXmlElement* ic = player->FirstChildElement("InputConfig");
while(ic)
{
std::string action_string;
if(ic->QueryValueAttribute("Action", &action_string) != TIXML_SUCCESS)
{
Logger::ErrorOut() << "Error reading action attribute, continuing\n";
continue;
}
std::string binding_type_string;
if(ic->QueryValueAttribute("BindingType", &binding_type_string) != TIXML_SUCCESS)
{
Logger::ErrorOut() << "Error reading binding attribute, continuing\n";
continue;
}
Action::Enum action = Action::FromStr(action_string);
BindingType::Enum binding_type = BindingType::FromStr(binding_type_string);
TiXmlElement* binding = ic->FirstChildElement("Binding");
if(binding)
{
switch(binding_type)
{
case BindingType::KeyboardBinding:
{
int key = 0;
if(binding->QueryValueAttribute("Key", &key) == TIXML_SUCCESS)
{
bindings[player_id].push_back(InputConfig(binding_type, Binding((SDLKey)key), action));
} else
{
Logger::ErrorOut() << "Missing Key attribute, continuing\n";
continue;
}
}
break;
case BindingType::JoystickButtonBinding:
{
int joystick_index = 0;
int joystick_button_index = 0;
if(binding->QueryValueAttribute("JoystickIndex", &joystick_index) == TIXML_SUCCESS &&
binding->QueryValueAttribute("JoystickButton", &joystick_button_index) == TIXML_SUCCESS)
{
bindings[player_id].push_back(InputConfig(binding_type, Binding(JoystickButton::Create(joystick_index, joystick_button_index)), action));
} else
{
Logger::ErrorOut() << "Missing JoystickIndex or JoystickButton atttribute, continuing\n";
}
}
break;
case BindingType::JoystickAxisBinding:
{
int joystick_index = 0;
int joystick_axis_index = 0;
if(binding->QueryValueAttribute("JoystickIndex", &joystick_index) == TIXML_SUCCESS &&
binding->QueryValueAttribute("JoystickAxis", &joystick_axis_index) == TIXML_SUCCESS)
{
bindings[player_id].push_back(InputConfig(binding_type, Binding(JoystickAxis::Create(joystick_index, joystick_axis_index)), action));
} else
{
Logger::ErrorOut() << "Missing JoystickIndex or JoystickAxis atttribute, continuing\n";
}
}
break;
case BindingType::MouseAxisBinding:
{
std::string axis;
if(binding->QueryValueAttribute("MouseAxis", &axis) == TIXML_SUCCESS)
{
MouseAxis::Enum mouse_axis = MouseAxis::FromStr(axis);
if(mouse_axis != MouseAxis::InvalidFirst && mouse_axis != MouseAxis::InvalidLast)
{
bindings[player_id].push_back(InputConfig(binding_type, Binding(mouse_axis), action));
} else
{
Logger::ErrorOut() << "MouseAxis attribute incorrect: " << axis << "\n";
}
} else
{
Logger::ErrorOut() << "Missing MouseAxis attribute\n";
}
}
break;
case BindingType::MouseButtonBinding:
{
//.........这里部分代码省略.........