/**
 * This function loads the data of positions from the given file.
 *
 * @param szFilename the path of the file, from which the positions data
 * 	should be loaded from
 * @return the loaded positions data
 */
set< cVectorPosition > loadPositionData( const char * szFilename ){
	
	/*every setLoadedData element is created by loading a point vector and
	then property vectors till the next point vector*/
	set< cVectorPosition > setLoadedData;
	
	TiXmlDocument xmlDocData( szFilename );
	bool loadOkay = xmlDocData.LoadFile();
	if ( ! loadOkay ){
		cerr<<"Error: Failed to load file \""<< szFilename <<"\""<<endl;
	}

	TiXmlHandle xmlHandle( &xmlDocData );
	TiXmlElement * pXmlElementData = xmlHandle.FirstChildElement().Element();
	
	if ( pXmlElementData ) {
		string szElementName = pXmlElementData->Value();

		if ( szElementName != "data" ){
			cerr<<"Error: The name of the root element is "<< szElementName <<" and not \"data\"."<<endl;
		}
	
	}else{// pXmlElementData == NULL ->no root handle
		cerr<<"Error: No root handle in \""<< szFilename <<"\"."<<endl;
		return setLoadedData;
	}
	
	TiXmlHandle xmlHandleData( pXmlElementData );
	TiXmlElement * pXmlElement = xmlHandleData.FirstChild().Element();
	
	//no variables defined
	list<cFibVariable*> liDefinedVariables;
	intFib outStatus = 0;
	
	for( ; pXmlElement; pXmlElement = pXmlElement->NextSiblingElement() ){
		//load the vector lists for setLoadedData
		string szElementName = pXmlElement->Value();

		if ( szElementName != "vector" ){
			cerr<<"Error: The name of the data list element is "<< szElementName <<" and not \"vector\"."<<endl;
		}
		const char * szVectorXmlType = pXmlElement->Attribute( "type" );
		
		if ( szVectorXmlType == NULL ){
			cerr<<"Error: The vector has no type."<<endl;
		}else if ( string( szVectorXmlType ) == "position" ) {
		
			setLoadedData.insert(
				cVectorPosition( pXmlElement, outStatus, liDefinedVariables ) );
		}else{
			cerr<<"Error: The vector type is \""<<szVectorXmlType<<"\" and not \"position\"."<<endl;
		}
		if ( outStatus != 0 ){
			cerr<<"Error: While loading a "<< szVectorXmlType <<
				" vector. (outStatus="<< outStatus <<" )"<<endl;
			outStatus = 0;
		}
	}
	return setLoadedData;
}
Example #2
0
void ControlFIFO::poll ()
{
  if (fifo == -1)
    return;

  char temp[2048];
  temp[0] = '\0';
  int len = read(fifo, temp, 2048);
  if (len < 0)
    return;

  temp[len] = '\0';
  if (!strlen(temp))
    return;

  TiXmlDocument doc;
  doc.Parse(temp);
  if (!doc.RootElement()) {
    std::cerr <<" *** Invalid control data received:\n"<< temp << std::endl;
    return;
  }

  TiXmlElement* elem = doc.RootElement()->FirstChildElement();
  for (; elem; elem = elem->NextSiblingElement())
    if (callbacks.find(elem->Value()) != callbacks.end())
      callbacks[elem->Value()]->OnControl(elem);
}
Example #3
0
TileMap tilemapFromXML(TiXmlDocument* doc) {
	TileMap tilemap;
	
	// Get top level attributes for source tilemap
	TiXmlElement* tilemapElement = doc->FirstChild()->ToElement();
//	int totalWidth, totalHeight, inputTileWidth, inputTileHeight;
	assert(TIXML_SUCCESS == tilemapElement->QueryIntAttribute("width", &tilemap.totalWidth));
	assert(TIXML_SUCCESS == tilemapElement->QueryIntAttribute("height", &tilemap.totalHeight));
	assert(TIXML_SUCCESS == tilemapElement->QueryIntAttribute("tileWidth", &tilemap.tileWidth));
	assert(TIXML_SUCCESS == tilemapElement->QueryIntAttribute("tileHeight", &tilemap.tileHeight));
	
	tilemap.highestIndex = 0;
	
	// CREATE ORIGINAL TILEMAP (and find number of atlases)
	for (TiXmlNode* child = doc->FirstChild()->FirstChild(); child != 0; child = child->NextSibling()) {
		TiXmlElement* element = child->ToElement();
		
		if(0 == strcmp(element->Value(), "row")) {
			string rowText = element->GetText();
			vector<int> inputRow = parseRow(rowText);
			tilemap.tilemap.push_back(inputRow);
		}
		else if(0 == strcmp(element->Value(), "atlas")) {
			int atlasWidth, atlasHeight;
			
			assert(TIXML_SUCCESS == element->QueryIntAttribute("width", &atlasWidth));
			assert(TIXML_SUCCESS == element->QueryIntAttribute("height", &atlasHeight));
			
			tilemap.highestIndex += (atlasWidth / tilemap.tileWidth) * (atlasHeight / tilemap.tileHeight);
		}
	}
	
	return tilemap;
}
void ComponentOptionMust::setComponents(TiXmlHandle docMUSTHandle, string nameOption, string tradeId)
{

	TiXmlElement *Component;
	TiXmlElement *elem;

	TiXmlElement *Trade = docMUSTHandle.FirstChild("BODY").FirstChild("TRADELIST").FirstChild("MUST_TR").ToElement();

	while (Trade)
	{
		if (strcmp(Trade->FirstChild("TradeId")->ToElement()->GetText(), tradeId.c_str()) == 0)
		{
			Component = Trade->FirstChild("MPTradeData")->FirstChild("MPTRDATA")->FirstChild("MPTrDataXML")->FirstChild("MPTRDATAXML")->FirstChild("STRUCTURED_INSTRUMENT")->
				FirstChild("COMPONENT_LIST")->FirstChild("COMPONENT_OPTION")->ToElement();
			while (Component)
			{
				if (strcmp(Component->Value(), "COMPONENT_OPTION") == 0)
				{

					if (strcmp(Component->FirstChild("NAME")->ToElement()->GetText(), nameOption.c_str()) == 0)
					{
						payOrSell = Component->FirstChild("PORS")->ToElement()->GetText();
						freqString = Component->FirstChild("EXPIRY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("SCHED_DEF")->FirstChild("FREQ")->ToElement()->GetText();
						settlementType = Component->FirstChild("EXPIRY_SCHED")->FirstChild("ACTUAL_SETTLE_MODE")->ToElement()->GetText();

						//firstExpiry = Component->FirstChild("EXPIRY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("START_DATE")->FirstChild("DATE_FORMULA")->FirstChild("TARGET")->FirstChild("ATTRIBUTE")->ToElement()->GetText();
						//lastExpiry = Component->FirstChild("EXPIRY_SCHED")->FirstChild("BASIC_SCHED")->FirstChild("END_DATE")->FirstChild("DATE_FORMULA")->FirstChild("TARGET")->FirstChild("ATTRIBUTE")->ToElement()->GetText();

					}
				}
				break;
				Component = Component->NextSiblingElement();
			}

			//****** recherche du type de l'option

			elem = Trade->FirstChild("MPTradeData")->FirstChild("MPTRDATA")->FirstChild("MPTrDataXML")->FirstChild("MPTRDATAXML")->FirstChild("STRUCTURED_INSTRUMENT")->
				FirstChild("VARIABLE_LIST")->FirstChild("VARIABLE")->ToElement();

			while (elem)
			{
				if (strcmp(elem->Value(), "VARIABLE") == 0)
				{

					if (strcmp(elem->FirstChild("NAME")->ToElement()->GetText(), "OptionStyle") == 0)
					{
						typeOption = elem->FirstChild("FORMULA")->FirstChild("FORMULA_STRING")->ToElement()->GetText();
					}
					break;
				}
				elem = elem->NextSiblingElement();
			}

			break;
		}
		Trade = Trade->NextSiblingElement();
	}

}
Example #5
0
/* virtual */ bool OAUCResponseImpl::ResponseDataFinder::VisitExit (const TiXmlElement& element)
{
  if (in_uuid_ && opera_update_checker::system_utils::SystemUtils::strnicmp(element.Value(), "uid", 3) == 0)
    in_uuid_ = false;
  else if (in_lut_ && opera_update_checker::system_utils::SystemUtils::strnicmp(element.Value(), "lut", 3) == 0)
    in_lut_ = false;
  else if (find_retry_time_ && opera_update_checker::system_utils::SystemUtils::strnicmp(element.Value(), "retry", 5) == 0)
    in_retry_time_ = false;

  return true;
}
Example #6
0
/* virtual */ bool OAUCResponseImpl::ResponseDataFinder::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute )
{
  if (find_uuid_ && opera_update_checker::system_utils::SystemUtils::strnicmp(element.Value(), "uid", 3) == 0)
    in_uuid_ = true;
  else if (find_lut_ && opera_update_checker::system_utils::SystemUtils::strnicmp(element.Value(), "lut", 3) == 0)
    in_lut_ = true;
  else if (find_retry_time_ && opera_update_checker::system_utils::SystemUtils::strnicmp(element.Value(), "retry", 5) == 0)
    in_retry_time_ = true;

  return (find_uuid_ && !uuid_) || (find_lut_ && !lut_) || (find_retry_time_ && !has_retry_time_);
}
Example #7
0
void VersionInfoFactory::ParseVTable(TiXmlElement* vtable, VersionInfo* mem)
{
    TiXmlElement* pClassEntry;
    TiXmlElement* pClassSubEntry;
    /*
    // check for rebase, do rebase if check positive
    const char * rebase = vtable->Attribute("rebase");
    if(rebase)
    {
        int32_t rebase_offset = strtol(rebase, NULL, 16);
        mem->RebaseVTable(rebase_offset);
    }
    */
    // parse vtable entries
    pClassEntry = vtable->FirstChildElement();
    for(;pClassEntry;pClassEntry=pClassEntry->NextSiblingElement())
    {
        string type = pClassEntry->Value();
        const char *cstr_name = pClassEntry->Attribute("name");
        const char *cstr_vtable = pClassEntry->Attribute("vtable");
        uint32_t vtable = 0;
        if(cstr_vtable)
            vtable = strtol(cstr_vtable, NULL, 16);
        // it's a simple class
        if(type== "class")
        {
            mem->setClass(cstr_name, vtable);
        }
        // it's a multi-type class
        else if (type == "multiclass")
        {
            // get offset of the type variable
            const char *cstr_typeoffset = pClassEntry->Attribute("typeoffset");
            uint32_t typeoffset = 0;
            if(cstr_typeoffset)
                typeoffset = strtol(cstr_typeoffset, NULL, 16);
            t_class * mclass = mem->setClass(cstr_name, vtable, typeoffset);
            // parse class sub-entries
            pClassSubEntry = pClassEntry->FirstChildElement();
            for(;pClassSubEntry;pClassSubEntry=pClassSubEntry->NextSiblingElement())
            {
                type = pClassSubEntry->Value();
                if(type== "class")
                {
                    // type is a value loaded from type offset
                    cstr_name = pClassSubEntry->Attribute("name");
                    const char *cstr_value = pClassSubEntry->Attribute("type");
                    mem->setClassChild(mclass,cstr_name,cstr_value);
                }
            }
        }
    }
}
Example #8
0
static bool ReadDeviceCertificate(const CStdString& deviceCertificate, AppInfo* appInfo)
{
  TiXmlDocument xmlDoc;

  if(!xmlDoc.LoadFile(deviceCertificate))
  {
    CLog::Log(LOGERROR, "CAppSecurity::%s - Failed to load %s", __func__, deviceCertificate.c_str());
    return false;
  }

  TiXmlElement* root = xmlDoc.RootElement();
  if(!root)
  {
    CLog::Log(LOGERROR,"CAppSecurity::%s - Failed to get root from BXXMLDocument of %s", __func__, deviceCertificate.c_str());
    return false;
  }

  CStdString type, serial, mac;
  while (root)
  {
    if(strcmp(root->Value(),"device") == 0)
    {
      type = root->Attribute("type");
      serial = root->Attribute("sn");
      mac = root->Attribute("mac");

      root = root->FirstChildElement();
      continue;
    }
    else if(strcmp(root->Value(),"signature") == 0)
    {
      appInfo->signature = root->FirstChild()->Value();
    }

    root = root->NextSiblingElement();
  }  

  bool bVerified = false;
  do
  {
     if(appInfo->signature.IsEmpty())
     {
       CLog::Log(LOGERROR,"CAppSecurity::%s - Device signature is empty", __func__);
       break;
     }

    bVerified = true;

  } while(false);

  return bVerified;
}
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;
}
bool CBusStopConfig::SaveBusStop(TiXmlElement* pElement)
{
	for (TiXmlElement* pChiled = pElement->FirstChildElement(); pChiled != NULL; pChiled = pChiled->NextSiblingElement())
	{
		const char* szValue = pChiled->Value();
// 		if(strcmp(Layout, szValue) == 0)
// 		{
// 			string strLeft = pChiled->Attribute(Left);
// 			string strRight = pChiled->Attribute(Right);
// 			string strTop = pChiled->Attribute(Top);
// 			string strBottom = pChiled->Attribute(Bottom);
// 
// 			m_size.left = atoi(strLeft.c_str());
// 			m_size.right = atoi(strRight.c_str());
// 			m_size.top = atoi(strTop.c_str());
// 			m_size.bottom = atoi(strBottom.c_str());
// 		}
		if(strcmp(Static, szValue) == 0)
		{
			for (TiXmlElement* pStatic = pChiled->FirstChildElement(); pStatic != NULL; pStatic = pStatic->NextSiblingElement())
			{
				const char* szStaticValue = pStatic->Value();
				if(strcmp(City, szStaticValue) == 0)
				{
					pStatic->SetAttribute(ID, m_strCityCode.c_str());
				}
				else if(strcmp(CurStop, szStaticValue) == 0)
				{
					pStatic->SetAttribute(ID, m_strStopID.c_str());
					pStatic->SetAttribute(Name, m_strStopName.c_str());
				}
// 				else if(strcmp(Attrib, szStaticValue) == 0)
// 				{
// 					string strLineCount = pStatic->Attribute(LineCount);
// 					string strOneBord = pStatic->Attribute(OneBord);
// 					m_nLineCount = atoi(strLineCount.c_str());
// 					m_nOneBord = atoi(strOneBord.c_str());
// 				}
				else if(strcmp(StaticData, szStaticValue) == 0)
				{
					pStatic->SetAttribute(Dir, m_strStaticData.c_str());
				}
			}
		}
	}

	return true;
}
Example #11
0
bool SSHTablesConfig::Parse(string xmlFile) {
	TiXmlDocument *doc = new TiXmlDocument(xmlFile.c_str());
    if (doc->LoadFile()) {
		TiXmlElement *root = doc->RootElement();
		TiXmlElement *pack = root->FirstChildElement();
		while (pack != NULL) {
			if (string(pack->Value()) == "package-path") {
				packagePath = pack->GetText();
			}

			if (string(pack->Value()) == "tables") {
				TiXmlElement *t = pack->FirstChildElement();
				while (t != NULL) {
					if (string(t->Value()) == "table") {
						Table table;
						TiXmlElement *tb = t->FirstChildElement();
						while (tb != NULL) {	
							if (string(tb->Value()) == "name") {
								table.name = tb->GetText();
							}
							if (string(tb->Value()) == "schema") {
								table.schema = tb->GetText();
							}
							if (string(tb->Value()) == "objectName") {
								table.objectName = tb->GetText();
							}

							if (string(tb->Value()) == "columns") {
								TiXmlElement *col = tb->FirstChildElement();
								while (col != NULL) {
									if (string(col->Value()) == "column") {
										Column column = {"undefined", "undefined"};
										column.name = col->GetText();
										TiXmlAttribute *attr = col->FirstAttribute();
										while (attr != NULL) {
											if (string(attr->Name()) == "type") {
												column.type = attr->Value();
											}
											attr = attr->Next();
										}
										table.columns.push_back(column);
									}
									col = col->NextSiblingElement();
								}
							}
							tb = tb->NextSiblingElement();
						}
						t = t->NextSiblingElement();
						tables.push_back(table);
					}
				}
			}
			pack = pack->NextSiblingElement();
		}
		return true;
	}  
	return false;
}
Example #12
0
static void ParseItem(CFileItem* item, SResources& resources, TiXmlElement* root, const std::string& path)
{
  for (TiXmlElement* child = root->FirstChildElement(); child; child = child->NextSiblingElement())
  {
    std::string name = child->Value();
    std::string xmlns;
    size_t pos = name.find(':');
    if(pos != std::string::npos)
    {
      xmlns = name.substr(0, pos);
      name.erase(0, pos+1);
    }

    if      (xmlns == "media")
      ParseItemMRSS   (item, resources, child, name, xmlns, path);
    else if (xmlns == "itunes")
      ParseItemItunes (item, resources, child, name, xmlns, path);
    else if (xmlns == "voddler")
      ParseItemVoddler(item, resources, child, name, xmlns, path);
    else if (xmlns == "boxee")
      ParseItemBoxee  (item, resources, child, name, xmlns, path);
    else if (xmlns == "zn")
      ParseItemZink   (item, resources, child, name, xmlns, path);
    else if (xmlns == "svtplay")
      ParseItemSVT    (item, resources, child, name, xmlns, path);
    else
      ParseItemRSS    (item, resources, child, name, xmlns, path);
  }
}
Example #13
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;
}
void ParticleSystemLoader::ProcessParticleMesh (TiXmlElement* xmlElem, Particle* prototype, 
	const std::string& filename)
{
	Model* mesh = NULL; 

	std::string type = xmlElem->Attribute ("type");

	if (type == "Primitive") {
		Primitive::Type ptype = (Primitive::Type) 
			std::stoi (xmlElem->Attribute ("index"));

		mesh = Primitive::Instance ()->Create (ptype);
	}
	else if (type == "Path") {
		std::string path = xmlElem->Attribute ("path");
		path = FileSystem::GetDirectory (filename) + path;

		mesh = Resources::LoadModel (path);
	}

	TiXmlElement* content = xmlElem->FirstChildElement ();

	while (content) {
		std::string name = content->Value ();

		if (name == "Material") {
			ProcessMeshMaterial (content, mesh, filename);
		}

		content = content->NextSiblingElement ();
	}

	prototype->SetMesh (mesh);
}
Example #15
0
TiXmlElement* CSiteManager::GetElementByPath(TiXmlElement* pNode, std::list<wxString> const& segments)
{
	for (std::list<wxString>::const_iterator it = segments.begin(); it != segments.end(); ++it)
	{
		const wxString & segment = *it;
		
		TiXmlElement* pChild;
		for (pChild = pNode->FirstChildElement(); pChild; pChild = pChild->NextSiblingElement())
		{
			const char* value = pChild->Value();
			if (strcmp(value, "Server") && strcmp(value, "Folder") && strcmp(value, "Bookmark"))
				continue;

			wxString name = GetTextElement_Trimmed(pChild, "Name");
			if (name.empty())
				name = GetTextElement_Trimmed(pChild);
			if (name.empty())
				continue;

			if (name == segment)
				break;
		}
		if (!pChild)
			return 0;

		pNode = pChild;
		continue;
	}

	return pNode;
}
Example #16
0
bool CScraperUrl::ParseString(CStdString strUrl)
{
  if (strUrl.empty())
    return false;

  CXBMCTinyXML doc;
  /* strUrl is coming from internal sources (usually generated by scraper or from database)
   * so strUrl is always in UTF-8 */
  doc.Parse(strUrl, TIXML_ENCODING_UTF8);

  TiXmlElement* pElement = doc.RootElement();
  if (!pElement)
  {
    SUrlEntry url;
    url.m_url = strUrl;
    url.m_type = URL_TYPE_GENERAL;
    url.m_season = -1;
    url.m_post = false;
    url.m_isgz = false;
    m_url.push_back(url);
    m_xml = strUrl;
  }
  else
  {
    while (pElement)
    {
      ParseElement(pElement);
      pElement = pElement->NextSiblingElement(pElement->Value());
    }
  }

  return true;
}
bool CAdvertisementConfig::AnalyseAdver(TiXmlElement* pElement)
{
	for (TiXmlElement* pChiled = pElement->FirstChildElement(); pChiled != NULL; pChiled = pChiled->NextSiblingElement())
	{
		const char* szValue = pChiled->Value();
		if(strcmp(Layout, szValue) == 0)
		{
			string strLeft = pChiled->Attribute(Left);
			string strRight = pChiled->Attribute(Right);
			string strTop = pChiled->Attribute(Top);
			string strBottom = pChiled->Attribute(Bottom);

			m_size.left = atoi(strLeft.c_str());
			m_size.right = atoi(strRight.c_str());
			m_size.top = atoi(strTop.c_str());
			m_size.bottom = atoi(strBottom.c_str());
		}
		else if(strcmp(Down, szValue) == 0)
		{
			m_strDownPort = pChiled->Attribute(Port);
		}
		else if(strcmp(Local, szValue) == 0)
		{
			m_strSourceDir = pChiled->Attribute(Dir);
		}
		else if(strcmp(Play, szValue) == 0)
		{
			m_strPlaylist = pChiled->Attribute(Dir);
		}
	}

	return true;
}
Example #18
0
//-----------------------------------------------------
bool ReadXmlFile_unattend(string& szFileName)
{   //读取Xml文件,并遍历
    try
    {
        string fullPath = "D:\\"+szFileName;

        //创建一个XML的文档对象。
        TiXmlDocument *myDocument = new TiXmlDocument(fullPath.c_str());
        myDocument->LoadFile();
        //获得根元素,即Persons。
        TiXmlElement *RootElement = myDocument->RootElement();
        //输出根元素名称,即输出Persons。
        cout << RootElement->Value() << endl;
        //获得第一个Person节点。
        TiXmlElement *FirstSettings = RootElement->FirstChildElement();
        //获得第一个Person的name节点和age节点和ID属性。
        TiXmlElement *Component = FirstSettings->FirstChildElement();
        TiXmlElement *ComputerName = Component->FirstChildElement();
        //输出第一个Person的name内容,即周星星;age内容,即;ID属性,即。
        cout << Component->FirstChild()->Value() << endl;
        cout << ComputerName->FirstChild()->Value() << endl;

        ComputerName->FirstChild()->SetValue("asdf");

        myDocument->SaveFile(fullPath.c_str());//保存到文件

        cout << ComputerName->FirstChild()->Value() << endl;
    }
    catch (string& e)
    {
        return false;
    }
    return true;
}
Example #19
0
bool CScraperUrl::ParseString(CStdString strUrl)
{
  if (strUrl.IsEmpty())
    return false;

  // ok, now parse the xml file
  if (!XMLUtils::HasUTF8Declaration(strUrl))
    g_charsetConverter.unknownToUTF8(strUrl);

  TiXmlDocument doc;
  doc.Parse(strUrl.c_str(),0,TIXML_ENCODING_UTF8);

  TiXmlElement* pElement = doc.RootElement();
  if (!pElement)
  {
    SUrlEntry url;
    url.m_url = strUrl;
    url.m_type = URL_TYPE_GENERAL;
    url.m_season = -1;
    url.m_post = false;
    url.m_isgz = false;
    m_url.push_back(url);
    m_xml = strUrl;
  }
  else
  {
    while (pElement)
    {
      ParseElement(pElement);
      pElement = pElement->NextSiblingElement(pElement->Value());
    }
  }

  return true;
}
Example #20
0
bool CGUIColorManager::LoadXML(TiXmlDocument &xmlDoc)
{
  TiXmlElement* pRootElement = xmlDoc.RootElement();

  CStdString strValue = pRootElement->Value();
  if (strValue != CStdString("colors"))
  {
    CLog::Log(LOGERROR, "color file doesnt start with <colors>");
    return false;
  }

  const TiXmlElement *color = pRootElement->FirstChildElement("color");

  while (color)
  {
    if (color->FirstChild() && color->Attribute("name"))
    {
      color_t value = 0xffffffff;
      sscanf(color->FirstChild()->Value(), "%x", (unsigned int*) &value);
      CStdString name = color->Attribute("name");
      iColor it = m_colors.find(name);
      if (it != m_colors.end())
        (*it).second = value;
      else
        m_colors.insert(make_pair(name, value));
    }
    color = color->NextSiblingElement("color");
  }
  return true;
}
//----------------------------------------------------------------------------
int CDotSceneSerializer::ReadSubEntity(TiXmlElement *element, CBaseEditor *parent, CBaseEditor **ret)
{
    OgitorsPropertyValueMap params;
    OgitorsPropertyValue propValue;
 
    propValue.propType = PROP_STRING;

    TiXmlElement* subs = 0;
    Ogre::String eType;
    subs = element->FirstChildElement();
    if(!subs) return SCF_OK;
    do
    {
        eType = subs->Value();
        if(eType == "subentity")
        {
            Ogre::String idx = ValidAttr(subs->Attribute("index"),"0");
            Ogre::String matname = ValidAttr(subs->Attribute("materialName"));
            propValue.val = Ogre::Any(matname);
            params["subentity" + idx + "::material"] = propValue;
        }
    } while(subs = subs->NextSiblingElement());

    parent->getProperties()->initValueMap(params);

    return SCF_OK;
}
Example #22
0
/**
 * 从字符串中初始化
 */
bool tixmlCode::initFromString(const char *content)
{
    TiXmlDocument doc;
    doc.Parse(content);
    static std::string CODE="code";
    static std::string READ="read";
    TiXmlHandle hDoc(&doc);
    TiXmlElement* pElem = NULL;
    pElem=hDoc.FirstChildElement().Element();
    for(; pElem; pElem=pElem->NextSiblingElement())
    {
        const char *pKey=pElem->Value();
        tixmlCodeNode *node = new tixmlCodeNode();
        node->init(pElem);
        if (node->nodeName == CODE)
        {
            parseCode(node);
        }
        else if (node->nodeName == READ)
        {
            std::string fileName = node->getAttr("file");
            init(fileName.c_str()); // 加载其他文本进入当前执行环境
        }
        else
        {
            takeNode(node); // 调用使用者的方法
        }
    }
    return  true;
}
void ParticleSystemLoader::ProcessParticle (TiXmlElement* xmlElem, Emiter* emiter, 
	const std::string& filename)
{
	std::string type = xmlElem->Attribute ("type");

	Particle* particlePrototype = nullptr;

	if (type == "BILLBOARD") {
		particlePrototype = new BillboardParticle ();
	} 
	else if (type == "MESH") {
		particlePrototype = new MeshParticle ();
	}

	TiXmlElement* content = xmlElem->FirstChildElement ();

	while (content) {
		std::string name = content->Value ();

		if (name == "Mesh") {
			ProcessParticleMesh (content, particlePrototype, filename);
		}

		content = content->NextSiblingElement ();
	}

	emiter->SetParticlePrototype (particlePrototype);
}
Example #24
0
bool ReadXmlFile(std::string& szFileName)
{//读取Xml文件,并遍历
	try
	{
		std::string fullPath = GetAppPath();
		fullPath += "\\";
		fullPath += szFileName;
		//创建一个XML的文档对象。
		TiXmlDocument *myDocument = new TiXmlDocument(fullPath.c_str());
		myDocument->LoadFile();
		//获得根元素,即Persons。
		TiXmlElement *RootElement = myDocument->RootElement();
		//输出根元素名称,即输出Persons。
		std::cout << RootElement->Value() << std::endl;
		//获得第一个Person节点。
		TiXmlElement *FirstPerson = RootElement->FirstChildElement();
		//获得第一个Person的name节点和age节点和ID属性。
		TiXmlElement *NameElement = FirstPerson->FirstChildElement();
		TiXmlElement *AgeElement = NameElement->NextSiblingElement();
		TiXmlAttribute *IDAttribute = FirstPerson->FirstAttribute();
		//输出第一个Person的name内容,即周星星;age内容,即;ID属性,即。
		std::cout << NameElement->FirstChild()->Value() << std::endl;
		std::cout << AgeElement->FirstChild()->Value() << std::endl;
		std::cout << IDAttribute->Value()<< std::endl;
	}
	catch (std::string& e)
	{
		return false;
	}
	return true;
}
Example #25
0
	void SVG::handle_group( TiXmlElement* pathElement ) {
		string id_;
//		if ( pathElement->QueryStringAttribute( "id", &id_) == TIXML_SUCCESS ) {
//			//_handler->onId( id_ );
//			cout << "group begin: " << id_ << endl;
//		}

		_handler->onGroupBegin();
		
		// handle transform and other parameters
		handle_general_parameter( pathElement );
		
		// go through all the children
		TiXmlElement* children = pathElement->FirstChildElement();
		for ( TiXmlElement* child = children; child != 0; child = child->NextSiblingElement() ) {
			string type = child->Value();
			handle_xml_element( child );
		}
		
		_handler->onGroupEnd();
		
//		if ( pathElement->QueryStringAttribute( "id", &id_) == TIXML_SUCCESS ) {
//			//_handler->onId( id_ );
//			cout << "group end: " << id_ << endl;
//		}


	}
// static member function
HeeksObj* COrientationModifier::ReadFromXMLElement(TiXmlElement* element)
{
	COrientationModifier* new_object = new COrientationModifier();

	std::list<TiXmlElement *> elements_to_remove;

	// read point and circle ids
	for(TiXmlElement* pElem = TiXmlHandle(element).FirstChildElement().Element(); pElem; pElem = pElem->NextSiblingElement())
	{
		std::string name(pElem->Value());
		if(name == "params"){
			new_object->m_params.ReadParametersFromXMLElement(pElem);
			elements_to_remove.push_back(pElem);
		}
	}

	for (std::list<TiXmlElement*>::iterator itElem = elements_to_remove.begin(); itElem != elements_to_remove.end(); itElem++)
	{
		element->RemoveChild(*itElem);
	}

	new_object->ReadBaseXML(element);

	return new_object;
}
//----------------------------------------------------------------------------
int CDotSceneSerializer::ReadSceneNode(TiXmlElement *element, CBaseEditor *parent, CBaseEditor **ret)
{
    OgitorsPropertyValueMap params;
    OgitorsPropertyValue propValue;
 
    propValue.propType = PROP_STRING;
    Ogre::String name = ValidAttr(element->Attribute("name"));
    if(Ogitors::OgitorsRoot::getSingletonPtr()->FindObject(name))
        propValue.val = Ogre::Any(Ogre::String("Node") + Ogitors::OgitorsRoot::getSingletonPtr()->CreateUniqueID("Node",""));
    else
        propValue.val = Ogre::Any(name);

    params["name"] = propValue;

    TiXmlElement* subs = 0;
    Ogre::String eType;
    subs = element->FirstChildElement();
    if(!subs) return SCF_OK;
    do
    {
        eType = subs->Value();
        if(eType == "scale")
            params["scale"] = parseVector3(subs);
        else if(eType == "position")
            params["position"] = parseVector3(subs);
        else if(eType == "rotation")
            params["orientation"] = parseQuaternion(subs);
    } while(subs = subs->NextSiblingElement());
    
    *ret = Ogitors::OgitorsRoot::getSingletonPtr()->CreateEditorObject(parent, "Node Object", params, false, false);
    return SCF_OK;
}
void HelloWorld::parseTinyXmlFile()
{
	try
	{
		char filePath[1024]= {'\0'};
		memset(filePath,0,sizeof(filePath));
		strcat(filePath,CCFileUtils::sharedFileUtils()->getWriteablePath().c_str());
		strcat(filePath,"CreatedTinyXml.xml");

		//创建一个XML的文档对象。
		TiXmlDocument *myDocument = new TiXmlDocument(filePath);
		myDocument->LoadFile();
		//获得根元素,即Persons。
		TiXmlElement *RootElement = myDocument->RootElement();
		//输出根元素名称,即输出Persons。
		CCLOG(RootElement->Value());
		//获得第一个Person节点。
		TiXmlElement *FirstPerson = RootElement->FirstChildElement();
		//获得第一个Person的name节点和age节点和ID属性。
		TiXmlElement *NameElement = FirstPerson->FirstChildElement();
		TiXmlElement *AgeElement = NameElement->NextSiblingElement();
		TiXmlAttribute *IDAttribute = FirstPerson->FirstAttribute();
		//输出第一个Person的name内容,即周星星;age内容,即;ID属性,即。

		CCLOG(NameElement->FirstChild()->Value());
		CCLOG(AgeElement->FirstChild()->Value());
		CCLOG(IDAttribute->Value());
	}
	catch (string& e)
	{
		return ;
	}
	return ;
}
Example #29
0
bool CSiteManager::ClearBookmarks(wxString sitePath)
{
	if (sitePath[0] != '0')
		return false;

	sitePath = sitePath.Mid(1);

	// We have to synchronize access to sitemanager.xml so that multiple processed don't write
	// to the same file or one is reading while the other one writes.
	CInterProcessMutex mutex(MUTEX_SITEMANAGER);

	CXmlFile file;
	TiXmlElement* pDocument = file.Load(_T("sitemanager"));

	if (!pDocument)
	{
		wxString msg = file.GetError() + _T("\n") + _("The bookmarks could not be cleared.");
		wxMessageBox(msg, _("Error loading xml file"), wxICON_ERROR);

		return false;
	}

	TiXmlElement* pElement = pDocument->FirstChildElement("Servers");
	if (!pElement)
		return false;

	std::list<wxString> segments;
	if (!UnescapeSitePath(sitePath, segments))
	{
		wxMessageBox(_("Site path is malformed."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement* pChild = GetElementByPath(pElement, segments);
	if (!pChild || strcmp(pChild->Value(), "Server"))
	{
		wxMessageBox(_("Site does not exist."), _("Invalid site path"));
		return 0;
	}

	TiXmlElement *pBookmark = pChild->FirstChildElement("Bookmark");
	while (pBookmark)
	{
		pChild->RemoveChild(pBookmark);
		pBookmark = pChild->FirstChildElement("Bookmark");
	}

	wxString error;
	if (!file.Save(&error))
	{
		if (COptions::Get()->GetOptionVal(OPTION_DEFAULT_KIOSKMODE) == 2)
			return true;

		wxString msg = wxString::Format(_("Could not write \"%s\", the selected sites could not be exported: %s"), file.GetFileName().GetFullPath().c_str(), error.c_str());
		wxMessageBox(msg, _("Error writing xml file"), wxICON_ERROR);
	}

	return true;
}
bool CDSPSettings::LoadSettingsData(bool initial)
{
  TiXmlDocument xmlDoc;
  string strSettingsFile = GetSettingsFile();

  if (!xmlDoc.LoadFile(strSettingsFile))
  {
    if (initial)
    {
      if (!SaveSettingsData())
      {
        KODI->Log(LOG_ERROR, "failed to create initial settings data file at '%s')", strSettingsFile.c_str());
        return false;
      }
      return true;
    }
    else
      KODI->Log(LOG_ERROR, "invalid settings data (no/invalid data file found at '%s')", strSettingsFile.c_str());
    return false;
  }

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (strcmp(pRootElement->Value(), "freesurround") != 0)
  {
    if (!initial)
      KODI->Log(LOG_ERROR, "invalid settings data (no <circlesurround2> tag found)");
    return false;
  }

  TiXmlElement *pElement = pRootElement->FirstChildElement("settings");
  if (pElement)
  {
    if (!XMLUtils::GetFloat(pElement, "inputgain", m_Settings.fInputGain))
      m_Settings.fInputGain = 0.70794576;
    if (!XMLUtils::GetFloat(pElement, "circularwrap", m_Settings.fCircularWrap))
      m_Settings.fCircularWrap = 90;
    if (!XMLUtils::GetFloat(pElement, "shift", m_Settings.fShift))
      m_Settings.fShift = 0.0f;
    if (!XMLUtils::GetFloat(pElement, "depth", m_Settings.fDepth))
      m_Settings.fDepth = 1.0f;
    if (!XMLUtils::GetFloat(pElement, "centerimage", m_Settings.fCenterImage))
      m_Settings.fCenterImage = 1.0f;
    if (!XMLUtils::GetFloat(pElement, "focus", m_Settings.fFocus))
      m_Settings.fFocus = 0.0f;
    if (!XMLUtils::GetFloat(pElement, "frontseparation", m_Settings.fFrontSeparation))
      m_Settings.fFrontSeparation = 1.0;
    if (!XMLUtils::GetFloat(pElement, "rearseparation", m_Settings.fRearSeparation))
      m_Settings.fRearSeparation = 1.0;
    if (!XMLUtils::GetBoolean(pElement, "bassredirection", m_Settings.bLFE))
      m_Settings.bLFE = false;
    if (!XMLUtils::GetFloat(pElement, "lowcutoff", m_Settings.fLowCutoff))
      m_Settings.fLowCutoff = 40.0;
    if (!XMLUtils::GetFloat(pElement, "highcutoff", m_Settings.fHighCutoff))
      m_Settings.fHighCutoff = 90.0;
  }

  return true;
}