Example #1
0
void SPDImplementation::parseUsesDevices(TiXmlElement *elem)
{
    DEBUG(4, SPDImplementation, "In parseUsesDevices.");

    TiXmlElement *uses = elem->FirstChildElement("usesdevice");

    for (; uses; uses = uses->NextSiblingElement("usesdevice")) {
        const char *id = uses->Attribute("id");
        const char *type = uses->Attribute("type");

        CF::Properties props;
        unsigned int i(0);

        TiXmlElement *prop = uses->FirstChildElement("propertyref");
        for (; prop; prop = prop->NextSiblingElement("propertyref")) {
            const char *refid = prop->Attribute("refid");
            const char *value = prop->Attribute("value");
            props.length(i+1);
            props[i].id = CORBA::string_dup (refid);
            props[i].value <<= value;
            i++;
        }

        usesDevice.push_back(new SPDUsesDevice (id, type, props));
    }
}
Example #2
0
TiXmlElement* CImportDialog::GetFolderWithName(TiXmlElement* pElement, const wxString& name)
{
	TiXmlElement* pChild;
	for (pChild = pElement->FirstChildElement("Server"); pChild; pChild = pChild->NextSiblingElement("Server"))
	{
		wxString childName = GetTextElement(pChild);
		childName.Trim(true);
		childName.Trim(false);
		if (!name.CmpNoCase(childName))
			return 0;
	}

	for (pChild = pElement->FirstChildElement("Folder"); pChild; pChild = pChild->NextSiblingElement("Folder"))
	{
		wxString childName = GetTextElement(pChild);
		childName.Trim(true);
		childName.Trim(false);
		if (!name.CmpNoCase(childName))
			return pChild;
	}

	pChild = pElement->LinkEndChild(new TiXmlElement("Folder"))->ToElement();
	AddTextElement(pChild, name);

	return pChild;
}
void XMLConfigReader::getAdaptersFromXML(TiXmlElement* ruleEngineElm, RuleEngine *engine) {
	for (TiXmlElement* adapterElm = ruleEngineElm->FirstChildElement("adapter");
			adapterElm != NULL; adapterElm = adapterElm->NextSiblingElement("adapter")) {
		TiXmlElement* conditionElm = adapterElm->FirstChildElement("rule");
		if(conditionElm != NULL){
			std::string rule = std::string(conditionElm->GetText());
			int delimiterLoc = rule.find(":");
			Adapter *adapter = new Adapter(new Rule(rule.substr(0, delimiterLoc),
					rule.substr(delimiterLoc + 1, rule.length()).at(0)));
			for (TiXmlElement* actionElm = adapterElm->FirstChildElement("action");
					actionElm != NULL; actionElm = actionElm->NextSiblingElement("action")) {
				std::string actionTxt = std::string(actionElm->GetText());
				if(actionTxt == "ADD"){
					adapter->addAction(ADD);
				} else if(actionTxt == "DEL"){
					adapter->addAction(DEL);
				} else if(actionTxt == "MOD"){
					adapter->addAction(MOD);
				} else if(actionTxt == "SHF"){
					adapter->addAction(SHF);
				} else {
					std::cerr << "Action: " << actionTxt << " not defined!!" << std::endl;
				}
			}
			engine->addAdapter(adapter);
		}
	}
}
Example #4
0
void CharacterLoader::Load(TiXmlDocument& doc)
{
	TiXmlElement* root = doc.FirstChildElement("Body");
	root = root->FirstChildElement("Character");
	while (root)
	{
		TiXmlAttribute* attribute = root->FirstAttribute();
		std::string str = attribute->Name();
		if (str == "name")
		{
			std::string characterName = attribute->Value();
			std::string fileName;
			int x1 = -1, x2 = -1, y1 = -1, y2 = -1;
			TiXmlElement* element = root->FirstChildElement("a");
			
			while (element)
			{
				TiXmlAttribute* attrib = element->FirstAttribute();
				while (attrib)
				{
					std::string name = attrib->Name();
					std::string value = attrib->Value();
					addValue(characterName, name, value);

					attrib = attrib->Next();
				}
				element = element->NextSiblingElement("a");
			}

		}

		root = root->NextSiblingElement("Character");
	}
}
bool parseSpriteNode(SpriteNode* node, TiXmlElement* elemParent)
{
	//TODO: there is a leak here somewhere.
	SpriteBlock* oldSibling = NULL;
	TiXmlElement* elemNode =  elemParent->FirstChildElement();
	const char* strParent = elemParent->Value();
	if (elemNode == NULL)
	{
		contentError("Empty SpriteNode Element",elemParent);
		return false;		
	}
	if ( strcmp(strParent,"building") != 0 && strcmp(strParent,"custom_workshop") != 0 && strcmp(strParent,"rotate") != 0)
	{
		//flag to allow else statements to be empty, rather than needing an "always" tag
		bool allowBlank = (strcmp(strParent,"else") == 0 || elemParent->Attribute("else"));
		// cast should be safe, because only spriteblocks
		// should get here
		int retvalue =parseConditionNode((SpriteBlock *)node,elemNode,allowBlank);
		if (retvalue == 0)
			return false;
		if (retvalue > 0)
			elemNode = elemNode->NextSiblingElement();
	}
	while (elemNode)
	{ 
		if (!readNode(node, elemNode, elemParent, oldSibling))
			return false;
		elemNode = elemNode->NextSiblingElement();
	}
	return true;
}
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 #7
0
void ImageLoader::Load(TiXmlDocument& doc)
{
	TiXmlElement* root = doc.FirstChildElement("Body");
	root = root->FirstChildElement("Image");
	while (root)
	{
		TiXmlAttribute* attribute = root->FirstAttribute();
		std::string str = attribute->Name();
		if (str == "name")
		{
			std::string imageName = attribute->Value();
			std::string fileName;
			int x1 = -1, x2 = -1, y1 = -1, y2 = -1;
			TiXmlElement* element = root->FirstChildElement("a");
			if (element)
			{
				if (element->Attribute("file"))
				{
					fileName = element->Attribute("file");
				}
			}

			element = root->FirstChildElement("rect");

			while (element)
			{

				TiXmlAttribute* attrib = element->FirstAttribute();
				while (attrib)
				{
					std::string name = attrib->Name();
					if (name == "x1")
					{
						x1 = attrib->IntValue();
					}
					else if (name == "x2")
					{
						x2 = attrib->IntValue();
					}
					else if (name == "y1")
					{
						y1 = attrib->IntValue();
					}
					else if (name == "y2")
					{
						y2 = attrib->IntValue();
					}

					attrib = attrib->Next();
				}
				element = element->NextSiblingElement("rect");
			}

			internalCreate(imageName, fileName, x1, y1, x2, y2);
		}

		root = root->NextSiblingElement("Image");
	}
}
Example #8
0
/* virtual */ opera_update_checker::status::Status OAUCRequestImpl::AddProductUpdatePart(const UpdateDataProvider& provider)
{
  try
  {
    if (!document_.RootElement())
    {
      document_.Parse(update_request_root);
      if (document_.Error())
        return opera_update_checker::status::StatusCode::FAILED;
    }

    TiXmlDocument temp;

    TIXML_STRING name(provider.GetProductName() ? provider.GetProductName() : "");
    TIXML_STRING encoded_name;
    TIXML_STRING ver(provider.GetProductVersion() ? provider.GetProductVersion() : "");
    TIXML_STRING encoded_ver;
    TIXML_STRING lang(provider.GetProductLanguage() ? provider.GetProductLanguage() : "");
    TIXML_STRING encoded_lang;
    document_.EncodeString(name, &encoded_name);
    document_.EncodeString(ver, &encoded_ver);
    document_.EncodeString(lang, &encoded_lang);

    sprintf(shared_work_buffer,
            update_product_part_template,
            encoded_name.c_str() ? encoded_name.c_str() : "",
            encoded_ver.c_str() ? encoded_ver.c_str() : "",
            encoded_lang.c_str() ? encoded_lang.c_str() : "");

      temp.Parse(shared_work_buffer);
      if (temp.Error())
        return opera_update_checker::status::StatusCode::FAILED;

      OAUC_ASSERT(document_.RootElement() && document_.RootElement()->FirstChildElement());
      TiXmlElement* child = document_.RootElement()->FirstChildElement();
      while (opera_update_checker::system_utils::SystemUtils::strnicmp(child->Value(), "product", 7) != 0)
      {
        child = child->NextSiblingElement();
        OAUC_ASSERT(child);
      }

      TiXmlElement* elm = temp.RootElement();
      do
      {
        child->InsertEndChild(*elm);
        elm = elm->NextSiblingElement();
      } while (elm);

      if (TiXmlElement* products = product_res_document_.RootElement())
        child->InsertEndChild(*products);
  }
  catch (...)
  {
    return opera_update_checker::status::StatusCode::OOM;
  }

  return opera_update_checker::status::StatusCode::OK;
}
Example #9
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 #10
0
int ServerConf::ReadMailList(TiXmlElement *root)
{
	TiXmlElement *servercfg = root->FirstChildElement("clientconn");	
	if(!servercfg){
		AC_ERROR("read clientconn error");
		return -1;	
	}
	const char* str;
	str = servercfg->Attribute("beatthreadsleep", &m_Beatthreadsleep);	
	if(!str){	
		AC_ERROR("read beatthreadsleep error");
		return -1;	
	}	
	AC_INFO("client beatthreadsleep = %d",m_Beatthreadsleep);
	TiXmlElement *mailsvrcfg = servercfg->FirstChildElement("mailserver");
	while(mailsvrcfg)
	{
		s_SrvList tmps;
		str=mailsvrcfg->Attribute("servername");
		if(!str){
			AC_ERROR("read servername error");
			return -1;
		}
		AC_INFO("read servername :%s",str);
		tmps.srvname = str;
		str=mailsvrcfg->Attribute("sender");
		if(!str){
			AC_ERROR("read sender error");
			return -1;
		}
		AC_INFO("read sender :%s",str);
		tmps.sender = str;
		str=mailsvrcfg->Attribute("password");
		if(!str){
			AC_ERROR("read password error");
			return -1;
		}
		AC_INFO("read password :%s",str);
		tmps.password = str;
		TiXmlElement *mailcfg = mailsvrcfg->FirstChildElement("mail");	
		while(mailcfg){
			str = mailcfg->Attribute("mailname");		
			if(!str){
				AC_ERROR("read mailname error");
				return -1;
			}
			AC_INFO("read mailname :%s",str);
			string strtmp = str;
			tmps.ListOfMail.push_back(strtmp);
			mailcfg = mailcfg->NextSiblingElement("mail");
		}
		m_ListOfMail.push_back(tmps);
		mailsvrcfg = mailsvrcfg->NextSiblingElement("mailserver");
	}
	return 0;
}
Example #11
0
void DataModel::loadStage()
{
    TiXmlDocument* myDocument = new TiXmlDocument();
    unsigned char* pBuffer = NULL;
    ssize_t bufferSize = 0;
    pBuffer = FileUtils::getInstance()->getFileData("stage.xml", "r", &bufferSize);
    if (pBuffer) {
        myDocument->Parse((const char*)pBuffer);
        TiXmlElement* stage = myDocument->RootElement();
        TiXmlElement* points = stage->FirstChildElement();
        TiXmlElement* point = points->FirstChildElement();
        while (points) {
            const char *name = points->Attribute("name");
            __Array *temp = __Array::create();
            
            while (point) {
                TiXmlAttribute *x = point->FirstAttribute();
                int pointX = x->IntValue();
                int pointY = x->Next()->IntValue();
                if (_winSize.height < 1100) {
                    pointY = pointY - 25;
                }
                temp->addObject(new MyPoint(pointX ,_winSize.height / 1280.0 * pointY));
                point = point->NextSiblingElement();
            }
            if (StringUtils::format("s9%d",flag9) == std::string(name)) {
                stage9.pushBack(temp);
                flag9++;
            }
            if (StringUtils::format("s5%d",flag5) == std::string(name)) {
                stage5.pushBack(temp);
                flag5++;
            }
            if (StringUtils::format("s6%d",flag6) == std::string(name)) {
                stage6.pushBack(temp);
                flag6++;
            }
            point = points->FirstChildElement();
            points = points->NextSiblingElement();
        }
        Ref *obj;
        MyPoint *p;
        for (auto a: stage5) {
            
            CCARRAY_FOREACH(a, obj)
            {
                p = (MyPoint *)obj;
            }
            
        }

    }
 
}
Example #12
0
void YafFile::processCameras(TiXmlElement* camerasElement)
{
    char* rootId = (char*)camerasElement->Attribute("initial");
    char* id;
    string testRoot=rootId;
    TiXmlElement* orthoElement = camerasElement->FirstChildElement("ortho");
    TiXmlElement* perspectiveElement = camerasElement->FirstChildElement("perspective");
    CGFcamera* cam;
    float near, far, left, right, top, bottom;
    unsigned int i = 0;
    while(orthoElement != NULL)
    {
        orthoElement->QueryFloatAttribute("near", &near);
        orthoElement->QueryFloatAttribute("far", &far);
        orthoElement->QueryFloatAttribute("left", &left);
        orthoElement->QueryFloatAttribute("right", &right);
        orthoElement->QueryFloatAttribute("top", &top);
        orthoElement->QueryFloatAttribute("bottom", &bottom);
        id=(char*)orthoElement->Attribute("id");
        cam = new OrthoCamera(near, far, left, right, top, bottom,id==rootId);
        sceneCameras.push_back(make_pair(id,cam));
        orthoElement = orthoElement->NextSiblingElement("ortho");
        string test = id;
        if(test==testRoot)
        {
            camera=i;
        }
        else
            i++;
    }

    while(perspectiveElement != NULL)
    {
        float position[3],target[3],angle;
        perspectiveElement->QueryFloatAttribute("near", &near);
        perspectiveElement->QueryFloatAttribute("far", &far);
        perspectiveElement->QueryFloatAttribute("angle", &angle);
        read3Float("pos", perspectiveElement, position[0], position[1], position[2]);
        read3Float("target", perspectiveElement, target[0], target[1], target[2]);
        id=(char*)perspectiveElement->Attribute("id");
        cam = new PerspectiveCamera(id==rootId,near, far, angle, position[0], position[1],
                                    position[2], target[0], target[1], target[2]);
        sceneCameras.push_back(make_pair(id,cam));
        string test = id;
        if(test==testRoot)
        {
            camera=i;
        }
        else
            i++;
        perspectiveElement = perspectiveElement->NextSiblingElement("perspective");
    }
}
Example #13
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);
                }
            }
        }
    }
}
static void DoLayers()
{
/* ---- */
/* Open */
/* ---- */

	XML_TKEM		xml( gArgs.GetXML(), flog );
	TiXmlElement*	layer	= xml.GetFirstLayer();

/* ------------------------- */
/* Kill layers outside range */
/* ------------------------- */

	TiXmlNode*		lyrset = layer->Parent();
	TiXmlElement*	next;

	for( ; layer; layer = next ) {

		// next layer0 before deleting anything
		next = layer->NextSiblingElement();

		int	z = atoi( layer->Attribute( "z" ) );

		if( z < gArgs.zmin || z > gArgs.zmax )
			lyrset->RemoveChild( layer );
	}

/* --------------------------- */
/* Copies for remaining layers */
/* --------------------------- */

	layer = lyrset->FirstChild( "t2_layer" )->ToElement();

	for( ; layer; layer = layer->NextSiblingElement() ) {

		int	z = atoi( layer->Attribute( "z" ) );

		gArgs.NewLayer( z );
		UpdateTiles( layer );
	}

/* ---- */
/* Save */
/* ---- */

	xml.Save( "xmltmp.txt", true );

/* ------------------ */
/* Rename version two */
/* ------------------ */

	gArgs.RenameXML();
}
Example #15
0
/**
 *	@method PigManager::loadLevel()
 *	@desc   parse the current level xml and instantiate the pigs in it
 */
void PigManager::loadLevel(TiXmlElement* levelPigElement)
{
	if (numPigs > 0)
	{
		shutdown();
	}

	numPigs = 0;
	TiXmlElement* levelPig = levelPigElement->FirstChildElement();
	while (levelPig != NULL)
	{
		numPigs++;
		levelPig = levelPig->NextSiblingElement();
	}

	pigList = new EnemyPig*[numPigs];
	int i = 0;
	int x, y;
	float wid, ht;

	levelPig = levelPigElement->FirstChildElement();
	ObjectData currentPigData;

	while (levelPig != NULL)
	{
		const char* currentBlockType = levelPig->Attribute("type");
		int j;
		for (j = 0; j < totalPossiblePigs; j++)
		{
			if (strcmp(currentBlockType, allPigsData[j].objectType) == 0)
			{
				currentPigData = allPigsData[j];
				break;
			}
		}
		assert(j < totalPossiblePigs);

		levelPig->QueryIntAttribute("x", &x);
		levelPig->QueryIntAttribute("y", &y);
		levelPig->QueryFloatAttribute("wid", &wid);
		levelPig->QueryFloatAttribute("ht", &ht);

		pigList[i] = new EnemyPig();
		pigList[i]->init(x, y, wid, currentPigData);

		levelPig = levelPig->NextSiblingElement();
		i++;
	}

	CGame::GetInstance()->setPigCount(numPigs);

}
Example #16
0
const std::list<CServer> CRecentServerList::GetMostRecentServers(bool lockMutex /*=true*/)
{
	CInterProcessMutex mutex(MUTEX_MOSTRECENTSERVERS, false);
	if (lockMutex)
		mutex.Lock();

	if (!m_XmlFile.HasFileName() || m_XmlFile.Modified())
		m_XmlFile.Load(_T("recentservers"));
	else
		return m_mostRecentServers;

	TiXmlElement* pElement = m_XmlFile.GetElement();
	if (!pElement || !(pElement = pElement->FirstChildElement("RecentServers")))
		return m_mostRecentServers;

	m_mostRecentServers.clear();
    
	bool modified = false;
	TiXmlElement* pServer = pElement->FirstChildElement("Server");
	while (pServer)
	{
		CServer server;
		if (!GetServer(pServer, server) || m_mostRecentServers.size() >= 10)
		{
			TiXmlElement* pRemove = pServer;
			pServer = pServer->NextSiblingElement("Server");
			pElement->RemoveChild(pRemove);
			modified = true;
		}
		else
		{
			std::list<CServer>::const_iterator iter;
			for (iter = m_mostRecentServers.begin(); iter != m_mostRecentServers.end(); iter++)
			{
				if (*iter == server)
					break;
			}
			if (iter == m_mostRecentServers.end())
				m_mostRecentServers.push_back(server);
			pServer = pServer->NextSiblingElement("Server");
		}
	}

	if (modified)
	{
		wxString error;
		m_XmlFile.Save(&error);
	}

	return m_mostRecentServers;
}
Example #17
0
void Poof::init(TiXmlElement* poofElement)
{
	int totalPoofFrames = 0;
	TiXmlElement* poofSprite = poofElement->FirstChildElement()->FirstChildElement();
	while (poofSprite != NULL)
	{
		poofSprite = poofSprite->NextSiblingElement();
		totalPoofFrames++;
	}

	poofData.numSprites = totalPoofFrames;
	poofData.spriteData = (SpriteStateData *)malloc(poofData.numSprites * sizeof(SpriteStateData));

	int j = 0;
	poofSprite = poofElement->FirstChildElement()->FirstChildElement();
	while (poofSprite != NULL)
	{
		poofData.spriteData[j].spriteState = poofSprite->Attribute("state");
		poofSprite->QueryFloatAttribute("xPosLeft", &poofData.spriteData[j].uLeft);
		poofSprite->QueryFloatAttribute("xPosRight", &poofData.spriteData[j].uRight);
		poofSprite->QueryFloatAttribute("yPosTop", &poofData.spriteData[j].vTop);
		poofSprite->QueryFloatAttribute("yPosBottom", &poofData.spriteData[j].vBottom);

		poofSprite = poofSprite->NextSiblingElement();
		j++;
	}

	float imageWidth, imageHeight;
	poofElement->QueryFloatAttribute("imageWidth", &imageWidth);
	poofElement->QueryFloatAttribute("imageHeight", &imageHeight);

	poofRenderer = new Renderer();
	poofRenderer->init(poofElement->Attribute("src"), totalPoofFrames, imageWidth, imageHeight);

	int k = 0;

	for (j = 0; j < poofData.numSprites; j++)
	{
		poofRenderer->setUTextureLeft(k, poofData.spriteData[j].uLeft);
		poofRenderer->setUTextureRight(k, poofData.spriteData[j].uRight);
		poofRenderer->setVTextureTop(k, poofData.spriteData[j].vTop);
		poofRenderer->setVTextureBottom(k, poofData.spriteData[j].vBottom);

		poofData.spriteData[j].rendererIndex = k;

		k++;
	}
}
void ProjectConfiguration::XmlLoad(TiXmlElement* Node,cbProject* Project)
{
    m_GlobalUsedLibs.Clear();
    m_TargetsUsedLibs.clear();
    m_DisableAuto = false;

    TiXmlElement* LibFinder = Node->FirstChildElement("lib_finder");
    if ( !LibFinder ) return;

    int noauto = 0;
    if ( (LibFinder->QueryIntAttribute("disable_auto",&noauto) == TIXML_SUCCESS) && noauto )
    {
        m_DisableAuto = true;
    }

    for ( TiXmlElement* Elem = LibFinder->FirstChildElement("lib");
            Elem;
            Elem = Elem->NextSiblingElement("lib") )
    {
        wxString LibName = cbC2U(Elem->Attribute("name"));
        if ( !LibName.IsEmpty() && m_GlobalUsedLibs.Index(LibName)==wxNOT_FOUND )
        {
            m_GlobalUsedLibs.Add(LibName);
        }
    }

    for ( TiXmlElement* Elem = LibFinder->FirstChildElement("target");
            Elem;
            Elem = Elem->NextSiblingElement("target") )
    {
        wxString TargetName = cbC2U(Elem->Attribute("name"));
        if ( !Project->GetBuildTarget(TargetName) ) continue;

        wxArrayString& Libs = m_TargetsUsedLibs[TargetName];
        for ( TiXmlElement* LibElem = Elem->FirstChildElement("lib");
                LibElem;
                LibElem = LibElem->NextSiblingElement("lib") )
        {
            wxString LibName = cbC2U(LibElem->Attribute("name"));
            if ( !LibName.IsEmpty() && Libs.Index(LibName)==wxNOT_FOUND )
            {
                Libs.Add(LibName);
            }
        }
    }

    // TODO: Invoke library settings check
}
Example #19
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 #20
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 #21
0
bool CScraperUrl::ParseEpisodeGuide(CStdString strUrls)
{
    if (strUrls.IsEmpty())
        return false;

    // ok, now parse the xml file
    if (strUrls.Find("encoding=\"utf-8\"") < 0)
        g_charsetConverter.stringCharsetToUtf8(strUrls);

    TiXmlDocument doc;
    doc.Parse(strUrls.c_str(),0,TIXML_ENCODING_UTF8);
    if (doc.RootElement())
    {
        TiXmlHandle docHandle( &doc );
        TiXmlElement *link = docHandle.FirstChild( "episodeguide" ).FirstChild( "url" ).Element();
        while (link)
        {
            ParseElement(link);
            link = link->NextSiblingElement("url");
        }
    }
    else
        return false;
    return true;
}
Example #22
0
   virtual void process(TiXmlElement* root, int version)
   {
      static_cast<void>(version);
      std::string mngr;
      utilib::get_string_attribute( root, "process_manager", mngr, 
                            ExecuteManager::default_process_mngr );
      ExecuteMngr().set_process_manager(mngr);
      

      // each child element should be a valid command...
      TiXmlElement* node = root->FirstChildElement();

      // special case: if it is an empty element, just execute the last
      // solver
      if ( node == NULL )
      {
         string solver = SolverMngr().get_newest_solver();
         if ( ! solver.empty() )
            ExecuteMngr().run_command(string("solve:") + solver);
         return;
      }
      
      int rank;
      int myRank = ExecuteMngr().rank();

      // step through all the commands
      for( ; node != NULL; node = node->NextSiblingElement() )
      {
         utilib::get_num_attribute( node, "rank", rank, ExecuteManager::local );
         if (( rank == ExecuteManager::local ) || ( rank == myRank ))
            ExecuteMngr().run_command(node->ValueStr(), rank, node);
      }
   }
Example #23
0
bool PeerManage::DelayInitialize()
{
    if (NULL == (m_pCallBackSystem = (CallBackSystem *)m_pCoreModuleManage->GetModule("CallBackSystem")))
    {
        Assert(false);
        LOG_ERROR("Get CallBackSystem error");
        return false;
    }

    char strConfigPath[PATH_LENGTH] = {0};
    const char * pStrPathFolder = GetAppPath();
    sprintf_s(strConfigPath, "%s/%s", pStrPathFolder, CONFIG_PATH_PEERCONFIG);

    TiXmlDocument xmlConfig;
    if (false == xmlConfig.LoadFile(strConfigPath))
    {
        LOG_ERROR("Load PeerManage Error");
        return false;
    }

    TiXmlElement * pRootElement = xmlConfig.RootElement();
    TiXmlElement * pPeerTypeElm = pRootElement->FirstChildElement("PeerType");

    while (pPeerTypeElm != NULL)
    {
        if (false == GetConfig(pPeerTypeElm))
        {
            LOG_ERROR("Load PeerManage Error");
        }
        pPeerTypeElm = pPeerTypeElm->NextSiblingElement();
    }

    return true;
}
Example #24
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;
}
Example #25
0
// XML format is of strUrls is:
// <TAG><url>...</url>...</TAG> (parsed by ParseElement) or <url>...</url> (ditto)
bool CScraperUrl::ParseEpisodeGuide(CStdString strUrls)
{
  if (strUrls.empty())
    return false;

  // ok, now parse the xml file
  CXBMCTinyXML doc;
  /* strUrls is coming from internal sources so strUrls is always in UTF-8 */
  doc.Parse(strUrls, TIXML_ENCODING_UTF8);
  if (doc.RootElement())
  {
    TiXmlHandle docHandle( &doc );
    TiXmlElement *link = docHandle.FirstChild("episodeguide").Element();
    if (link->FirstChildElement("url"))
    {
      for (link = link->FirstChildElement("url"); link; link = link->NextSiblingElement("url"))
        ParseElement(link);
    }
    else if (link->FirstChild() && link->FirstChild()->Value())
      ParseElement(link);
  }
  else
    return false;

  return true;
}
Example #26
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;
}
void ModelLibrary::LoadAnimsFromXML(TiXmlElement* parent, vector<SAnimation*>* anims, vector<SSound*>* sounds)
{
	TiXmlElement* child;
	for(child = parent->FirstChildElement(); child; child = child->NextSiblingElement())
	{
		if (child->ValueStr() == "sound") 
		{
			SSound* s = new SSound();
			s->filename = child->Attribute(FILENAME);
			child->Attribute(SOUNDLOOP, &s->soundloop);
			sounds->push_back(s);

			Ogre::LogManager::getSingleton().logMessage("XML: SOUND: "+s->filename);
		}
		else if (child->ValueStr() == "animation")
		{
			SAnimation* a = new SAnimation();
			a->name = child->Attribute(ANIMNAME);
			child->Attribute(FRAMES, &a->frames);
			child->Attribute(LOOP, &a->loop);
			anims->push_back(a);

			Ogre::LogManager::getSingleton().logMessage("XML: ANIM: "+a->name);
		}
		else
		{
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : should never get here *giggles*");
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : culporate: "+child->ValueStr());
		};
	}
}
void wxsItemResData::LoadToolsReq(TiXmlElement* Node,bool IsXRC,bool IsExtra)
{
    for ( TiXmlElement* Object = Node->FirstChildElement("object"); Object; Object = Object->NextSiblingElement("object") )
    {
        wxString Class = cbC2U(Object->Attribute("class"));
        if ( Class.IsEmpty() ) continue;
        const wxsItemInfo* Info = wxsItemFactory::GetInfo(Class);
        if ( !Info ) continue;
        if ( Info->Type != wxsTTool )
        {
            LoadToolsReq(Object,IsXRC,IsExtra);
            continue;
        }
        if ( !(GetPropertiesFilter()&flSource) && !Info->AllowInXRC ) continue;
        wxsItem* Item = wxsItemFactory::Build(Class,this);
        if ( !Item ) continue;
        wxsTool* Tool = Item->ConvertToTool();
        if ( !Tool )
        {
            delete Item;
            continue;
        }
        if ( InsertNewTool(Tool) )
        {
            Tool->XmlRead(Object,IsXRC,IsExtra);
        }
    }
}
bool wxsItemResData::LoadInFileMode()
{
    TiXmlDocument Doc;
    if ( !TinyXML::LoadDocument(m_XrcFileName,&Doc) ) return false;

    TiXmlElement* Resource = Doc.FirstChildElement("resource");
    if ( !Resource ) return false;

    TiXmlElement* Object = Resource->FirstChildElement("object");
    while ( Object )
    {
        if ( cbC2U(Object->Attribute("name")) == m_ClassName ) break;
        Object = Object->NextSiblingElement("object");
    }

    if ( !Object ) return false;
    if ( cbC2U(Object->Attribute("class")) != m_ClassType ) return false;

    RecreateRootItem();
    if ( !m_RootItem ) return false;
    m_RootItem->XmlRead(Object,true,false);
    LoadToolsReq(Object,true,false);

    return true;
}
Example #30
0
/**
* 从xml文件中读取“键-值”对 load "key-value" from xml file
* @param filename 读取的xml文件,必须是按照规定的格式
* @return 布尔值 读取成功与否
*/
bool Properties::loadFromXML(const string filename)
{
	TiXmlDocument doc(filename.c_str());
	bool loadOkay = doc.LoadFile();//以utf-8格式读取xml文件
	if (!loadOkay)
	{
		return false;
	}
	TiXmlNode *node = doc.FirstChild("properties");
        #ifdef DEBUG_PROPERTIES_H
	node->Print(stdout, 1);
	cout << endl;
        #endif
	TiXmlElement* propertiesElement = node->ToElement();
	for(TiXmlElement *it = propertiesElement->FirstChildElement("entry")
		; it!=NULL ;
		it = it->NextSiblingElement("entry")
		)
	{
		TiXmlAttribute *att = it->FirstAttribute();
		this->setProperty(att->Value(), it->GetText());
		#ifdef DEBUG_PROPERTIES_H
		cout << "[" << att->Name() << ":" << att->Value() << "->" << it->GetText() << "]" << endl;
                #endif
	}
	return true;
}