コード例 #1
0
	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);
			}
		}
	}
コード例 #2
0
ETHEntityProperties::ETHEntityProperties(const str_type::string& filePath, const Platform::FileManagerPtr& fileManager)
{
	ETHEntityMaterial::Reset();
	Reset();

	TiXmlDocument doc(filePath);
	str_type::string content;
	fileManager->GetUTF16FileString(filePath, content);
	if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY))
	{
		ETH_STREAM_DECL(ss) << GS_L("Couldn't load file: ") << filePath;
		ETHResourceProvider::Log(ss.str(), Platform::Logger::ERROR);
		return;
	}

	TiXmlHandle hDoc(&doc);
	TiXmlHandle hRoot(0);

	TiXmlElement *pElem = hDoc.FirstChildElement().Element();
	if (!pElem)
	{
		ETH_STREAM_DECL(ss) << GS_L("The current file seems to be invalid: ") << filePath;
		ETHResourceProvider::Log(ss.str(), Platform::Logger::ERROR);
		return;
	}

	hRoot = TiXmlHandle(pElem);
	entityName = Platform::GetFileName(filePath);
	if (ReadFromXMLFile(hRoot.FirstChildElement().Element()))
	{
		successfullyLoaded = true;
	}
}
コード例 #3
0
ファイル: SoftUninstall.cpp プロジェクト: dreamsxin/PcManager
BOOL CSoftUninstall::LoadPinYin()
{
	CDataFileLoader	loader;
	BkDatLibContent content;

	if(!loader.GetLibDatContent((_ksafePath + SOFT_PINYIN_DAT).c_str(), content))
		return FALSE;

	TiXmlDocument plugins;
	if(plugins.Parse((char*)content.pBuffer) == NULL)
		return FALSE;

	TiXmlHandle hRoot(plugins.FirstChildElement("fonts"));
	for(TiXmlElement *pElem = hRoot.FirstChildElement("font").Element(); pElem != NULL; pElem = pElem->NextSiblingElement())
	{
		LPCSTR pHan = pElem->Attribute("c");
		if(pHan == NULL) continue;

		PinYin pinyin;
		pinyin._whole = pElem->Attribute("p");
		pinyin._acronym = pElem->Attribute("s");

		_hashPinYin.insert(make_pair(pHan, pinyin));
	}

	return TRUE;
}
コード例 #4
0
ファイル: vsFontLib.cpp プロジェクト: acompania/T-Rex-Game
// 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;
}
コード例 #5
0
	void ObjectProduction::load(string filename) {
		TiXmlDocument doc(filename);
		if (!doc.LoadFile()) {
			Error::addMessage(Error::FILE_NOT_FOUND, LIBGENS_OBJECT_PRODUCTION_ERROR_FILE + filename);
			return;
		}

		TiXmlHandle hDoc(&doc);
		TiXmlElement* pElem;
		TiXmlHandle hRoot(0);

		pElem=hDoc.FirstChildElement().Element();
		if (!pElem) {
			Error::addMessage(Error::EXCEPTION, LIBGENS_OBJECT_PRODUCTION_ERROR_FILE_ROOT);
			return;
		}

		sorted_entry_names.clear();

		pElem=pElem->FirstChildElement();
		for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
			ObjectPhysics *object=new ObjectPhysics();
			object->readXML(pElem);
			object_entries.push_back(object);

			sorted_entry_names.insert(object->getName());
		}
	}
コード例 #6
0
bool MProject::loadXML(const char * filename)
{
	char rep[256];

	if(! filename)
		return false;

	// get rep
	getRepertory(rep, filename);

	// read document
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
		return false;
	
	TiXmlHandle hDoc(&doc);
	TiXmlElement * rootNode;
	TiXmlHandle hRoot(0);

	// maratis
	rootNode = hDoc.FirstChildElement().Element();
	if(! rootNode)
		return false;

	if(strcmp(rootNode->Value(), "Maratis") != 0)
		return false;

	hRoot = TiXmlHandle(rootNode);

	// Project
	TiXmlElement * projectNode = rootNode->FirstChildElement("Project");
	if(! projectNode)
		return false;

	// renderer
	TiXmlElement * rendererNode = projectNode->FirstChildElement("renderer");
	if(rendererNode)
	{
		const char * name = rendererNode->Attribute("name");
		if(name)
		{
			renderer = name;
		}
	}
	
	// start
	TiXmlElement * startNode = projectNode->FirstChildElement("start");
	if(startNode)
	{
		const char * file = startNode->Attribute("file");
		if(file)
		{
			char levelFilename[256];
			getGlobalFilename(levelFilename, rep, file);
			startLevel = levelFilename;
		}
	}

	return true;
}
コード例 #7
0
ファイル: MapSelectionMenu.cpp プロジェクト: mcmonkey/cglory
void MapSelectionMenu::setupOptions()
{
	title = L"Load Map";
	// Load xml in. Store Paths in pathnames
	// foreach map
	// pathnames[i++] = path
	// addoption(name, i)
	// leave UIMenu::setupOptions();
	TiXmlDocument doc( "maplist.xml");
	if(doc.LoadFile())
	{
		TiXmlHandle hDoc(&doc);
		TiXmlElement* pElem;
		TiXmlHandle hRoot(0);
		pElem = hDoc.FirstChildElement().Element();
		hRoot=TiXmlHandle(pElem);
		TiXmlElement* pMap = hRoot.FirstChild("Map").ToElement();
		int i=0;
		for(pMap; pMap; pMap = pMap->NextSiblingElement("Map"))
		{
			pathNames.insert(pair<int, string>(i, pMap->Attribute("path")));
			addOption(Utility::widen(pMap->Attribute("name")), i);
			i++;
		}
	}
	//addOption(L"Pea Island, 2p", 0);
	//addOption(L"Dev Map, 2p", 1);
	UIMenu::setupOptions();
}
コード例 #8
0
DefaultShaderParameters::DefaultShaderParameters(string filename) {
	TiXmlDocument doc(filename);
	if (!doc.LoadFile()) {
		return;
	}

	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem;
	TiXmlHandle hRoot(0);

	pElem=hDoc.FirstChildElement().Element();
	if (!pElem) {
		return;
	}

	pElem=pElem->FirstChildElement();
	for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
		string entry_name = pElem->ValueStr();

		if (entry_name=="Parameter") {
			DefaultShaderParameter *parameter = new DefaultShaderParameter();
			parameter->read(pElem);
			parameters.push_back(parameter);
		}
	}
}
コード例 #9
0
ファイル: statDatabase.cpp プロジェクト: telnykha/VideoA
bool TStatDatabase::LoadDatabase(const char* lpFileName)
{
    CloseDatabase();
	TiXmlDocument doc(lpFileName);
    if (!doc.LoadFile())
		return false;
    TiXmlHandle hDoc(&doc);
    TiXmlHandle hRoot(0);
	TiXmlElement* elem = hDoc.FirstChildElement().Element();
    if (strcmp(elem->Value(), "awpStatDB") != 0)
        return false;

    for(TiXmlNode* child = elem->FirstChild(); child; child = child->NextSibling() )
    {
        const char* name = child->Value();
        if (strcmp(name, "EntryID") != 0)
            return false;
        TDbEntry* e = new TDbEntry(0, "");
        if (e->LoadXML(child->ToElement()))
            this->m_entries.Add(e);
        else
        {
            delete e;
            return false;
        }

    }
    this->m_isChanged = false;
    this->m_dbName = lpFileName;
    return true;
}
コード例 #10
0
ファイル: GameConfig.cpp プロジェクト: PhiBabin/LD21---Escape
/**
    Chargement de la configuration
**/
void GameConfig::LoadConfig(){
    TiXmlDocument doc("config/config.xml");
    doc.LoadFile();

    TiXmlHandle hDoc(&doc);
    TiXmlHandle hRoot(0);
    TiXmlElement* pElem;

    pElem=hDoc.FirstChild("img").FirstChild().Element();
    for(; pElem; pElem=pElem->NextSiblingElement()){
        imgAnim newAnim;
        sf::Texture newImg;
        if(!newImg.LoadFromFile(pElem->Attribute("path"))){
            cerr<<"Image not found: "<<pElem->Attribute("path")<<endl;
            exit(0);
        }
        newAnim.img=newImg;
        newAnim.nbrCollum=atoi(pElem->Attribute("nbrCollums"));
        newAnim.nbrLine=atoi(pElem->Attribute("nbrLines"));
        g_imgManag[pElem->Attribute("name")]=newAnim;
    }
    pElem=hDoc.FirstChild("sound").FirstChild().Element();
    for(; pElem; pElem=pElem->NextSiblingElement()){
        sf::SoundBuffer newSound;
        newSound.LoadFromFile(pElem->Attribute("path"));
        g_soundManag[pElem->Attribute("name")]=newSound;
    }
    pElem=hDoc.FirstChild("config").FirstChild().Element();
    for(; pElem; pElem=pElem->NextSiblingElement()){
        GameConfig::g_config[pElem->Attribute("name")]=atoi(pElem->Attribute("value"));
    }
}
コード例 #11
0
bool GibbsTrackingFilter< ItkQBallImageType >::LoadParameters()
{
    m_AbortTracking = true;
    try
    {
        if( m_LoadParameterFile.length()==0 )
        {
            m_AbortTracking = false;
            return true;
        }

        MITK_INFO << "GibbsTrackingFilter: loading parameter file " << m_LoadParameterFile;

        TiXmlDocument doc( m_LoadParameterFile );
        doc.LoadFile();

        TiXmlHandle hDoc(&doc);
        TiXmlElement* pElem;
        TiXmlHandle hRoot(0);

        pElem = hDoc.FirstChildElement().Element();
        hRoot = TiXmlHandle(pElem);
        pElem = hRoot.FirstChildElement("parameter_set").Element();

        string iterations(pElem->Attribute("iterations"));
        m_Iterations = boost::lexical_cast<unsigned long>(iterations);

        string particleLength(pElem->Attribute("particle_length"));
        m_ParticleLength = boost::lexical_cast<float>(particleLength);

        string particleWidth(pElem->Attribute("particle_width"));
        m_ParticleWidth = boost::lexical_cast<float>(particleWidth);

        string partWeight(pElem->Attribute("particle_weight"));
        m_ParticleWeight = boost::lexical_cast<float>(partWeight);

        string startTemp(pElem->Attribute("temp_start"));
        m_StartTemperature = boost::lexical_cast<float>(startTemp);

        string endTemp(pElem->Attribute("temp_end"));
        m_EndTemperature = boost::lexical_cast<float>(endTemp);

        string inExBalance(pElem->Attribute("inexbalance"));
        m_InexBalance = boost::lexical_cast<float>(inExBalance);

        string fiberLength(pElem->Attribute("fiber_length"));
        m_MinFiberLength = boost::lexical_cast<float>(fiberLength);

        string curvThres(pElem->Attribute("curvature_threshold"));
        m_CurvatureThreshold = cos(boost::lexical_cast<float>(curvThres)*M_PI/180);
        m_AbortTracking = false;
        MITK_INFO << "GibbsTrackingFilter: parameter file loaded successfully";
        return true;
    }
    catch(...)
    {
        MITK_INFO << "GibbsTrackingFilter: could not load parameter file";
        return false;
    }
}
コード例 #12
0
ファイル: script.cpp プロジェクト: leonhong/sitemon2
bool Script::loadScriptFile(const std::string &file)
{
	std::string finalPath;

	// handle relative paths
#ifdef _MSC_VER
	if (file.find(":") == -1)
#else
	if (file[0] != '/')
#endif
	{
		char *szCurrentDir = getcwd(NULL, 0);
		if (szCurrentDir == 0)
		{
			printf("can't get current dir - try using a full path\n");
			return false;
		}

		std::string strFullPath = szCurrentDir;
#ifdef _MSC_VER
		strFullPath += "\\";
#else
		strFullPath += "/";
#endif
		strFullPath += file;

		finalPath = strFullPath;
	}
	else
	{
		finalPath = file;
	}

	TiXmlDocument doc(finalPath);
	
	if (!doc.LoadFile())
	{
		printf("Can't load xml file.\n");
		return false;
	}
	
	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem = NULL;
	TiXmlHandle hRoot(0);
	
	pElem = hDoc.FirstChildElement("script").Element();
	
	if (!pElem) // no script item...
		return false;
	
	for (pElem = pElem->FirstChildElement("request"); pElem; pElem = pElem->NextSiblingElement())
	{
		loadRequestElement(pElem);
	}

	return true;
}
コード例 #13
0
	void BIXFConverter::convertToBIXF(string source, string dest, int mode_flag) {
		File file(dest, LIBGENS_FILE_WRITE_BINARY);
		vector<string> string_table;
		vector<unsigned char> data;

		
		if (file.valid()) {
			TiXmlDocument doc(source);
			doc.LoadFile();

			TiXmlHandle hDoc(&doc);
			TiXmlElement* pElem;
			TiXmlHandle hRoot(0);

			pElem=hDoc.FirstChildElement().Element();
			for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
				convertToBIXF(pElem, string_table, data, mode_flag);
			}

			// Write Binary Data
			unsigned char header=0x01;
			file.writeString("BIXF");
			file.writeUChar(&header);
			file.fixPadding(20);


			unsigned int total_data_size=data.size();
			unsigned int total_string_size=0;
			unsigned int total_string_count=string_table.size();


			for (size_t c=0; c<data.size(); c++) {
				file.writeUChar(&(data[c]));
			}

			// Apparently it needs three zeros at the end of the data
			unsigned char zero=0;
			file.writeUChar(&zero);
			file.writeUChar(&zero);
			file.writeUChar(&zero);
			total_string_size += 3;

			for (size_t c=0; c<string_table.size(); c++) {
				file.writeString(&(string_table[c]));
				total_string_size += string_table[c].size() + 1;
			}

			file.goToAddress(8);
			file.writeInt32(&total_data_size);
			file.writeInt32(&total_string_size);
			file.writeInt32(&total_string_count);

			file.close();
		}
	}
コード例 #14
0
ファイル: Config.cpp プロジェクト: maciejgrzybek/ChaTIN
void Config::loadFile(const std::string& fileName) throw(FileOpenException,DataParsingException)
{
// code mostly basis on TinyXML example
    TiXmlDocument doc(fileName.c_str());
    if (!doc.LoadFile())
        throw FileOpenException(fileName);

    TiXmlHandle hDoc(&doc);
    TiXmlElement* pElem;
    TiXmlHandle hRoot(0);

    std::string m_name; // check what for it is

	// block: name
	{
		pElem=hDoc.FirstChildElement().Element();
		// should always have a valid root. If does not - throw exception.
		if (!pElem)
            throw XML::XMLParsingException(fileName);

		m_name=pElem->Value();

		// save this for later
		hRoot=TiXmlHandle(pElem);
	}

    // <configuration>
	{
		config.clear(); // trash existing table

		pElem=hRoot.FirstChild().Element();
		for(; pElem; pElem=pElem->NextSiblingElement())
		{
			std::string pKey = pElem->Value();
			std::string pText = pElem->GetText();
            std::string pAttr = pElem->Attribute("name");
            SupportedTypesVariant value;
            try
            {
                value = fromStringToTypeVariableMap[pKey](pText);
            }
            catch(boost::bad_lexical_cast&)
            {
                throw XML::WrongTypeOfValueException(pKey,pText);
            }
			if (pKey.length() > 0 && pText.length() > 0)
			{
			    config[pAttr] = value;
			}
        }
	}

}
コード例 #15
0
	void ArchiveTree::load(string filename) {
		TiXmlDocument doc(filename);
		doc.LoadFile();

		TiXmlHandle hDoc(&doc);
		TiXmlHandle hRoot(0);
		TiXmlElement *pElem=hDoc.FirstChildElement().Element();
		for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
			string entry_name = pElem->ValueStr();
			printf("%s\n", entry_name.c_str());
		}
	}
コード例 #16
0
ファイル: playlist.cpp プロジェクト: zurn/Zakes
void playlist::load(std::string filename)
{
	music.clear();

	if (access(filename.c_str(), F_OK)==-1) {
		printf("No playlist found(%s).  No music will played.\n",
			filename.c_str());
		return;
	}

	TiXmlDocument doc(filename.c_str());
	doc.LoadFile();

	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem;
	TiXmlHandle hRoot(0);

	pElem=hDoc.FirstChildElement().Element();
	// should always have a valid root but handle gracefully if it doesn't
	if (!pElem) {
		printf("Error opening: %s.  No music will played.\n", filename.c_str());
		return;
	}
//	printf("name: %s\n", pElem->Value());
	hRoot=TiXmlHandle(pElem);
	TiXmlElement * songs = hRoot.FirstChild().Element();

	for (; songs!=NULL; songs=songs->NextSiblingElement()) {
		const char *pKey=songs->Value();
		const char *pText=songs->GetText();

		if (!pKey || !pText)
			continue;
//	printf("loop: %s %s\n", pKey, pText);

		std::string file = pText;
		std::string disp;
//	songs->QueryStringAttribute("display", &disp);
		if (songs->QueryStringAttribute("display", &disp)!= TIXML_SUCCESS)
			disp = file;
//	printf("%s: %s\n", disp.c_str(), file.c_str());
		if (access(file.c_str(), F_OK)==-1) {
			//no file found
		}
		else {
			music.push_back(std::make_pair(disp, file));
		}
	}


}
コード例 #17
0
bool ModelLibrary::Load(Ogre::SceneManager* sc, string filename)
{   
	if (models)
	{
		for(int i = 0; i < models->size(); i++)
		{
			delete (*models)[i];
		}
		delete models;
	}
	
	models = new vector<SModel*>();
	
	TiXmlDocument doc(filename);
	
	if(doc.LoadFile())
	{
		Ogre::LogManager::getSingleton().logMessage("XML: Models loaded");
	}
	else
	{
		Ogre::LogManager::getSingleton().logMessage("XML: Foutje");
		if(doc.Error())
		{
			Ogre::LogManager::getSingleton().logMessage("XML: Fout");
			Ogre::LogManager::getSingleton().logMessage(filename);
			Ogre::LogManager::getSingleton().logMessage(doc.ErrorDesc());
		}
		return false;
	}
	
	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElement;
	TiXmlHandle hRoot(0);
	
	pElement = hDoc.FirstChildElement().Element(); //Get the root element.
	
	// Check if the root element is correct.
	if( !(pElement->ValueStr() == XMLROOT) )
	{
		Ogre::LogManager::getSingleton().logMessage("XML: Wrong root element");
		return false;
	}
	
	hRoot = TiXmlHandle(pElement); // Store the root element.
	
	// Load models.
	ModelLibrary::LoadModelsFromXML(sc, pElement);

	return true;
}
コード例 #18
0
ファイル: FontDef.cpp プロジェクト: DanAlbert/apollo
	bool FontDef::loadFromFile(const char* path)
	{
		TiXmlDocument doc(path);
		if (!doc.LoadFile(TIXML_ENCODING_UTF8))
			return false;

		TiXmlHandle hDoc(&doc);
		TiXmlElement* elem;
		TiXmlHandle hRoot(0);

		// root
		elem = hDoc.FirstChildElement().Element(); // /Font
		hRoot = TiXmlHandle(elem);
		
		this->resourcePath = elem->Attribute("file");

		for (elem = hRoot.FirstChild("Character").Element(); elem; elem = elem->NextSiblingElement())
		{
			char value;
			int x;
			int y;
			int width;
			int height;
			int xOffset;
			int yOffset;
			int xAdvance;

			value = (char)atoi(elem->GetText());
			elem->QueryIntAttribute("x", &x);
			elem->QueryIntAttribute("y", &y);
			elem->QueryIntAttribute("width", &width);
			elem->QueryIntAttribute("height", &height);
			elem->QueryIntAttribute("x-offset", &xOffset);
			elem->QueryIntAttribute("y-offset", &yOffset);
			elem->QueryIntAttribute("x-advance", &xAdvance);

			this->characters[value] = CharacterDef(
				value,
				x,
				y,
				width,
				height,
				xOffset,
				yOffset,
				xAdvance);
		}

		return true;
	}
コード例 #19
0
ファイル: GDMeshAttribute.cpp プロジェクト: MrPants23/ED1
	void GDMeshAttribute::OpenXML(const char* fileName)
	{
		TiXmlDocument doc(fileName);

		if(!doc.LoadFile())
			return;

		TiXmlHandle hDoc(&doc);
		TiXmlElement* elementPtr;
		TiXmlHandle hRoot(0);
		
		elementPtr = hDoc.FirstChildElement().Element();

		ReadXML(elementPtr);
	}
コード例 #20
0
bool RosGContainerPublisher::readXMLFile(const std::string& fileName)
{
  TiXmlDocument doc(fileName);
  if (!doc.LoadFile())
  {
    _log->error("Could not load XML file '%v'", fileName);
    return false;
  }

  TiXmlHandle hDoc(&doc);
  TiXmlElement* element;
  TiXmlHandle hRoot(0);

  // find root element
  {
    element = hDoc.FirstChildElement().Element();
    // should always have a valid root but handle gracefully if it does
    if (!element || strcmp("templates", element->Value()) != 0)
    {
      _log->error("Root element should be 'templates' but is '%v' in file '%v'", element->Value(), fileName);
      return false;
    }

    // save this for later
    hRoot = TiXmlHandle(element);
  }

  for (TiXmlElement* cElement = hRoot.FirstChildElement().Element(); cElement; cElement = cElement->NextSiblingElement())
  {
    const char *child = cElement->Value();

    if (!child)
    {
      _log->error("Invalid child '%v' of operations", child);
      return false;
    }
    else if (strcmp("template", child) == 0)
    {
      bool result = this->readTemplate(cElement);
    }
    else
    {
      _log->warn("Unknown child '%v', will be ignored", child);
    }
  }

  return true;
}
コード例 #21
0
ファイル: Example.cpp プロジェクト: ferreirasc/CG-2015-2
void searchXMLData(TiXmlElement* pElem)  
{  
	TiXmlHandle hRoot(0);  
	TiXmlElement* pSubElem = pElem;  
	TiXmlAttribute* pAttrib = NULL;  


	//Set current node to root node and determine childe node is exist or not  
	hRoot = TiXmlHandle(pSubElem);  
	pSubElem = hRoot.FirstChildElement().Element();  
	if (!pSubElem) return;  

	char* pszNode = NULL;  
	char* pszAttrib = NULL;  
	char* pszText = NULL;  

	while (pSubElem)  
	{  
		//node  
		pszNode = (char*)pSubElem->Value();  
		if (pszNode)  
		printf("Node: %s\n", pszNode);  

		//Attribute  
		pAttrib = pSubElem->FirstAttribute();  
		while (pAttrib)  
		{  
			char* pszAttrib = (char*)pAttrib->Name();  
			char* pszText = (char*)pAttrib->Value();  

			printf("------------Attribute: %s, Data: %s\n", pszAttrib, pszText);  

			pAttrib = pAttrib->Next();  
		}  

		//Data  
		pszText = (char*)pSubElem->GetText();  
		if (pszText)  
		printf("Text: %s\n", pszText);  

		// Recursive call for searching child node based current node  
		searchXMLData(pSubElem);  
		pSubElem = pSubElem->NextSiblingElement();  
	}  
}  
コード例 #22
0
	ObjectSet::ObjectSet(string filename_p) {
		filename = filename_p;

		need_update = false;

		TiXmlDocument doc(filename);
		if (!doc.LoadFile()) {
			Error::addMessage(Error::FILE_NOT_FOUND, LIBGENS_FILE_H_ERROR_READ_FILE_BEFORE + filename + LIBGENS_FILE_H_ERROR_READ_FILE_AFTER);
			return;
		}

		name = filename;
		size_t sep = name.find(LIBGENS_OBJECT_SET_NAME);
		if (sep != std::string::npos) {
			name = name.substr(sep + 8, name.size() - sep - 8);
		}
	
		size_t dot = name.find(LIBGENS_OBJECT_SET_EXTENSION);
		if (dot != string::npos) {
			name = name.substr(0, dot);
		}

		TiXmlHandle hDoc(&doc);
		TiXmlElement* pElem;
		TiXmlHandle hRoot(0);

		pElem=hDoc.FirstChildElement().Element();
		if (!pElem) {
			Error::addMessage(Error::EXCEPTION, LIBGENS_OBJECT_H_ERROR_READ_SET_BEFORE + filename + LIBGENS_OBJECT_H_ERROR_READ_SET_AFTER);
			return;
		}
		
		// Go past SetObject
		pElem=pElem->FirstChildElement();
		for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
			if (pElem->ValueStr() != LIBGENS_OBJECT_SET_LAYER_DEFINE) {
				Object *obj=new Object(pElem->ValueStr());
				obj->readXML(pElem);
				obj->setParentSet(this);
				objects.push_back(obj);
			}
		}
	}
コード例 #23
0
bool ETHParticleSystem::ReadFromFile(const str_type::string& fileName, const Platform::FileManagerPtr& fileManager)
{
	TiXmlDocument doc(fileName);
	str_type::string content;
	fileManager->GetUTFFileString(fileName, content);
	if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY))
		return false;

	TiXmlHandle hDoc(&doc);
	TiXmlHandle hRoot(0);

	TiXmlElement *pElem = hDoc.FirstChildElement().Element();
	if (!pElem)
		return false;

	hRoot = TiXmlHandle(pElem);

	return ReadFromXMLFile(hRoot.FirstChildElement().Element());
}
コード例 #24
0
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);
		}
	}
}
コード例 #25
0
ファイル: test_recorder.cpp プロジェクト: telnykha/VideoA
/*
	функция считывает контура  из файла out_с.xml 
	в массив g_zones
*/
void LoadContours(int w, int h)
{
   TiXmlDocument doc("out_c.xml");
   if (!doc.LoadFile())
    return;	

   TiXmlHandle hDoc(&doc);
   TiXmlElement* pElem = NULL;
   TiXmlHandle hRoot(0);

   pElem = hDoc.FirstChildElement().Element();
   if (pElem == NULL)
	   return;

   if (strcmp(pElem->Value(), "Contours") != 0)
	   return;
   int count = 0;
   double v = 0;
   for (TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling())
   {
	   if (strcmp(child->Value(), "Contour") != 0)
		   continue;	
	   int np = 0;
	   for (TiXmlNode* child1 = child->FirstChild(); child1; child1 = child1->NextSibling())
	   {
		   
		   child1->ToElement()->QueryDoubleAttribute("x",&v);
		   g_contours[count].Points[np].X = (float)(w*v/100.);
		   child1->ToElement()->QueryDoubleAttribute("y",&v);
		   g_contours[count].Points[np].Y = (float)(h*v/100.);
		   np++;
		   g_contours[count].NumPoints = np;
		   if (np >= C_MAX_POINTS)
			   break;
	   }
	   count++;
	   if (count >= C_MAX_OBJECTS)
		   break;
   }
   g_contours_count = count;
   MakeMaskImage(g_mask);
}
コード例 #26
0
ファイル: EMM.cpp プロジェクト: Everscent/LibXenoverse
	bool EMM::load(string filename) {
		name = nameFromFilenameNoExtension(filename, true);

		if (filename.find(".xml") != string::npos) {
			TiXmlDocument doc(filename);
			if (!doc.LoadFile()) {
				return false;
			}

			TiXmlHandle hDoc(&doc);
			TiXmlElement* pElem;
			TiXmlHandle hRoot(0);

			pElem = hDoc.FirstChildElement().Element();
			if (!pElem) {
				return false;
			}

			pElem = pElem->FirstChildElement();
			for (pElem; pElem; pElem = pElem->NextSiblingElement()) {
				string element_name = pElem->ValueStr();

				if (element_name == "EMMMaterial") {
					EMMMaterial *material = new EMMMaterial();
					material->readXML(pElem);
					materials.push_back(material);
				}
			}
		}
		else {
			File file(filename, LIBXENOVERSE_FILE_READ_BINARY);

			if (file.valid() && file.readHeader(LIBXENOVERSE_EMM_SIGNATURE)) {
				read(&file);
				file.close();
			}
			else return false;
		}

		return true;
	}
コード例 #27
0
ファイル: ETHScene.cpp プロジェクト: andresan87/Torch
bool ETHScene::LoadFromFile(const str_type::string& fileName)
{
	Platform::FileManagerPtr fileManager = m_provider->GetVideo()->GetFileManager();

	// load the scene from a file
	{
		Platform::FileBuffer file;
		fileManager->GetFileBuffer(fileName, file);
		if (!file)
		{
			ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: file not found (") << fileName << GS_L(")");
			m_provider->Log(ss.str(), Platform::FileLogger::ERROR);
			return false;
		}
	}
	m_minSceneHeight = 0.0f;
	m_maxSceneHeight = m_provider->GetVideo()->GetScreenSizeF().y;

	// Read the header and check if the file is valid
	TiXmlDocument doc(fileName);
	str_type::string content;
	fileManager->GetUTF16FileString(fileName, content);
	if (!doc.LoadFile(content, TIXML_ENCODING_LEGACY))
	{
		ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: file found, but parsing failed (") << fileName << GS_L(")");
		m_provider->Log(ss.str(), Platform::FileLogger::ERROR);
		return false;
	}

	TiXmlHandle hDoc(&doc);
	TiXmlHandle hRoot(0);

	TiXmlElement *pElement = hDoc.FirstChildElement().Element();
	if (!pElement)
	{
		ETH_STREAM_DECL(ss) << GS_L("ETHScene::Open: couldn't find root element (") << fileName << GS_L(")");
		m_provider->Log(ss.str(), Platform::FileLogger::ERROR);
		return false;
	}
	return ReadFromXMLFile(pElement);
}
コード例 #28
0
ファイル: MMeshLoad.cpp プロジェクト: Keedu/maratis
bool loadAnimFile(MMesh * mesh, const char * filename, const char * repertory)
{
	TiXmlDocument doc(filename);
	if(! doc.LoadFile())
		return false;

	TiXmlHandle hDoc(&doc);
	TiXmlElement * pRootNode;
	TiXmlHandle hRoot(0);

	// Maratis
	pRootNode = hDoc.FirstChildElement().Element();
	if(! pRootNode)
		return false;

	if(strcmp(pRootNode->Value(), "Maratis") != 0)
		return false;

	hRoot = TiXmlHandle(pRootNode);

	return loadAnim(pRootNode, repertory, mesh);
}
コード例 #29
0
bool XMLTransformationReader::readFile(const std::string& fileName)
{
  TiXmlDocument doc(fileName);
  if (!doc.LoadFile())
  {
    return false;
  }

  TiXmlHandle hDoc(&doc);
  TiXmlElement* element;
  TiXmlHandle hRoot(0);

  // find root element
  {
    element = hDoc.FirstChildElement().Element();
    // should always have a valid root but handle gracefully if it does
    if (!element || strcmp("transformations", element->Value()) != 0)
    {
      _log->error("Root element should be 'transformations' but is '%v' in file '%v'", element->Value(), fileName);
      return false;
    }

    // save this for later
    hRoot = TiXmlHandle(element);
  }

  // read Transformations
  for (element = hRoot.FirstChildElement("transformation").Element(); element; element = element->NextSiblingElement())
  {
    TransDesc* transformation = this->readTransformation(element);

    if (transformation)
      this->transformationDescs.push_back(transformation);
    else
      return false;
  }

  return true;
}
コード例 #30
0
ファイル: SpriteDef.cpp プロジェクト: DanAlbert/apollo
	// TODO: Overload this method. The other method should accept a
	// TiXmlElement* to <Sprite>
	bool SpriteDef::LoadFromFile(const char* szPath) throw(IOError)
	{
		Release();

		TiXmlDocument doc(szPath);
		if (!doc.LoadFile(TIXML_ENCODING_UTF8))
		{
			throw IOError(ERR_APOLLO_SPRITEDEF_LOAD);
		}

		TiXmlHandle hDoc(&doc);
		TiXmlElement* elem;
		TiXmlHandle hRoot(0);

		// root
		elem = hDoc.FirstChildElement().Element(); // /Sprite
		hRoot = TiXmlHandle(elem);
		elem->QueryIntAttribute("nFrames", &m_nFrames);
		elem->QueryIntAttribute("frame-time", &m_frameTime);

		m_Frames = new char*[m_nFrames];
		memset(m_Frames, 0, m_nFrames * sizeof(char*));

		elem = hRoot.FirstChild("Frame").Element(); // /Sprite/Frame
		for (int i = 0; i < m_nFrames; ++i)
		{
			if (elem)
			{
				const char* text = elem->GetText();
				m_Frames[i] = new char[strlen(text) + 1];
				
				strcpy(m_Frames[i], text);

				elem = elem->NextSiblingElement();
			}
		}

		return true;
	}