当前位置: 首页>>代码示例>>C++>>正文


C++ XMLDocument::Error方法代码示例

本文整理汇总了C++中XMLDocument::Error方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLDocument::Error方法的具体用法?C++ XMLDocument::Error怎么用?C++ XMLDocument::Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLDocument的用法示例。


在下文中一共展示了XMLDocument::Error方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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";
}
开发者ID:noxshroom,项目名称:TikoIrcBot,代码行数:27,代码来源:XMLHandler.cpp

示例2: example_4

bool example_4()
{
	static const char* xml =
		"<information>"
		"	<attributeApproach v='2' />"
		"	<textApproach>"
		"		<v>2</v>"
		"	</textApproach>"
		"</information>";

	XMLDocument doc;
	doc.Parse( xml );

	int v0 = 0;
	int v1 = 0;

	XMLElement* attributeApproachElement = doc.FirstChildElement()->FirstChildElement( "attributeApproach" );
	attributeApproachElement->QueryIntAttribute( "v", &v0 );

	XMLElement* textApproachElement = doc.FirstChildElement()->FirstChildElement( "textApproach" );
	textApproachElement->FirstChildElement( "v" )->QueryIntText( &v1 );

	printf( "Both values are the same: %d and %d\n", v0, v1 );

	return !doc.Error() && ( v0 == v1 );
}
开发者ID:AlejandorLazaro,项目名称:tinyxml2,代码行数:26,代码来源:xmltest.cpp

示例3: readFractalID

bool FractalConfiguration::readFractalID(string filename, string *id, string *error)
{
	XMLDocument doc;

	// Parse file
	doc.LoadFile(filename.c_str());

	if(doc.Error())
	{
		*error = doc.GetErrorStr1();
		return true;
	}

	// Get ID
	XMLElement *root = doc.RootElement();
	string name = string(root->Name());

	if(name != "fractal")
	{
		*error = "Configuration file is invalid!";
		return true;
	}

	const char* id_tmp = root->Attribute("id");

	if(id_tmp == NULL)
	{
		*error = "Configuration file is invalid!";
		return true;
	}

	*id = string(id_tmp);
	return false;
}
开发者ID:svenhertle,项目名称:fractalimages,代码行数:34,代码来源:FractalConfiguration.cpp

示例4: Read

REBOOL REXMLSerializableReader::Read(const REString & xmlString)
{
#ifndef __RE_NO_XML_PARSER_PRIVATE__	
	_totalElementsCount = 0;
	_processedElementsCount = 0;
	_isError = false;
	if (_controller && _callBack.CreateNewObject) 
	{
		XMLDocument doc;
		doc.Parse(xmlString.UTF8String());
		
		if (doc.Error()) { return false; }
		
		XMLElement * root = doc.RootElement();
		if (root == NULL) { return false; }
		
		const char * rootVal = root->Value();
		if (rootVal) 
		{
			if (strcmp(rootVal, "viewcontroller") == 0) 
			{
				_totalElementsCount = this->CalculateElements(root);
#if 0				
				if ( this->ParseObject(root, _controller, _controller) ) 
				{
					return true;
				}
#endif				
				_isError = true;
			}
		}
	}
#endif
	return false;
}
开发者ID:OlehKulykov,项目名称:re-sdk,代码行数:35,代码来源:REXMLSerializableReader.cpp

示例5:

std::shared_ptr<RoadPatch::PatchArray> RoadPatch::loadPatches(const std::string& filename)
{
  XMLDocument doc;
  doc.LoadFile(filename.c_str());

  if (doc.Error())
    return nullptr;

  std::shared_ptr<PatchArray> arr = std::make_shared<PatchArray>();

  for (XMLElement* titleElement = doc.FirstChildElement(XML_TITLE_ELEMENT);
       titleElement != nullptr;
       titleElement = titleElement->NextSiblingElement(XML_TITLE_ELEMENT))
  {
    // Create new
    ConstPtr tmp = std::make_shared<RoadPatch>(titleElement);

    // Check for XML/Read error
    if (!tmp->good())
      return nullptr;

    // Save according to ID
    (*arr)[tmp->getPatchTypeInt()] = tmp;
  }

  return arr;
}
开发者ID:KAtana-Karlsruhe,项目名称:AADC_2015_KAtana,代码行数:27,代码来源:RoadPatch.cpp

示例6: fillData

RoadPatch::RoadPatch(const std::string& filename)
  : m_good(false)
{
  XMLDocument doc;
  doc.LoadFile(filename.c_str());

  if (doc.Error())
    return;

  XMLElement* titleElement = doc.FirstChildElement(XML_TITLE_ELEMENT);

  m_good = fillData(titleElement);
}
开发者ID:KAtana-Karlsruhe,项目名称:AADC_2015_KAtana,代码行数:13,代码来源:RoadPatch.cpp

示例7: main

int main( int argc, const char ** argv )
{
	#if defined( _MSC_VER ) && defined( DEBUG )
		_CrtMemCheckpoint( &startMemState );
	#endif

	#if defined(_MSC_VER) || defined(MINGW32) || defined(__MINGW32__)
		#if defined __MINGW64_VERSION_MAJOR && defined __MINGW64_VERSION_MINOR
			//MINGW64: both 32 and 64-bit
			mkdir( "resources/out/" );
                #else
                	_mkdir( "resources/out/" );
                #endif
	#else
		mkdir( "resources/out/", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
	#endif

	if ( argc > 1 ) {
		XMLDocument* doc = new XMLDocument();
		clock_t startTime = clock();
		doc->LoadFile( argv[1] );
		clock_t loadTime = clock();
		int errorID = doc->ErrorID();
		delete doc; doc = 0;
		clock_t deleteTime = clock();

		printf( "Test file '%s' loaded. ErrorID=%d\n", argv[1], errorID );
		if ( !errorID ) {
			printf( "Load time=%u\n",   (unsigned)(loadTime - startTime) );
			printf( "Delete time=%u\n", (unsigned)(deleteTime - loadTime) );
			printf( "Total time=%u\n",  (unsigned)(deleteTime - startTime) );
		}
		exit(0);
	}

	FILE* fp = fopen( "resources/dream.xml", "r" );
	if ( !fp ) {
		printf( "Error opening test file 'dream.xml'.\n"
				"Is your working directory the same as where \n"
				"the xmltest.cpp and dream.xml file are?\n\n"
	#if defined( _MSC_VER )
				"In windows Visual Studio you may need to set\n"
				"Properties->Debugging->Working Directory to '..'\n"
	#endif
			  );
		exit( 1 );
	}
	fclose( fp );

	XMLTest( "Example-1", 0, example_1() );
	XMLTest( "Example-2", 0, example_2() );
	XMLTest( "Example-3", 0, example_3() );
	XMLTest( "Example-4", true, example_4() );

	/* ------ Example 2: Lookup information. ---- */

	{
		static const char* test[] = {	"<element />",
										"<element></element>",
										"<element><subelement/></element>",
										"<element><subelement></subelement></element>",
										"<element><subelement><subsub/></subelement></element>",
										"<!--comment beside elements--><element><subelement></subelement></element>",
										"<!--comment beside elements, this time with spaces-->  \n <element>  <subelement> \n </subelement> </element>",
										"<element attrib1='foo' attrib2=\"bar\" ></element>",
										"<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
										"<element>Text inside element.</element>",
										"<element><b></b></element>",
										"<element>Text inside and <b>bolded</b> in the element.</element>",
										"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
										"<element>This &amp; That.</element>",
										"<element attrib='This&lt;That' />",
										0
		};
		for( int i=0; test[i]; ++i ) {
			XMLDocument doc;
			doc.Parse( test[i] );
			doc.Print();
			printf( "----------------------------------------------\n" );
		}
	}
#if 1
	{
		static const char* test = "<!--hello world\n"
								  "          line 2\r"
								  "          line 3\r\n"
								  "          line 4\n\r"
								  "          line 5\r-->";

		XMLDocument doc;
		doc.Parse( test );
		doc.Print();
	}

	{
		static const char* test = "<element>Text before.</element>";
		XMLDocument doc;
		doc.Parse( test );
		XMLElement* root = doc.FirstChildElement();
		XMLElement* newElement = doc.NewElement( "Subelement" );
//.........这里部分代码省略.........
开发者ID:AlejandorLazaro,项目名称:tinyxml2,代码行数:101,代码来源:xmltest.cpp

示例8: main

int main( int /*argc*/, const char ** /*argv*/ )
{
	#if defined( _MSC_VER ) && defined( DEBUG )
		_CrtMemCheckpoint( &startMemState );
	#endif	

	#if defined(_MSC_VER)
	#pragma warning ( push )
	#pragma warning ( disable : 4996 )		// Fail to see a compelling reason why this should be deprecated.
	#endif

	FILE* fp = fopen( "dream.xml", "r" );
	if ( !fp ) {
		printf( "Error opening test file 'dream.xml'.\n"
				"Is your working directory the same as where \n"
				"the xmltest.cpp and dream.xml file are?\n\n"
	#if defined( _MSC_VER )
				"In windows Visual Studio you may need to set\n"
				"Properties->Debugging->Working Directory to '..'\n"
	#endif
			  );
		exit( 1 );
	}
	fclose( fp );

	#if defined(_MSC_VER)
	#pragma warning ( pop )
	#endif

	/* ------ Example 1: Load and parse an XML file. ---- */	
	{
		XMLDocument doc;
		doc.LoadFile( "dream.xml" );
	}
	
	/* ------ Example 2: Lookup information. ---- */	
	{
		XMLDocument doc;
		doc.LoadFile( "dream.xml" );

		// Structure of the XML file:
		// - Element "PLAY"			the root Element
		// - - Element "TITLE"		child of the root PLAY Element
		// - - - Text				child of the TITLE Element
		
		// Navigate to the title, using the convenience function, with a dangerous lack of error checking.
		const char* title = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->GetText();
		printf( "Name of play (1): %s\n", title );
		
		// Text is just another Node to TinyXML-2. The more general way to get to the XMLText:
		XMLText* textNode = doc.FirstChildElement( "PLAY" )->FirstChildElement( "TITLE" )->FirstChild()->ToText();
		title = textNode->Value();
		printf( "Name of play (2): %s\n", title );
	}

	{
		static const char* test[] = {	"<element />",
									    "<element></element>",
										"<element><subelement/></element>",
									    "<element><subelement></subelement></element>",
									    "<element><subelement><subsub/></subelement></element>",
									    "<!--comment beside elements--><element><subelement></subelement></element>",
									    "<!--comment beside elements, this time with spaces-->  \n <element>  <subelement> \n </subelement> </element>",
									    "<element attrib1='foo' attrib2=\"bar\" ></element>",
									    "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",
										"<element>Text inside element.</element>",
										"<element><b></b></element>",
										"<element>Text inside and <b>bolded</b> in the element.</element>",
										"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",
										"<element>This &amp; That.</element>",
										"<element attrib='This&lt;That' />",
										0
		};
		for( int i=0; test[i]; ++i ) {
			XMLDocument doc;
			doc.Parse( test[i] );
			doc.Print();
			printf( "----------------------------------------------\n" );
		}
	}
#if 1
	{
		static const char* test = "<!--hello world\n"
			                      "          line 2\r"
			                      "          line 3\r\n"
			                      "          line 4\n\r"
			                      "          line 5\r-->";

		XMLDocument doc;
		doc.Parse( test );
		doc.Print();
	}

	{
		static const char* test = "<element>Text before.</element>";
		XMLDocument doc;
		doc.Parse( test );
		XMLElement* root = doc.FirstChildElement();
		XMLElement* newElement = doc.NewElement( "Subelement" );
		root->InsertEndChild( newElement );
//.........这里部分代码省略.........
开发者ID:qaisjp,项目名称:green-candy,代码行数:101,代码来源:xmltest.cpp

示例9: load

int ColladaParser::load( const char* filename, Scene* scene ) {

  ifstream in( filename );
  if ( !in.is_open() ) {
    return -1;
  } in.close();
  
  XMLDocument doc;
  doc.LoadFile( filename );
  if ( doc.Error() ) {
    doc.PrintError();
    exit( 1 );
  }

  XMLElement* root = doc.FirstChildElement("COLLADA");
  if ( !root ) {
    stat("Error: not a COLLADA file!")
    exit( 1 );
  } else {
    stat("Loading COLLADA file...");
  }

  // save COLLADA library entry points
  e_scenes     = root->FirstChildElement("library_visual_scenes");
  e_cameras    = root->FirstChildElement("library_cameras"      );
  e_lights     = root->FirstChildElement("library_lights"       );
  e_geometries = root->FirstChildElement("library_geometries"   );
  e_materials  = root->FirstChildElement("library_materials"    );
  e_effects    = root->FirstChildElement("library_effects"      );

  // load assets
  XMLElement* e_asset = root->FirstChildElement("asset");
  if ( e_asset ) {

    // NOTE (sky):
    // We probably should take care of different Y directions here if we want
    // to support exports from different packages.
    XMLElement* up_axis = e_asset->FirstChildElement("up_axis");
    stat("Y direction: "<< up_axis->GetText());
  }

  // load scenes -
  XMLElement* e_scene = root->FirstChildElement("scene");
  if ( e_scene ) {

    XMLElement* e_instance = e_scene->FirstChildElement("instance_visual_scene");

    // NOTE (sky):
    // COLLADA seems to support multiple scenes in one file
    // right now the parser only loads the first scene

    // load all scenes
    // while (e_instance) {
    //   // load a single scene
    //   e_instance = e_scene->NextSiblingElement("instance_visual_scene");
    // }

    // load first scene
    if (e_instance) {

      const char* instance_url = e_instance->Attribute("url");
      if ( instance_url ) {

        // look for scene in scene library
        string instance_id = instance_url + 1;
        XMLElement* e_instance = find_instance( e_scenes, instance_id );
        if ( e_instance ) {
          stat("Loading scene: " << instance_id);
          
          parseScene(e_instance, *scene);
        } else {
          stat("Error: undefined scene instance: " << instance_id);
          return -1;
        }

      } else {

        // Note (Sky):
        // not sure if there are non-indirection encodings but
        // if there is then it should be handled here
        return 0;

      }
    }
  }

  return 0;

}
开发者ID:CS184-sp16,项目名称:asst2_geomenagerie,代码行数:89,代码来源:collada.cpp

示例10: readFromFile

SVideoSettings::SVideoSettings()
  : 
#ifdef INPUT_TOUCH
  m_fHUDSize(1)
#else
  m_fHUDSize(0)
#endif
{
}

SSocialGamingSettings::SSocialGamingSettings() {
#if MENCUS_DEFAULT_LOGIN_TO_SOCIAL_GAMING == 1
  m_bLoginOnStart = true;
#else
  m_bLoginOnStart = false;
#endif
}

CSettings &CSettings::getSingleton() {
  assert(msSingleton);
  return *msSingleton;
}
CSettings *CSettings::getSingletonPtr() {
  return msSingleton;
}
CSettings::CSettings() {
  readFromFile();
}
CSettings::~CSettings() {
  writeToFile();
}
void CSettings::readFromFile() {
  XMLDocument doc;
  doc.LoadFile(CFileManager::getValidPath(SETTINGS_FILE_PATH).c_str());
  if (doc.Error()) {
    return;
  }
  XMLElement *pRoot = doc.FirstChildElement("settings");
  if (!pRoot) {
    // no settings stored yet
    return;
  }

  // input
  XMLElement *pInput = pRoot->FirstChildElement("input");
  if (!pInput) {return;}

  m_InputSettings.m_fMapEditorButtonSize
    = RealAttribute(pInput,
		    "map_editor_button_size",
		    m_InputSettings.m_fMapEditorButtonSize);

  for (XMLElement *pElem = pInput->FirstChildElement(); pElem; pElem = pElem->NextSiblingElement()) {
    if (strcmp(pElem->Value(), "touch") == 0) {
      m_InputSettings.m_fTouchButtonSize = RealAttribute(pElem, "button_size", m_InputSettings.m_fTouchButtonSize);
    }
  }

  // video
  XMLElement *pVideo = pRoot->FirstChildElement("video");
  if (!pVideo) {return;}

  m_VideoSettings.m_fHUDSize = RealAttribute(pVideo, "hud_size", m_VideoSettings.m_fHUDSize);

  // social gaming
  XMLElement *pSocialGaming = pRoot->FirstChildElement("social_gaming");
  if (!pSocialGaming) {return;}

  m_SocialGamingSettings.m_bLoginOnStart = BoolAttribute(pSocialGaming, "login_on_start", m_SocialGamingSettings.m_bLoginOnStart);
}
开发者ID:ChWick,项目名称:Mencus,代码行数:70,代码来源:Settings.cpp

示例11: SaveLink

string XMLHandler::SaveLink(string name, string url)
{
    // Load existing links
    XMLDocument doc;
    doc.LoadFile("links.xml");

    if( doc.Error() ) {std::cout << "ERROR_SAVE: Could not open links.\n";}

    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;

    // Struct which contains data from one link
    struct Data
    {
        string name;
        string url;
    };
    // List of Data, basically contains everything from XML
    list<Data> dump;

    // Loop through XML
    for( ; linkNode != NULL; linkNode = linkNode->NextSiblingElement() )
    {
        Data d;
        d.name = linkNode->Attribute("name");
        d.url = linkNode->Attribute("url");
        dump.push_back(d);
    }

    // Set exist flag false if not found, otherwise update previous entry
    bool exist = false;
    for(auto it = dump.begin(); it != dump.end(); ++it)
    {
        if(it->name == name)
        {
            it->url = url;
            exist = true;
            break;
        }
    }

    // Link was not found, append
    if(!exist)
    {
        Data d;
        d.name = name;
        d.url = url;
        dump.push_back(d);
    }

    // Finally save new file
    FILE* file = fopen("links.xml", "w+");
    XMLPrinter printer(file);
    printer.PushHeader(true,true);

    printer.OpenElement("Links");
    for(Data d : dump)
    {
        printer.OpenElement("Link");
        printer.PushAttribute("name", d.name.c_str() );
        printer.PushAttribute("url", d.url.c_str() );
        printer.CloseElement();
    }
    printer.CloseElement();
    fclose(file);

    return "SUCCESS";
}
开发者ID:noxshroom,项目名称:TikoIrcBot,代码行数:71,代码来源:XMLHandler.cpp

示例12: LoadTilemap

bool TilemapLoader::LoadTilemap(const string _path, Tilemap& _tilemap)
{
	// Temporary map object
	Tilemap temp_map;

	// Load TMX file in TinyXML
	XMLDocument doc;
	doc.LoadFile(_path.c_str());

	// Check for error in parsing
	if (doc.Error())
	{
		cout << "XML Parsing Error: " << doc.ErrorID() << endl;
		return false;
	}

	// Find the map element
	const XMLElement* map_element = doc.FirstChildElement("map");
	if (!CheckPointer(map_element, "Couldn't locate map element in map file"))
		return false;

	// Load all of the basic map data
	map_element->QueryFloatAttribute("version", &temp_map.version);
	map_element->QueryIntAttribute("width", &temp_map.map_dimensions.x);
	map_element->QueryIntAttribute("height", &temp_map.map_dimensions.y);
	map_element->QueryIntAttribute("tilewidth", &temp_map.tile_dimensions.x);
	map_element->QueryIntAttribute("tileheight", &temp_map.tile_dimensions.y);

	// Load the orientation of the tile map. Only orthogonal
	// is supported currently.
	string orient_str = map_element->Attribute("orientation");
	if (orient_str == "orthogonal")
		temp_map.orientation = SFTILE_ORIENT_ORTHOGONAL;
	else
	{
		cout << "SfTileEngine currently only supports orthogonal tile maps." << endl;
		temp_map.orientation = SFTILE_ORIENT_UNSUPPORTED;
		return false;
	}

	// Parse the tilesets in the tile map.
	const XMLElement* tileset_element = map_element->FirstChildElement("tileset");
	while (tileset_element)
	{
		if (!ParseTileset(tileset_element, temp_map.tileset))
		{
			cout << "Failed to parse tileset" << endl;
			return false;
		}
		tileset_element = tileset_element->NextSiblingElement("tileset");
	}
	// Don't let your pointer dangle... That's gross.
	tileset_element = nullptr;

	// Parse all layers: tile, object, image
	const XMLElement* layer_element = map_element->FirstChildElement();
	while (layer_element)
	{
		string name = layer_element->Name();
		if (name == "layer")
		{
			TileLayer temp_tile_layer;
			if (!ParseTileLayer(layer_element, temp_tile_layer))
			{
				cout << "Failed to parse tile layer" << endl;
				return false;
			}
			else
				temp_map.layers.push_back(unique_ptr<TileLayer>(new TileLayer(temp_tile_layer)));
		}
		else if (name == "objectgroup")
		{
			ObjectLayer temp_object_layer;
			if (!ParseObjectLayer(layer_element, temp_object_layer))
			{
				cout << "Failed to parse object layer" << endl;
				return false;
			}
			else
				temp_map.layers.push_back(unique_ptr<ObjectLayer>(new ObjectLayer(temp_object_layer)));
		}
		/*else if (layer_element->Name() == "imagelayer")
		{
			ImageLayer temp_image_layer;
			if (!ParseImageLayer(layer_element, temp_image_layer))
			{
				cout << "Failed to parse image layer" << endl;
				return false;
			}
			else
				temp_map.layers.push_back(unique_ptr<ImageLayer>(new ImageLayer(temp_image_layer)));
		}*/
		layer_element = layer_element->NextSiblingElement();
	}
	layer_element = nullptr;



	/*
	// Parse the tile layers
//.........这里部分代码省略.........
开发者ID:Tresky,项目名称:sf_tile_engine,代码行数:101,代码来源:tilemap_loader.cpp

示例13: open

bool FractalConfiguration::open(string filename)
{
	if(invalidID())
		return true;

	m_dirty = false;

	XMLDocument doc;

	// Parse file
	doc.LoadFile(filename.c_str());

	if(doc.Error())
	{
		m_last_error = doc.GetErrorStr1();
		return true;
	}

	// Get data
	XMLElement *root = doc.RootElement();

	string name = string(root->Name());

	if(name != "fractal")
	{
		m_last_error = "Configuration file is invalid!";
		return true;
	}

	if(root->Attribute("id", m_id.c_str()))
	{
		XMLNode *node = root->FirstChild();

		// Loop over all properties
		while(node != NULL)
		{
			XMLElement *element = node->ToElement();

			if(element == NULL)
			{
				m_last_error = "Configuration file is invalid!";
				return true;
			}

			// Get name and type (attributes)
			const char* tmp_name = element->Attribute("name");
			const char* tmp_type = element->Attribute("type");

			if(tmp_name == NULL || tmp_type == NULL)
			{
				m_last_error = "Configuration file is invalid!";
				return true;
			}

			string name(tmp_name);
			string type(tmp_type);

			// Get text
			const char* tmp_text = element->GetText();
			string text = "";

			if(tmp_text != NULL)
				text = tmp_text;

			// Set property
			if(type == "string")
			{
				if(setStringProperty(name, text))
					return true;
			}
			else if(type == "int")
			{
				int value;
				if(stringToInt(text, &value))
				{
					m_last_error = "Error in configuration: " + text + " should be an integer";
					return true;
				}

				if(setIntProperty(name, value))
					return true;
			}
			else if(type == "double")
			{
				double value;
				if(stringToDouble(text, &value))
				{
					m_last_error = "Error in configuration: " + text + " should be a double";
					return true;
				}

				if(setDoubleProperty(name, value))
					return true;
			}
			else if(type == "bool")
			{
				bool value;
				if(text == "1")
					value = true;
				else if(text == "0")
//.........这里部分代码省略.........
开发者ID:svenhertle,项目名称:fractalimages,代码行数:101,代码来源:FractalConfiguration.cpp

示例14: parseDotScene

void DotSceneLoader::parseDotScene(const String &SceneName, const String &groupName, SceneManager *yourSceneMgr, CPhysicsManager *pPhysicsManager, SceneNode *pAttachNode, const String &sPrependNode)
{
	cleanup();

    Ogre::LogManager::getSingleton().logMessage("Loading dot scene: " + SceneName);
    // set up shared object values
    m_sGroupName = groupName;
    mSceneMgr = yourSceneMgr;
	m_pPhysicsManager = pPhysicsManager;
    m_sPrependNode = sPrependNode;


	mStaticSceneNode = pAttachNode->createChildSceneNode(sPrependNode + "StaticSceneNode");

    XMLDocument   *XMLDoc = 0;
    XMLElement   *XMLRoot;

    try
    {
        // Strip the path
        Ogre::String basename, path;
        Ogre::StringUtil::splitFilename(SceneName, basename, path);

        // Do not look in other groups but the given one
        DataStreamPtr pStream = ResourceGroupManager::getSingleton().
            openResource( basename, groupName, false );

        //DataStreamPtr pStream = ResourceGroupManager::getSingleton().
        //    openResource( SceneName, groupName );

        String data = pStream->getAsString();
        // Open the .scene File
        XMLDoc = new XMLDocument();
        XMLDoc->Parse( data.c_str() );
        pStream->close();
        pStream.setNull();

        if( XMLDoc->Error() )
        {
            //We'll just log, and continue on gracefully
            LogManager::getSingleton().logMessage("[DotSceneLoader] The TiXmlDocument reported an error");
            delete XMLDoc;
            return;
        }
    }
    catch(...)
    {
        //We'll just log, and continue on gracefully
        LogManager::getSingleton().logMessage("[DotSceneLoader] Error creating TiXmlDocument");
        delete XMLDoc;
        return;
    }

    // Validate the File
    XMLRoot = XMLDoc->RootElement();
    if( String( XMLRoot->Value()) != "scene"  ) {
        LogManager::getSingleton().logMessage( "[DotSceneLoader] Error: Invalid .scene File. Missing <scene>" );
        delete XMLDoc;
        return;
    }

    // figure out where to attach any nodes we create
    mAttachNode = pAttachNode;
    if(!mAttachNode)
        mAttachNode = mSceneMgr->getRootSceneNode();

    // Process the scene
    processScene(XMLRoot);

	/*for (auto &m : m_mStaticGeometryMap) {
		m.second->build();
	}*/

	/*for (auto &s : mStaticObjects) {
		for (auto &cb : m_lCallbacks){
			cb->staticObjectAdded(s);
		}
	}
	// remove static geometry entities
	destroySceneNode(mStaticSceneNode);*/


	// apply manually material data
	// ===============================

	// dont cull grass
	auto mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("CS_Grass"));
	if (!mat.isNull() && mat->getBestTechnique()) {
		mat->getBestTechnique()->setCullingMode(Ogre::CullingMode::CULL_NONE);
	}

	// make water transparent, add textures
	mat = static_cast<Ogre::MaterialPtr>(Ogre::MaterialManager::getSingleton().getByName("Water"));
	if (!mat.isNull() && mat->getBestTechnique()) {
		mat->getBestTechnique()->setCullingMode(Ogre::CullingMode::CULL_NONE);
		mat->getBestTechnique()->getPass(0)->setDepthCheckEnabled(true);
		mat->getBestTechnique()->getPass(0)->setDepthWriteEnabled(false);
		mat->getBestTechnique()->getPass(0)->setSceneBlending(Ogre::SBF_SOURCE_ALPHA, Ogre::SBF_ONE);
		mat->getBestTechnique()->getPass(0)->getTextureUnitState(0)->setTransformAnimation(
			Ogre::TextureUnitState::TT_TRANSLATE_U, Ogre::WFT_SINE, 0, 0.25, 0, 0.125);
//.........这里部分代码省略.........
开发者ID:ChWick,项目名称:Zelda,代码行数:101,代码来源:DotSceneLoader.cpp


注:本文中的XMLDocument::Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。