本文整理汇总了C++中XMLDocument::GetErrorStr2方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument::GetErrorStr2方法的具体用法?C++ XMLDocument::GetErrorStr2怎么用?C++ XMLDocument::GetErrorStr2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLDocument
的用法示例。
在下文中一共展示了XMLDocument::GetErrorStr2方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadFile
void Config::loadFile(const string& path)
{
XMLDocument document;
if (document.LoadFile(path.c_str()) == XML_NO_ERROR) {
XMLElement* file = document.FirstChildElement("file");
if (file) {
XMLElement* config = file->FirstChildElement("config");
while (config) {
const char* name = config->Attribute("name");
if (name) {
if (strcmp(name, "DefaultGravity") == 0) config->QueryDoubleAttribute("value", &Config::DefaultGravity);
else if (strcmp(name, "PlayerMoveSpeed") == 0) config->QueryDoubleAttribute("value", &Config::PlayerMoveSpeed);
else if (strcmp(name, "PlayerJumpSpeed") == 0) config->QueryDoubleAttribute("value", &Config::PlayerJumpSpeed);
else if (strcmp(name, "MaxCrosshairDistance") == 0) config->QueryDoubleAttribute("value", &Config::MaxCrosshairDistance);
else if (strcmp(name, "MaxGibsOnScreen") == 0) config->QueryUnsignedAttribute("value", &Config::MaxGibsOnScreen);
else if (strcmp(name, "GibsMin") == 0) config->QueryIntAttribute("value", &Config::GibsMin);
else if (strcmp(name, "GibsMax") == 0) config->QueryIntAttribute("value", &Config::GibsMax);
else if (strcmp(name, "BloodParticles") == 0) config->QueryIntAttribute("value", &Config::BloodParticles);
else if (strcmp(name, "GibMaxSpeedX") == 0) config->QueryIntAttribute("value", &Config::GibMaxSpeedX);
else if (strcmp(name, "GibMaxSpeedY") == 0) config->QueryIntAttribute("value", &Config::GibMaxSpeedY);
else if (strcmp(name, "BloodMaxSpeedX") == 0) config->QueryIntAttribute("value", &Config::BloodMaxSpeedX);
else if (strcmp(name, "BloodMaxSpeedY") == 0) config->QueryIntAttribute("value", &Config::BloodMaxSpeedY);
}
config = config->NextSiblingElement("config");
}
}
} else {
cout << document.GetErrorStr1() << endl;
cout << document.GetErrorStr2() << endl;
}
}
示例2: Init
// Loads the campaign data
int _Campaign::Init() {
Campaigns.clear();
Log.Write("_Campaign::Init - Loading file irrlamb.xml");
// Open the XML file
std::string LevelFile = std::string("levels/main.xml");
XMLDocument Document;
if(Document.LoadFile(LevelFile.c_str()) != XML_NO_ERROR) {
Log.Write("Error loading level file with error id = %d", Document.ErrorID());
Log.Write("Error string 1: %s", Document.GetErrorStr1());
Log.Write("Error string 2: %s", Document.GetErrorStr2());
Close();
return 0;
}
// Check for level tag
XMLElement *CampaignsElement = Document.FirstChildElement("campaigns");
if(!CampaignsElement) {
Log.Write("Could not find campaigns tag");
return 0;
}
// Load campaigns
XMLElement *CampaignElement = CampaignsElement->FirstChildElement("campaign");
for(; CampaignElement != 0; CampaignElement = CampaignElement->NextSiblingElement("campaign")) {
CampaignStruct Campaign;
Campaign.Name = CampaignElement->Attribute("name");
// Get levels
XMLElement *LevelElement = CampaignElement->FirstChildElement("level");
for(; LevelElement != 0; LevelElement = LevelElement->NextSiblingElement("level")) {
LevelStruct Level;
Level.File = LevelElement->GetText();
Level.DataPath = Game.GetWorkingPath() + "levels/" + Level.File + "/";
Level.Unlocked = 0;
LevelElement->QueryIntAttribute("unlocked", &Level.Unlocked);
::Level.Init(Level.File, true);
Level.NiceName = ::Level.GetLevelNiceName();
Campaign.Levels.push_back(Level);
}
Campaigns.push_back(Campaign);
}
return 1;
}
示例3: readXML
void ImageMapWorldCreator::readXML(MapDirectory* mapDirectory, Engine* engine, SDL_Surface* surface, World* world)
{
XMLDocument document;
if (document.LoadFile(mapDirectory->getXMLPath().c_str()) == XML_NO_ERROR) {
XMLElement* mapElement = document.FirstChildElement("map");
if (mapElement) {
XMLElement* backgroundsElement = mapElement->FirstChildElement("backgrounds");
XMLElement* texturesElement = mapElement->FirstChildElement("textures");
if (texturesElement) {
readTexturesElement(texturesElement, surface);
}
if (backgroundsElement) {
readBackgroundsElement(backgroundsElement, engine, mapDirectory, world);
}
}
} else {
cout << document.GetErrorStr1() << endl;
cout << document.GetErrorStr2() << endl;
}
}
示例4: XmlParsingException
void
Game::LoadMap( const std::string & filename )
{
XMLDocument doc;
doc.LoadFile(filename.c_str());
if ( doc.ErrorID() != XML_NO_ERROR )
{
ostringstream ss;
ss << "Loadfile:" << g_TinyXmlErrors[doc.ErrorID()] << " " << doc.GetErrorStr1() << " " << doc.GetErrorStr2();
throw XmlParsingException(ss.str());
}
// Load rooms
XMLElement *pElem = doc.FirstChildElement( "Room");
while( pElem != NULL )
{
g_Log << "loading..." << pElem->Attribute("id");
Room *pRoom = NULL;
// Custom rooms
if ( pElem->Attribute("class"))
{
std::string classID = pElem->Attribute("class");
pRoom = RoomFactory::Create(classID);
}
else
{
pRoom = new Room();
}
pRoom->Load( *pElem );
if ( m_Rooms.find(pRoom->GetId()) != m_Rooms.end())
{
throw DuplicateRoomIdException(pRoom->GetId());
}
m_Rooms[pRoom->GetId()] = pRoom;
pElem = pElem->NextSiblingElement("Room");
}
// Load transitions
pElem = doc.FirstChildElement( "Transitions");
if ( pElem != NULL )
{
pElem = pElem->FirstChildElement("Transition");
while( pElem != NULL )
{
const char * from = pElem->Attribute("from");
const char * to = pElem->Attribute("to");
const char * direction = pElem->Attribute("direction");
const char * oneway = pElem->Attribute("oneway");
if ( direction == NULL ) throw AttributeMissingException("Direction is missing from transition");
if ( from == NULL ) throw AttributeMissingException("From attribute is missing from transition!");
if ( to == NULL ) throw AttributeMissingException("To attribute is missing from transition!");
// check is from a proper id
if ( m_Rooms.find(from) == m_Rooms.end() )
{
ostringstream ss;
ss << from << " is not a proper room id";
throw InvalidAttributeException(ss.str());
}
// check is to a proper id
if ( m_Rooms.find(to) == m_Rooms.end() )
{
ostringstream ss;
ss << to << " is not a proper room id";
throw InvalidAttributeException(ss.str());
}
string tmp = direction;
transform(tmp.begin(),tmp.end(), tmp.begin(), [] (char c){ return tolower(c);});
Direction dir = kNumDirs;
if ( tmp == "east" ) dir = East;
else if ( tmp == "north" ) dir = North;
else if ( tmp == "south" ) dir = South;
else if ( tmp == "west" ) dir = West;
else throw InvalidAttributeException("Direction is not properly set");
m_Rooms[from]->SetNextRoom(dir, m_Rooms[to]);
if ( !oneway )
{
m_Rooms[to]->SetNextRoom(g_Opposite[dir], m_Rooms[from]);
}
pElem = pElem->NextSiblingElement("Transition");
}
}
else
{
throw ElementMissingException("Transitions is missing!");
}
// set current room
pElem = doc.FirstChildElement("OnStart");
if ( pElem == NULL ) throw ElementMissingException("No OnStart defined");
pElem = pElem->FirstChildElement("CurrentRoom");
if ( pElem == NULL )
//.........这里部分代码省略.........
示例5: Init
// Loads a level file
int _Level::Init(const std::string &LevelName, bool HeaderOnly) {
if(!HeaderOnly)
Log.Write("_Level::Init - Loading level: %s", LevelName.c_str());
// Get paths
this->LevelName = LevelName;
LevelNiceName = "";
std::string LevelFile = LevelName + "/" + LevelName + ".xml";
std::string FilePath = Game.GetWorkingPath() + std::string("levels/") + LevelFile;
std::string CustomFilePath = Save.GetCustomLevelsPath() + LevelFile;
std::string DataPath = Game.GetWorkingPath() + std::string("levels/") + LevelName + "/";
// See if custom level exists first
IsCustomLevel = false;
std::ifstream CustomLevelExists(CustomFilePath.c_str());
if(CustomLevelExists) {
IsCustomLevel = true;
FilePath = CustomFilePath;
DataPath = Save.GetCustomLevelsPath() + LevelName + "/";
}
CustomLevelExists.close();
// Open the XML file
XMLDocument Document;
if(Document.LoadFile(FilePath.c_str()) != XML_NO_ERROR) {
Log.Write("Error loading level file with error id = %d", Document.ErrorID());
Log.Write("Error string 1: %s", Document.GetErrorStr1());
Log.Write("Error string 2: %s", Document.GetErrorStr2());
Close();
return 0;
}
// Check for level tag
XMLElement *LevelElement = Document.FirstChildElement("level");
if(!LevelElement) {
Log.Write("Could not find level tag");
Close();
return 0;
}
// Level version
if(LevelElement->QueryIntAttribute("version", &LevelVersion) == XML_NO_ATTRIBUTE) {
Log.Write("Could not find level version");
Close();
return 0;
}
// Check required game version
GameVersion = LevelElement->Attribute("gameversion");
if(GameVersion == "") {
Log.Write("Could not find game version attribute");
Close();
return 0;
}
// Load level info
XMLElement *InfoElement = LevelElement->FirstChildElement("info");
if(InfoElement) {
XMLElement *NiceNameElement = InfoElement->FirstChildElement("name");
if(NiceNameElement) {
LevelNiceName = NiceNameElement->GetText();
}
}
// Return after header is read
if(HeaderOnly) {
Close();
return true;
}
// Load default lua script
Scripts.clear();
Scripts.push_back(Game.GetWorkingPath() + "scripts/default.lua");
// Options
bool Fog = false;
bool EmitLight = false;
Level.ClearColor.set(255, 0, 0, 0);
// Load options
XMLElement *OptionsElement = LevelElement->FirstChildElement("options");
if(OptionsElement) {
// Does the player emit light?
XMLElement *EmitLightElement = OptionsElement->FirstChildElement("emitlight");
if(EmitLightElement) {
EmitLightElement->QueryBoolAttribute("enabled", &EmitLight);
}
}
// Load world
XMLElement *ResourcesElement = LevelElement->FirstChildElement("resources");
if(ResourcesElement) {
// Load scenes
for(XMLElement *SceneElement = ResourcesElement->FirstChildElement("scene"); SceneElement != 0; SceneElement = SceneElement->NextSiblingElement("scene")) {
// Get file
std::string File = SceneElement->Attribute("file");
//.........这里部分代码省略.........