Example #1
0
// Retrieves the color for player indicated in the 'controller' parameter from
// config file indicated in 'config_file' and returns it as type 'probe_color'.
// This functions will only load colors from the config file that are formatted
// in a 24 bit format.  Because of this, when you use ConfigManager::SetPlayerColor()
// you must make sure it is saving a color that is formatted in a 24 bit format.
// Please note that even though this function loads a 24 bit color, it'll reformat
// it so where it is a 32 bit color that'll include the value in 'cAlpha'.
const probe_color ConfigManager::GetPlayerColor(int controller, Uint8 cAlpha)
{
        Uint8 cRed;
        Uint8 cGreen;
        Uint8 cBlue;

	TiXmlHandle docHandle( config_file );
    TiXmlElement* key = docHandle.FirstChild( "Balder" ).FirstChild( "Player" ).Element();
    while(key)
    {
    	int c;
    	int result = key->QueryIntAttribute("controller",&c);
    	if (TIXML_SUCCESS == result){
    		if (controller == c){
    			TiXmlHandle h(key);
    			TiXmlElement *clrEl = h.FirstChild("Probe").FirstChild("Color").Element();
    			if (!clrEl) { return (probe_color)0;}
    			int colorSelected;
                        int gotColor = clrEl->QueryIntAttribute("probe_color", &colorSelected);
    			if (TIXML_SUCCESS == gotColor) {
                                if (colorSelected > 0xFFFFFF) colorSelected = 0xFFFFFF;
                                else if (colorSelected < 0) colorSelected = 0;

                                colorSelected = colorSelected << 8;
                                colorSelected += cAlpha;

                                return colorSelected;
                        }
    		}
    	}
	    key=key->NextSiblingElement("Player");
    }
    return 0;
}
Example #2
0
void HTContext::getBusMappings(std::map<int, int>& m)
{
    TiXmlDocument doc("../mapping.xml");
	if (!doc.LoadFile())
	{
		printf("GETBUSMAPPINGS: Unable to read config file!\n");
		return;
	}
	TiXmlHandle handle(&doc);
	TiXmlElement* curElem = handle.FirstChildElement().FirstChildElement("mapping").ToElement();

	if (!curElem)
	{
		printf("GETBUSMAPPINGS: Unable to find \"mapping\" elements!\n");
		return;
	}


	for (;curElem != 0; curElem = curElem->NextSiblingElement("mapping"))
	{
		int bus;
		int address;
		curElem->QueryIntAttribute("bus", &bus);
		curElem->QueryIntAttribute("id", &address);
		m.insert(std::pair<int, int>(bus, address));
		printf("MAPPING: BUS: %i to ADDRESS: %i\n", bus, address);
	}
}
Example #3
0
BOOL GetBkgPingCheckOpt(PBBS_BKG_PINGCHECK_OPT pPingOpt)
{
	TiXmlDocument doc;
	const char *pszCustomDest = NULL;
	bool bOperating = false;
	int nBreakInt = 0;
	int nPingInt = 0;
	int nMaxCount = 0;

	if( CheckValidXML(&doc) == FALSE )
	{
		return FALSE;
	}

	TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("BkgPingCheck");


	pElem->QueryBoolAttribute("Operating", &bOperating);
	pElem->QueryIntAttribute("BreakInterval",  &nBreakInt);
	pElem->QueryIntAttribute("PingInterval", &nPingInt);
	pElem->QueryIntAttribute("MaxCheckCnt", &nMaxCount);
	pszCustomDest = pElem->Attribute("CustomDestAddr");


	pPingOpt->bOperating = bOperating;
	pPingOpt->dwBreakInterval = nBreakInt;
	pPingOpt->dwPingInterval = nPingInt;
	pPingOpt->dwMaxCheckCount = nMaxCount;

	mbstowcs(pPingOpt->tszCustomDestAddr, pszCustomDest, strlen(pszCustomDest));

	return TRUE;
}
bool ConfigManager::Read(const wxString& name, wxColour* ret)
{
    wxString key(name);
    TiXmlElement* e = AssertPath(key);

    TiXmlHandle parentHandle(e);
    TiXmlElement *c = (TiXmlElement *) parentHandle.FirstChild(cbU2C(key)).FirstChild("colour").Element();

    if (c)
    {
        const char *isNull = c->Attribute("null");
        if (isNull && strcmp(isNull, "true") == 0)
        {
            *ret = wxNullColour;
            return true;
        }
        else
        {
            int r, g, b;
            if (c->QueryIntAttribute("r", &r) == TIXML_SUCCESS
                    && c->QueryIntAttribute("g", &g) == TIXML_SUCCESS
                    && c->QueryIntAttribute("b", &b) == TIXML_SUCCESS)
            {
                ret->Set(r, g, b);
                return true;
            }
        }
    }
    *ret = wxNullColour;
    return false;
}
Example #5
0
void FEPlayer::Deserialize(TiXmlDocument* _poXmlDoc, TiXmlElement* _poParent)
{
	TiXmlElement* poElement = _poParent->FirstChildElement("Player");
	if(poElement)
	{
		int isMovable, isDeletable;
		poElement->QueryIntAttribute("is_movable", &isMovable);
		poElement->QueryIntAttribute("is_deletable", &isDeletable);
		if(isMovable)
			AddFlags(EFEFlag_Movable);
		else
			RemoveFlags(EFEFlag_Movable);

		if(isDeletable)
			AddFlags(EFEFlag_Deletable);
		else
			RemoveFlags(EFEFlag_Deletable);

		TiXmlElement* poPosElement = poElement->FirstChildElement("Position");
		D_CHECK(poPosElement);

		double x, y;
		poPosElement->QueryDoubleAttribute("x", &x);
		poPosElement->QueryDoubleAttribute("y", &y);
		SetPosition(Vec3(x, y, 0.f));
		SetColor(GetColor(m_id));
	}
}
Example #6
0
	void ObjectRef::Init(TiXmlNode *node)
	{
		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;

			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				id = intValue;
			else
				id = 0;

			if (element->QueryIntAttribute("timeline", &intValue) == TIXML_SUCCESS)
				timeline = intValue;
			else
				timeline = 0;

			if (element->QueryIntAttribute("key", &intValue) == TIXML_SUCCESS)
				key = intValue;
			else
				key = 0;

			if (element->QueryIntAttribute("z_index", &intValue) == TIXML_SUCCESS)
				z_index = intValue;
			else
				z_index = 0;

		}
	}
Example #7
0
void GUI_Button::readAttributes(TiXmlElement* p_element)
{
	TiXmlElement* e = p_element->FirstChildElement("Title");
	if(e)
	{
		const char* p_title = e->GetText();
		setTitle(p_title ? p_title : "");
	}

	e = p_element->FirstChildElement("Image");
	if(e)
	{
		const char* p_imageFilename = e->GetText();
		if(p_imageFilename) setImageFilename(localizeString(p_imageFilename));

		e->QueryIntAttribute("u", &positionOnTexture.x);
		e->QueryIntAttribute("v", &positionOnTexture.y);

		e->QueryIntAttribute("u2", &clickedPositionOnTexture.x);
		e->QueryIntAttribute("v2", &clickedPositionOnTexture.y);
	}

	e = p_element->FirstChildElement("ExtendedStyle");
	if(e) style = 1;
}
void SerializedMessageList::ParseMessages(TiXmlElement *root)
{
#ifdef KNET_USE_TINYXML
	TiXmlElement *node = root->FirstChildElement("message");
	while(node)
	{
		SerializedMessageDesc desc;
		int success = node->QueryIntAttribute("id", (int*)&desc.id);
		if (success == TIXML_NO_ATTRIBUTE)
		{
			KNET_LOG(LogError, "Error parsing message attribute 'id' as int!");
			node = node->NextSiblingElement("message");
			continue; 
		}
		success = node->QueryIntAttribute("priority", (int*)&desc.priority);
		if (success == TIXML_NO_ATTRIBUTE)
			desc.priority = 0; // If priority not specified, use the default priority of zero - the lowest priority possible.
		if (node->Attribute("name"))
			desc.name = node->Attribute("name");
		desc.reliable = ParseBool(node->Attribute("reliable"));
		desc.inOrder = ParseBool(node->Attribute("inOrder"));
		desc.data = ParseNode(node, 0);

		// Work a slight convenience - if there is a single struct inside a single struct inside a single struct - jump straight through to the data.

		messages.push_back(desc);

		node = node->NextSiblingElement("message");
	}
#else
	throw NetException("kNet was built without TinyXml support! SerializedMessageList is not available!");
#endif
}
Example #9
0
bool LoadActionsXML(TiXmlHandle hActions, int enjoyments[], int enjoymentsMods[], int enjoymentsTemps[])
{
	TiXmlElement* pActions = hActions.ToElement();
	if (pActions == 0) return false;

	for (int x = 0; x < NUM_ACTIONTYPES; ++x)
	{
		TiXmlElement* pAction = pActions->FirstChildElement(XMLifyString(actionTypeNames[x]));
		
		// `J` a fix for the old WORKINTERN changed to WORKTRAINING
		if (x == ACTION_WORKTRAINING && !pAction) pAction = pActions->FirstChildElement(XMLifyString("WORKINTERN"));

		if (pAction)
		{
			int tempInt = 0;
			if (pAction->Attribute("Enjoys"))	pAction->QueryIntAttribute("Enjoys", &tempInt);
			if (tempInt < -100)	tempInt = -100; if (tempInt > 100)	tempInt = 100;
			enjoyments[x] = tempInt; 
			
			tempInt = 0;
			if (pAction->Attribute("Mod"))	pAction->QueryIntAttribute("Mod", &tempInt);
			enjoymentsMods[x] = tempInt;

			tempInt = 0;
			if (pAction->Attribute("Temp"))	pAction->QueryIntAttribute("Temp", &tempInt);
			enjoymentsTemps[x] = tempInt;
		}
	}
	return true;
}
Example #10
0
void ClassifierSVM::loadCache(TiXmlElement* settings, boost::filesystem::path file){
	clearData();

	svm = svm_load_model(file.c_str());

	TiXmlElement* pScales = settings->FirstChildElement("scales");
	if(!pScales){
		throw "Bad cache file - no scales";
	}
	pScales->QueryIntAttribute("desc_len", &descLen);
	scalesSub = new double[descLen];
	scalesDiv = new double[descLen];
	TiXmlElement* pValue = pScales->FirstChildElement("value");
	while(pValue){
		int d = -1;
		pValue->QueryIntAttribute("idx", &d);
		if(d == -1){
			throw "Bad cache file - no idx for value";
		}
		pValue->QueryDoubleAttribute("sub", &scalesSub[d]);
		pValue->QueryDoubleAttribute("div", &scalesDiv[d]);

		pValue = pValue->NextSiblingElement();
	}

	TiXmlElement* pLabels = settings->FirstChildElement("labels");
	if(!pLabels){
		throw "Bad cache file - no labels";
	}
	pLabels->QueryIntAttribute("num", &numLabels);
}
Example #11
0
void Graphe::importTemplate(QString & filename){

    TiXmlDocument doc(filename.toStdString());
    if(doc.LoadFile()){
        //TiXmlHandle hDoc(&doc);
        TiXmlElement * pRoot;
        TiXmlElement * pChildren;
        std::string temps;
        TiXmlElement * pGraph;
        pGraph = doc.FirstChildElement("Graph");
        if(pGraph){
            pRoot = pGraph->FirstChildElement("Nodes");
            int i, x, y;
            if(pRoot){
                pChildren = pRoot->FirstChildElement("Node");
                while(pChildren){
                    pChildren->QueryIntAttribute("id", &i);
                    if(i<n){
                        pChildren->QueryIntAttribute("x", &x);
                        pChildren->QueryIntAttribute("y", &y);
                        noeuds[i]= Noeud(x,y);
                        //qDebug()<<i;
                        if(pChildren->QueryStringAttribute("Label", &temps) == TIXML_SUCCESS){
                            //qDebug()<<QString(temps.c_str());
                            labels[i]= QString(temps.c_str());

                        }
                    }
                    pChildren = pChildren->NextSiblingElement("Node");
                }
            }
        }
    }
}
Example #12
0
GeneratorPtr Session::create_generator_from_node(TiXmlElement* element, Region* region){
    fsom::DebugStream << "Attempting to create generator"<<std::endl;
    GeneratorPtr gen = GeneratorPtr(new Generator(Generator::GEN_Sine,dspCreationStruct(region)));
    
    TiXmlElement* basicInfoElement = element->FirstChildElement("BasicInfo");
    if(basicInfoElement){
	fsom::DebugStream << "Generator basic info found"<<std::endl;
	int genType,noiseState;
	std::string path = basicInfoElement->Attribute("Path"); 
	basicInfoElement->QueryIntAttribute("GenType",&genType);
	basicInfoElement->QueryIntAttribute("NoiseState",&noiseState);
	Generator::GeneratorType type = Generator::GeneratorType(genType);
	gen->set_generator_voice(type);
	gen->set_noise_state(noiseState);
	gen->set_file_path(path);
	fsom::DebugStream << "noise state for gen set to "<<noiseState<<std::endl;
	fsom::DebugStream << "gen type = "<<genType<<std::endl;
	
	
	
    }
    
    TiXmlElement * child = element->FirstChildElement("Parameter");
    while(child){
      fsom::DebugStream << "Parameter in generator found"<<std::endl;
      ParameterPtr p = create_parameter_from_node(child, region);
      gen->get_parameter(p->get_name())->set_value(p->get_value());
      child = child->NextSiblingElement("Parameter");
    }
    
    return gen;
}
Example #13
0
bool CSPropExcitation::ReadFromXML(TiXmlNode &root)
{
	if (CSProperties::ReadFromXML(root)==false) return false;

	TiXmlElement *prop = root.ToElement();
	if (prop==NULL) return false;

	int iHelp;
	if (prop->QueryIntAttribute("Number",&iHelp)!=TIXML_SUCCESS) uiNumber=0;
	else uiNumber=(unsigned int)iHelp;

	if (prop->QueryIntAttribute("Type",&iExcitType)!=TIXML_SUCCESS) return false;

	if (ReadVectorTerm(Excitation,*prop,"Excite",0.0)==false) return false;

	ReadTerm(m_Frequency,*prop,"Frequency");
	ReadTerm(Delay,*prop,"Delay");

	TiXmlElement *weight = prop->FirstChildElement("Weight");
	if (weight!=NULL)
	{
		ReadTerm(WeightFct[0],*weight,"X");
		ReadTerm(WeightFct[1],*weight,"Y");
		ReadTerm(WeightFct[2],*weight,"Z");
	}

	ReadVectorTerm(PropagationDir,*prop,"PropDir",0.0);

	return true;
}
Example #14
0
// 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;
}
BOOL CMExerciseList::GetExerciseData(const char *eid, TExerciseListItem &item)
{
    BOOL ret = FALSE;
    CMString sPath = CMGlobal::TheOne().GetUserDir() + L"examexercise.xml";
    TiXmlDocument *pDoc = new TiXmlDocument(sPath);
    if(!pDoc)
		return ret;
	if(CMFile::FileExist(sPath))
	{
		pDoc->LoadFile(TIXML_ENCODING_UTF8);
        
		if(!pDoc->Error())
		{
			TiXmlElement *pRoot = pDoc->RootElement();
			if(pRoot)
			{
				TiXmlElement* pQuestion = pRoot->FirstChildElement("question");
				while(pQuestion)
				{
					const char* sid = pQuestion->Attribute("id");
                    
					if (strcmp(sid, eid) == 0)
					{
                        int curindex = 0;
                        pQuestion->QueryIntAttribute("index", &curindex);
                        item.nCurIndex = curindex;
                        
                        int rightcount = 0;
                        pQuestion->QueryIntAttribute("rightcount", &rightcount);
                        item.nRightCount = rightcount;
                        
                        TiXmlElement* pItem = pQuestion->FirstChildElement("item");
                        
                        int wrongcount = 0;
                        while (pItem)
                        {
                            int nWrong = 0;
                            pItem->Attribute("iswrong", &nWrong);
                            if (nWrong == 1) {
                                wrongcount++;
                            }
                            pItem = pItem->NextSiblingElement("item");
                        }
                        item.nWrongCount = wrongcount;
                    }
                    pQuestion = pQuestion->NextSiblingElement("question");
                }
            }
        }
    }
    
	SAFEDELETE(pDoc);
    
    return ret;
}
Example #16
0
	void Object::Init(TiXmlNode *node, CCSpriterX *animator)
	{
		sprite = NULL;

		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;
			float floatValue;

			if (element->QueryIntAttribute("folder", &intValue) == TIXML_SUCCESS)
				folder = intValue;
			else
				folder = 0;

			if (element->QueryIntAttribute("file", &intValue) == TIXML_SUCCESS)
				file = intValue;
			else
				file = 0;

			if (element->QueryFloatAttribute("x", &floatValue) == TIXML_SUCCESS)
				x = floatValue;
			else
				x = 0;

			if (element->QueryFloatAttribute("y", &floatValue) == TIXML_SUCCESS)
				y = floatValue;
			else
				y = 0;

			if (element->QueryFloatAttribute("angle", &floatValue) == TIXML_SUCCESS)
				angle = floatValue;
			else
				angle = 0;

			if (element->QueryFloatAttribute("pivot_x", &floatValue) == TIXML_SUCCESS)
				pivot_x = floatValue;
			else
				pivot_x = 0;

			if (element->QueryFloatAttribute("pivot_y", &floatValue) == TIXML_SUCCESS)
				pivot_y = floatValue;
			else
				pivot_y = 1;

			if (element->QueryIntAttribute("z_index", &intValue) == TIXML_SUCCESS)
				z_index = intValue;
			else
				z_index = 0;

			sprite = animator->getSprite(folder, file);

		}
	}
void CMQACategory::OnSessionCmd(unsigned int nCmdID, unsigned int nCode, TiXmlDocument* pDoc)
{
    
	INT32 result = TResult::EUnknownError;
    if (nCode == MER_OK)
    {

        IsUpdate=true;


        ASSERT(pDoc);
        TiXmlElement *pItem = pDoc->RootElement();

        INT32 nErr = 0;
		INT32 nCmdID = 0;
		pItem->QueryIntAttribute("no", &nCmdID);
        if(pItem->QueryIntAttribute("errno", &nErr) == TIXML_SUCCESS)
		{
            if (nErr == 0)
            {
				if(nCmdID == SERVICE_SEARCHCATEGERY )
				{
					if(!pItem->NoChildren())
					{
						if(m_lstCategoryItem)
							Clear(m_lstCategoryItem);
						else
							m_lstCategoryItem = new CMList<CMQACategoryItem*>();
						CycParser(pItem,NULL);
					}
					if(m_lstCategoryItem && m_lstCategoryItem->size() > 0)
						result = TResult::ESuccess;
					else
						result = TResult::ENothing;
				}
				else
					result = TResult::EProtocolFormatError;        //跑到这里来了
			}
			else
				result = TResult::EUnknownError;
        }
		else
			result = TResult::EProtocolFormatError;
    }
	else if(nCode == MERN_INITIALIZE)
	{
		result = TResult::ENetDisconnect;
	}
	else
		result = TResult::ENetDisconnect;

	if(m_pListener)
		m_pListener->OnUpdateDataFinish(m_UserData, result);
}
Example #18
0
void
FontXMLLoader::loadFont (Font *aFont, std::string &aFilename)
{
	File::FixSlashes(aFilename);
	std::string s = aFilename;
	int numChars,height;
	TiXmlDocument doc(s.c_str());
	bool loadOK = doc.LoadFile();

	if (!loadOK) {
		NAU_THROW("Parsing Error -%s- Line(%d) Column(%d) in file: %s", doc.ErrorDesc(), doc.ErrorRow(), doc.ErrorCol(),aFilename.c_str());
	}		
	
	TiXmlHandle hDoc(&doc);
	TiXmlHandle hRoot(0);
	TiXmlElement *pElem;

	pElem = hDoc.FirstChildElement().Element();
	if (0 == pElem)
		NAU_THROW("Not a XML file: %s", aFilename.c_str());

	hRoot = TiXmlHandle(pElem);
	
	pElem->QueryIntAttribute("numchars",&numChars);

	if (numChars == 0)
		NAU_THROW("Zero chars in file: %s", aFilename.c_str());

	hRoot = hRoot.FirstChild("characters");
	pElem = hRoot.FirstChild("chardata").Element();
	if (pElem) {
		pElem->QueryIntAttribute("hgt",&height);
		if (pElem)
			aFont->setFontHeight(height);
	}
	int code,width,A,C;
	float x1,x2,y1,y2;

	for(; 0 != pElem; pElem = pElem->NextSiblingElement()) {

		pElem->QueryIntAttribute("char",&code);
		pElem->QueryIntAttribute("wid",&(width));
		pElem->QueryFloatAttribute("X1", &(x1));
		pElem->QueryFloatAttribute("X2", &(x2));
		pElem->QueryFloatAttribute("Y1", &(y1));
		pElem->QueryFloatAttribute("Y2", &(y2));
		pElem->QueryIntAttribute("A", &(A));
		pElem->QueryIntAttribute("C", &(C));
		aFont->addChar(code,width,x1,x2,y1,y2,A,C);
	}
}
void joinNetworkGameDialogImpl::fillServerProfileList()
{


	treeWidget->clear();

	TiXmlDocument doc(QString::fromUtf8(myServerProfilesFile.c_str()).toStdString());
	if(!doc.LoadFile()) {
		MyMessageBox::warning(this, tr("Load Server-Profile-File Error"),
							  tr("Could not load server-profiles-file:\n"+QString::fromUtf8(myServerProfilesFile.c_str()).toAscii()),
							  QMessageBox::Close);
	}
	TiXmlHandle docHandle( &doc );

	TiXmlElement* profile = docHandle.FirstChild( "PokerTH" ).FirstChild( "ServerProfiles" ).FirstChild().ToElement();
	if ( profile ) {

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

			QTreeWidgetItem *item = new QTreeWidgetItem(treeWidget,0);
			item->setData(0, 0, QString::fromUtf8(profile->Attribute("Name")));
			item->setData(1, 0, QString::fromUtf8(profile->Attribute("Address")));
			item->setData(2, 0, profile->Attribute("Port"));

			string isIpv6 = "no";
			int tempInt = 0;
			profile->QueryIntAttribute("IsIpv6", &tempInt );
			if( tempInt == 1 ) {
				isIpv6 = "yes";
			}
			item->setData(3, 0, QString::fromUtf8(isIpv6.c_str()));

			string isSctp = "no";
			int tempInt1 = 0;
			profile->QueryIntAttribute("IsSctp", &tempInt1 );
			if( tempInt1 == 1 ) {
				isSctp = "yes";
			}
			item->setData(4, 0, QString::fromUtf8(isSctp.c_str()));

			treeWidget->addTopLevelItem(item);
		}
	} else {
		cout << "No Profiles Found \n";
	}

	treeWidget->resizeColumnToContents ( 0 );
	treeWidget->resizeColumnToContents ( 1 );
	treeWidget->resizeColumnToContents ( 2 );
	treeWidget->resizeColumnToContents ( 3 );
}
Example #20
0
	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;
	}
Configuration::Configuration()
{
	vendor = VENDOR_UNKNOWN;

	char buffer[1000];
	int n = GetModuleFileName(0, buffer, 1000);
	char *exename = buffer;
	for (int i = 0; i < n; i++)
	if (buffer[i] == '\\') exename = buffer + i + 1;

	TiXmlDocument doc("gShaderReplacer.xml");
	bool loadOkay = doc.LoadFile();
	if (loadOkay)
	{
		TiXmlElement *root = doc.RootElement();
		int i = 0;
		_dumpAllShaders = (root->QueryIntAttribute("DumpAllShaders", &i) == TIXML_SUCCESS) ? (i ? true : false) : 0;
		_dumpErrorShaders = (root->QueryIntAttribute("DumpErrorShaders", &i) == TIXML_SUCCESS) ? (i ? true : false) : 0;

		TiXmlElement *child = root->FirstChildElement();
		while (child)
		{
			if (child->ValueStr() == "Application")
			{
				bool match = false;
				const char* name = child->Attribute("Name");
				if (name && _strcmpi(exename, name) == 0) match = true;
				for (int j = 0; j < 10; j++)
				{
					const string *s = child->Attribute(string("Name") + char(j + 0x30));
					if (s && _strcmpi(exename, s->c_str()) == 0) match = true;
				}
				if (match)
				{
					TiXmlElement *child2 = child->FirstChildElement();
					while (child2)
					{
						ReadReplacers(child2);
						child2 = child2->NextSiblingElement();
					}
				}
			}
			ReadReplacers(child);
			child = child->NextSiblingElement();
		}
	}
	_buffer = new char[BUFFERSIZE];
	_bufferpos = 0;
}
Example #22
0
bool LoadStatsXML(TiXmlHandle hStats, int stats[], int statMods[], int tempStats[])
{
	TiXmlElement* pStats = hStats.ToElement();
	if (pStats == 0) return false;

	for (int i = 0; i < NUM_STATS; i++)
	{
		TiXmlElement* pStat = pStats->FirstChildElement(XMLifyString(sGirl::stat_names[i]));
		if (pStat)
		{
			int tempInt = 0;
			if (pStat->Attribute("Value"))	pStat->QueryIntAttribute("Value", &tempInt);

			int min = 0, max = 100;
			switch (i)
			{
			case STAT_AGE:
				if (tempInt > 99)		tempInt = 100;
				else if (tempInt > 80)		tempInt = 80;
				else if (tempInt < 18)		tempInt = 18;	// `J` Legal Note: 18 is the Legal Age of Majority for the USA where I live 
				break;
			case STAT_EXP:		max = 32000;	break;
			case STAT_LEVEL:	max = 255;		break;
			case STAT_PCFEAR:		case STAT_PCHATE:	case STAT_PCLOVE:	case STAT_MORALITY:
			case STAT_REFINEMENT:	case STAT_DIGNITY:	case STAT_LACTATION:
				min = -100;		break;
			default:	break;
			}
			if (tempInt < -1000)	tempInt = -1;	// test for null stats and set them to 0
			if (tempInt > max) tempInt = max;
			else if (tempInt < min) tempInt = min;
			stats[i] = tempInt;

			if (statMods)
			{
				tempInt = 0;
				if (pStat->Attribute("Mod"))	pStat->QueryIntAttribute("Mod", &tempInt);
				statMods[i] = tempInt;
			}
			if (tempStats)
			{
				tempInt = 0;
				if (pStat->Attribute("Temp"))	pStat->QueryIntAttribute("Temp", &tempInt);
				tempStats[i] = tempInt;
			}
		}
	}
	return true;
}
//网络返回数据 刷新内存
void CMGetNewContent::OnSessionCmd(unsigned int nCmdID, unsigned int nCode, TiXmlDocument *pDoc)
{
    if (nCode == MER_OK)
    {
        TiXmlElement* pItem = pDoc->RootElement();
        
        if (pItem)
        {
            INT32 nCmdID = 0;
            
            pItem->QueryIntAttribute("no", &nCmdID);
            
            INT32 nErr = 0;
            
            if (pItem->QueryIntAttribute("errno", &nErr) == TIXML_SUCCESS)
            {
                if (nErr == 0)
                {
                    if (nCmdID == SERVICE_GETNEWCONTENT || nCmdID == SERVICE_GETRECOMMEND)
                    {
						if(!pItem->NoChildren())
                        {
                            TiXmlElement* pHeadItemList = pItem->FirstChildElement("largeimage");
                            if(pHeadItemList)
                                DoHeadItemList(pHeadItemList);
                            DoItemList(pItem);
                        }

                        if (m_lstItem && m_lstItem->size() > 0)
                        {
                        	if(m_pListener)
                        		m_pListener->OnUpdateDataFinish(m_pUserData, TResult::ESuccess);
                            return ;
                        }
                        else
                        {
                        	if(m_pListener)
                        		m_pListener->OnUpdateDataFinish(m_pUserData, TResult::ENothing);
                            return ;
                        }
                    }
                }
            }
        }
    }
    if(m_pListener)
    	m_pListener->OnUpdateDataFinish(m_pUserData, TResult::EUnknownError);
}
Example #24
0
void ConfigManager::SetControlType(int controller, const char* type)
{
	TiXmlHandle docHandle( config_file );
    TiXmlElement* player = docHandle.FirstChild( "Balder" ).FirstChild( "Player" ).Element();
    TiXmlElement* lastPlayer = 0;
    while(player)
    {
    	lastPlayer = player;
    	int c;
    	int result = player->QueryIntAttribute("controller",&c);
    	if (TIXML_SUCCESS == result){
    		if (controller == c){
    			TiXmlHandle h(player);
    			TiXmlElement *controlEl = h.FirstChild("Control").Element();
    			if (!controlEl){
    				// first make sure the Control section exists
					controlEl = new TiXmlElement("Control");
					controlEl->SetAttribute("type", type);
    			}
    			else {controlEl->SetAttribute("type", type);}
    			return;
    		}
    	}
	    player=player->NextSiblingElement("Player");
    }
    // it appears that we did not find the player, must add it . .
    if (!lastPlayer) {
    	lastPlayer = docHandle.FirstChild("Balder").Element();
    }
    player = new TiXmlElement("Player");
    player->SetAttribute("controller", controller);
    player->InsertEndChild(*(new TiXmlElement("Control")));
    player->FirstChildElement("Control")->SetAttribute("type", type);
    docHandle.FirstChild("Balder").Element()->InsertAfterChild(lastPlayer, *player);
}
int XmlPropertyBagLoader::getVersion()
{
  TiXmlElement* element = doc.FirstChildElement("Factories");
  int version = -1;
  element->QueryIntAttribute("Version", &version);
  return version;
}
Example #26
0
BOOL GetPowerOpt(int *pnAllowSuspendMode)
{
	TiXmlDocument doc;

	int nAllowSuspendMode = 0;
	int nResult = TIXML_NO_ATTRIBUTE;


	if( CheckValidXML(&doc) == FALSE )
	{
		return FALSE;
	}

	TiXmlElement* pElem = doc.FirstChild("BBS_WiFiConfig")->FirstChild("Setting")->FirstChild("Option")->FirstChildElement("PowerOption");

	nResult = pElem->QueryIntAttribute("AllowSuspend",  pnAllowSuspendMode);
	// 초기값이 설정되지 않았을때는, 연결된 상태에서 SuspendMode 허용 기본 설정
	if( nResult == TIXML_WRONG_TYPE )
	{
		*pnAllowSuspendMode = -1;
	}
	else if ( nResult == TIXML_NO_ATTRIBUTE )
	{
		RETAILMSG(1, (TEXT("[PSH] ERROR \r\n") ));
	}

	return TRUE;
}
Example #27
0
	void Timeline::Init(TiXmlNode *node, CCSpriterX *animator)
	{
		int intValue;

		TiXmlElement *element = node->ToElement();

		if (element)
		{
			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				mId = intValue;

			for (TiXmlNode* keyNode = node->FirstChild(); keyNode; keyNode = keyNode->NextSibling())
			{
				element = keyNode->ToElement();
				if (element)
				{
					Key *keyframe = new Key();

					keyframe->Init(keyNode, animator);

					mKeyframes.push_back(keyframe);
				}
			}

		}

	}
Example #28
0
	void File::Init(TiXmlNode *node)
	{
		TiXmlElement *element = node->ToElement();
		if (element)
		{
			int intValue;
			float floatValue;

			if (element->QueryIntAttribute("id", &intValue) == TIXML_SUCCESS)
				id = intValue;
			else
				id = 0;

			name = element->Attribute("name");

			if (element->QueryFloatAttribute("width", &floatValue) == TIXML_SUCCESS)
				width = floatValue;
			else
				width = 0;

			if (element->QueryFloatAttribute("height", &floatValue) == TIXML_SUCCESS)
				height = floatValue;
			else
				height = 0;

			if (name.size()>0)
			{
                sprite = CCSprite::createWithSpriteFrameName(name.c_str());
//				sprite = CCSprite::create(name.c_str());
				sprite->retain();
			}

		}

	}
Example #29
0
wxString ConfigManager::ReadBinary(const wxString& name)
{
    wxString str;
    wxString key(name);
    TiXmlElement* e = AssertPath(key);
    unsigned int crc = 0;

    TiXmlHandle parentHandle(e);
    TiXmlElement* bin = parentHandle.FirstChild(cbU2C(key)).FirstChild("bin").Element();

    if (!bin)
        return wxEmptyString;

    if (bin->QueryIntAttribute("crc", (int*)&crc) != TIXML_SUCCESS)
        return wxEmptyString;

    if (const TiXmlText* t = bin->FirstChild()->ToText())
    {
        str.assign(cbC2U(t->Value()));
        str = wxBase64::Decode(str);
        if (crc ==  wxCrc32::FromString(str))
            return str;
    }
    return wxEmptyString;
}
//---------------------------------------------------------
bool ofxXmlSettings::readIntAttribute(const string& tag, const string& attribute, int& outValue, int which){

    TiXmlElement* elem = getElementForAttribute(tag, which);
    if (elem)
        return (elem->QueryIntAttribute(attribute, &outValue) == TIXML_SUCCESS);
    return false;
}