예제 #1
0
bool CInstrOffsetData::Load(LPCTSTR filePath, bool isCreate) {
	m_data.clear();
	CMarkup xml;
	if (!xml.Load(filePath)) {
		return false;
	}
	if (!xml.FindElem("root")) {
		return false;
	}
	xml.IntoElem();
	if (!xml.FindElem("data")) {
		return false;
	}
	xml.IntoElem();
	while (xml.FindElem("frequency")) {
		double frequency = atof(xml.GetAttrib("value"));
		xml.IntoElem();
		while (xml.FindElem("power")) {
			double dest_power = atof(xml.GetAttrib("dest_power"));
			double offset     = atof(xml.GetAttrib("offset"));
			m_data[frequency][dest_power] = offset;
		}
		xml.OutOfElem();
	}
	return true;
}
예제 #2
0
Vehicle::Vehicle(const char * inputXml)
{
   CMarkup xml;
   xml.SetDoc (inputXml);
   xml.FindElem ();
   xml.IntoElem ();

   while (xml.FindElem ()) {
      std::string tag = xml.GetTagName ();
      if (tag == "vtypeidname") {
         vtypeidname_ = xml.GetData();
      }
      else if (tag == "vtypeid") {
         vtypeid_ = atoi (xml.GetData().c_str());
      }
      else if (tag == "color") {
         color_ = xml.GetData();
      }
      else if (tag == "heat") {
         heat_ = atoi (xml.GetData().c_str());
      }
      else if (tag == "location") {
         location_ = atoi (xml.GetData().c_str());
      }
      else if (tag == "myear") {
         myear_ = atoi (xml.GetData().c_str());
      }
      else if (tag == "id") {
         id_ = atoi (xml.GetData().c_str());
      }
   }
}
예제 #3
0
파일: Xml.cpp 프로젝트: Bam4d/Neuretix
int SaveLoadCNN::GetAxonVec(CMarkup AxonXml,AxonList * axon, std::vector<Group*>* destCluster, std::vector<Group*>* srcCluster)
{
//	axon_iter = 0;

        axon->Clear();
	AxonXml.FindElem("AxonData");
	AxonXml.IntoElem();
	while ( AxonXml.FindElem("Axon") )
	{
		//get a pointer to the source Neuron
		Neuron* source = Neuron::FindNeuronByID(atoi(AxonXml.GetAttrib("NsID").c_str()),&Group::FindGroupByID(atoi(AxonXml.GetAttrib("GsID").c_str()),srcCluster)->neurons);
		//get a pointer to the destination Neuron
		Neuron* destination = Neuron::FindNeuronByID(atoi(AxonXml.GetAttrib("NdID").c_str()),&Group::FindGroupByID(atoi(AxonXml.GetAttrib("GdID").c_str()),destCluster)->neurons);

                if(source == NULL)
                    printf("Could not load axon: source Neuron not found. NsID=%s, GsID=%s\n", AxonXml.GetAttrib("NsID").c_str(),AxonXml.GetAttrib("GsID").c_str());
                if(destination==NULL)
                    printf("Could not load axon: destination Neuron not found NdID=%s, GdID=%s\n", AxonXml.GetAttrib("NdID").c_str(),AxonXml.GetAttrib("GdID").c_str());
		//generate axons in specified cluster
                if(source!=NULL&&destination!=NULL)
		axon->Add(new Axon(source,destination,atof(AxonXml.GetAttrib("Mag").c_str()),atoi(AxonXml.GetAttrib("SynDelay").c_str())));
	}

        return axon->Count();

}
예제 #4
0
static int _ParseSegXml(const char *src, 
						const LocationInfo *location, 
						int len, 
						int *extraLoaction,
						int extraLen,
						char *dst)
{
	CMarkup xml;
	xml.SetDoc(src);						
	if (!xml.FindElem("SEGMENTS")){		
		return -1;								
	}										
	xml.IntoElem();						
	if (! xml.FindElem("SEGMENT")){		
		return -1;								
	}										
	xml.IntoElem();
	_doIntersect(location, len, extraLoaction, extraLen);
	while (xml.FindElem("COLUMN"))
	{
		int id = atoi(xml.GetAttrib("ID").c_str());
		if (_isExtra(id, extraLoaction, extraLen)) {
			continue;
		}

		if (!isExist(id, location, len)) {
			xml.RemoveElem();
		}
	}
	xml.OutOfElem();						
	xml.OutOfElem();
	strcpy(dst, xml.GetDoc().c_str());
	return 0;
}
예제 #5
0
BOOL CViewGameDlg::OnInitDialog()
{
	CDialog::OnInitDialog();
	m_lstCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
	if (m_bViewCmpAllGame)
	{
		m_lstCtrl.InsertColumn(0, "GID",		LVCFMT_LEFT, 80);
		m_lstCtrl.InsertColumn(1, "游戏名",		LVCFMT_LEFT, 140);
		m_lstCtrl.InsertColumn(2, "更新时间",   LVCFMT_LEFT, 150);
	}
	else
	{
		m_lstCtrl.InsertColumn(0, "计算机",		LVCFMT_LEFT, 150);
		m_lstCtrl.InsertColumn(1, "更新时间",   LVCFMT_LEFT, 180);
	}

	std::string ErrInfo;
	CConsoleDlg* pDlg = reinterpret_cast<CConsoleDlg*>(AfxGetMainWnd());	
	if (!pDlg->m_pDbMgr->ViewGameInfo(gid, m_bViewCmpAllGame, ErrInfo))
	{
		AfxMessageBox(ErrInfo.c_str());
		OnCancel();
		return TRUE;
	}
	CMarkup xml;
	xml.SetDoc(ErrInfo);
	if (m_bViewCmpAllGame)
	{
		if (i8desk::IntoXmlNode(xml, "/status/gameLst/"))
		{
			while (xml.FindElem("Task"))
			{
				std::string gid = xml.GetAttrib("gid");
				int nIdx = m_lstCtrl.InsertItem(m_lstCtrl.GetItemCount(), gid.c_str());
				DWORD ver = atoi(xml.GetAttrib("version").c_str());
				m_lstCtrl.SetItemText(nIdx, 1, pDlg->GetNameFromGID(atoi(gid.c_str())).c_str());
				m_lstCtrl.SetItemText(nIdx, 2, i8desk::MakeTimeString(ver).c_str());
			}
		}
	}
	else
	{
		if (i8desk::IntoXmlNode(xml, "/status/ipLst/"))
		{
			while (xml.FindElem("Task"))
			{
				DWORD ip = atoi(xml.GetAttrib("ip").c_str());
				int nIdx = m_lstCtrl.InsertItem(m_lstCtrl.GetItemCount(), i8desk::MakeIpString(ip).c_str());
				DWORD ver = atoi(xml.GetAttrib("version").c_str());
				m_lstCtrl.SetItemText(nIdx, 1, i8desk::MakeTimeString(ver).c_str());
			}
		}
	}

	this->CenterWindow();

	return TRUE;
}
예제 #6
0
파일: Xml.cpp 프로젝트: Bam4d/Neuretix
int SaveLoadCNN::GetClusterVec(CMarkup ClusterXml, std::vector<Group*>* Cluster)
{

    PlotPoint gP,nP;
    RGB col;
    std::vector<Neuron*> n_temp;
    int clusterID = 0;

    Cluster->clear(); //clear the vector

    ClusterXml.FindElem("ClusterData");
    ClusterXml.IntoElem();
    while ( ClusterXml.FindElem("Group") )
    {
        clusterID = atoi(ClusterXml.GetAttrib("GID").c_str());
        n_temp.clear();

        //get the colours of the Neurons in this group
        col.r = atof(ClusterXml.GetAttrib("r").c_str());
        col.g = atof(ClusterXml.GetAttrib("g").c_str());
        col.b = atof(ClusterXml.GetAttrib("b").c_str());



        ClusterXml.IntoElem();
        while ( ClusterXml.FindElem("Neuron"))
        {

            nP.x = atof(ClusterXml.GetAttrib("x").c_str());
            nP.y = atof(ClusterXml.GetAttrib("y").c_str());
            nP.z = atof(ClusterXml.GetAttrib("z").c_str());

            n_temp.push_back(new Neuron(clusterID,
                                    nP,
                                    atof(ClusterXml.GetAttrib("Threshold").c_str()),
                                    atof(ClusterXml.GetAttrib("Epsilon").c_str()),
                                    atoi(ClusterXml.GetAttrib("Refractory").c_str()),
                                    col
                                    ));
        }
        ClusterXml.OutOfElem();

        gP.x = atof(ClusterXml.GetAttrib("x").c_str());
        gP.y = atof(ClusterXml.GetAttrib("y").c_str());
        gP.z = atof(ClusterXml.GetAttrib("z").c_str());

        Group* _newGroup = new Group();
        _newGroup->Init(n_temp,clusterID,gP,col);
        Cluster->push_back(_newGroup);
    }

    return Cluster->size();
}
예제 #7
0
Shop::ShopItem::ShopItem(MCD_STR xmlstring, bool only_sell_legal,
                         bool increase_price_with_illegality)
 : price_(0), only_sell_legal_(only_sell_legal),
   increase_price_with_illegality_(increase_price_with_illegality),
   description_defined_(false)
{
   CMarkup xml;
   xml.SetDoc(xmlstring);
   xml.FindElem();
   xml.IntoElem();

   while (xml.FindElem())
   {
      std::string tag = xml.GetTagName();

      if (tag == "class")
      {
         if (xml.GetData() == "WEAPON")
            itemclass_ = WEAPON;
         else if (xml.GetData() == "CLIP")
            itemclass_ = CLIP;
         else if (xml.GetData() == "ARMOR")
            itemclass_ = ARMOR;
         else if (xml.GetData() == "LOOT")
            itemclass_ = LOOT;
      }
      else if (tag == "type")
         itemtypename_ = xml.GetData();
      else if (tag == "description")
      {
         description_ = xml.GetData();
         description_defined_ = true;
      }
      else if (tag == "price")
         price_ = atoi(xml.GetData().c_str());
      else if (tag == "sleeperprice")
	     sleeperprice_ = atoi(xml.GetData().c_str());
	  else if (tag == "letter")
      {
         letter_ = xml.GetData()[0];
         if (97 <= letter_ && letter_ <= 122) //Check it is a letter.
            letter_defined_ = true;
         else if (65 <= letter_ && letter_ <= 90)
         {
            letter_ += 32;
            letter_defined_ = true;
         }
         else if (letter_ == '!') //Allow special character.
            letter_defined_ = true;
      }
   }
}
예제 #8
0
CMarkup XMLSerialized::OpenFile(){
	CMarkup xml;
//nếu file chưa tồn  tại thì kiểm tra trong listRole
	bool exist =PathFileExists(sFileName);
	if(!exist){
		int begin = sFileName.ReverseFind('\\')+1;
		int end = sFileName.ReverseFind(L'.');
		CString roleName = sFileName.Mid(begin,end-begin);
		if(roleName.Left(4)=="Role")
			return NULL;
		CString szLstRole = L"Character\\ListRole.xml";
		ConvertFileName(szLstRole);
		//nếu không tồn tại file listRole thì tạo note root
		if(!PathFileExists(szLstRole)){
			xml.AddElem(L"ListRoles");			
		}
		else{
			xml.Load(szLstRole);
			xml.FindElem(L"ListRoles");
		}
		
		xml.IntoElem();
		while(xml.FindElem(L"Role")){
			if(xml.GetAttrib(L"ID")==roleName){
				sFileName=L"Character\\"+xml.GetAttrib(L"File");
				ConvertFileName(sFileName);
				exist =true;
				break;
			}
			
		}
		//nếu trong listRole không có thì lưu trong listRole và tạo file
		if(!exist){
			time_t timer;
			time(&timer);
			CTime t = timer;
			sFileName=t.Format(L"Role%d%m%Y%H%M%S.xml");
			xml.AddElem(L"Role");
			xml.AddAttrib(L"ID",roleName);
			xml.AddAttrib(L"File",sFileName);
			xml.Save(szLstRole);
			sFileName=L"Character\\"+sFileName;
			ConvertFileName(sFileName);
			return NULL;
		}
		
	}		
	xml.Load(sFileName);
	if(xml.GetDoc().GetLength()>0)
		return xml;
	return NULL;
}
예제 #9
0
Item::Item(const std::string& inputXml)
{
   CMarkup xml;
   xml.SetDoc(inputXml);
   xml.FindElem();
   xml.IntoElem();
   while(xml.FindElem())
   {
      std::string tag=xml.GetTagName();
      if(tag=="itemtypename") itemtypename_=xml.GetData();
      else if(tag=="itemtypeid") itemtypeid_=atoi(xml.GetData());
      else if(tag=="number") number_=atoi(xml.GetData());
   }
}
예제 #10
0
LootType::LootType(MCD_STR xmlstring)
 : ItemType(xmlstring), stackable_(true),
   no_quick_fencing_(false), cloth_(false)
{
   CMarkup xml;
   xml.SetDoc(xmlstring);
   xml.FindElem();
   xml.IntoElem();

   while (xml.FindElem()) //Loop over all the elements inside the loottype element.
   {
      std::string element = xml.GetTagName();

      if (element == "stackable")
      {
         int b = stringtobool(xml.GetData());
         if (b == 1)
            stackable_ = true;
         else if (b == 0)
            stackable_ = false;
         /*else
            errorlog << "Invalid boolean value for loot type " << idname
                      << "::stackable: " << xml.GetData() << std::endl;*/
      }
      else if (element == "no_quick_fencing")
      {
         int b = stringtobool(xml.GetData());
         if (b == 1)
            no_quick_fencing_ = true;
         else if (b == 0)
            no_quick_fencing_ = false;
         /*else
            errorlog << "Invalid boolean value for loot type " << idname
                      << "::no_quick_fencing: " << xml.GetData() << std::endl;*/
      }
      else if (element == "cloth")
      {
         int b = stringtobool(xml.GetData());
         if (b == 1)
            cloth_ = true;
         else if (b == 0)
            cloth_ = false;
         /*else
            errorlog << "Invalid boolean value for loot type " << idname
                      << "::cloth: " << xml.GetData() << std::endl;*/
      }
   }
}
예제 #11
0
BOOL FindMarkItem(CMarkup& markDoc, ST_MARKITEM& kvOut)
{
	while(markDoc.FindElem())
	{
		//tree node, set val to empty
		kvOut.strVal.Empty();
		kvOut.bIsPath = TRUE;
		ST_MARKITEM tmpItem;
		CString strAttKey;
		CString strAttVal;
		int nAttIdx = 0;
		while(markDoc.GetNthAttrib(nAttIdx, strAttKey, strAttVal))
		{
			tmpItem.mapAttrib[strAttKey] = strAttVal;
			++nAttIdx;
		}

		tmpItem.strKey = markDoc.GetTagName();
		tmpItem.strVal = markDoc.GetElemContent();
		markDoc.IntoElem();
		FindMarkItem(markDoc, tmpItem);
		markDoc.OutOfElem();

		kvOut.mapChildItem[tmpItem.strKey] = tmpItem;
	}

	return TRUE;
}
예제 #12
0
ClipType::ClipType(MCD_STR xmlstring) : ItemType(xmlstring), ammo_(1)
{
   CMarkup xml;
   xml.SetDoc(xmlstring);
   xml.FindElem();
   xml.IntoElem();

   while(xml.FindElem()) //Loop over all the elements inside the cliptype element.
   {
      std::string element=xml.GetTagName();
      if(element=="ammo")
         ammo_=atoi(xml.GetData());
      /*else
         errorlog << "Unknown element for clip type " << idname() << ": " << element << endl;*/
   }
}
예제 #13
0
static int _ParseXml(const char *src, std::map<std::string, std::string> &mapValue)
{
	CMarkup xml;
	xml.SetDoc(src);						
	if (!xml.FindElem("SEGMENTS")){		
		return -1;								
	}
	xml.IntoElem();
	while (xml.FindElem("SEGMENT")){
		std::string szSource = xml.GetAttrib("SOURCE");
		mapValue[szSource] = xml.GetAttrib("VALUE");
	}
	xml.OutOfElem();
	return 0;
	
}
예제 #14
0
Money::Money(const char * inputXml)
 : Item(inputXml)
{
   CMarkup xml;
   xml.SetDoc (inputXml);
   xml.FindElem ();
   xml.IntoElem ();
   
   while (xml.FindElem ())
   {
      std::string tag = xml.GetTagName ();
   
      if (tag == "amount")
         amount_ = atoi(xml.GetData().c_str());
   }
}
예제 #15
0
Weapon::Weapon(const char * inputXml)
 : Item(inputXml)
{
   CMarkup xml;
   xml.SetDoc (inputXml);
   xml.FindElem ();
   xml.IntoElem ();
   
   while (xml.FindElem ())
   {
      std::string tag = xml.GetTagName ();
      
      if (tag == "loaded_cliptype")
         loaded_cliptype_ = xml.GetData();
      else if (tag == "ammo")
         ammo_ = atoi(xml.GetData().c_str());
   }
}
bool VectorOfFloatComplexType::ParseXMLInstance(const std::string& instance)
{ 
	CMarkup parser;
	parser.SetDoc(instance);
	parser.ResetPos();
	parser.FindElem();
	if(parser.GetTagName()!=name)
		return false;
	parser.IntoElem();	
	while(parser.FindElem())
	{
		std::string str=parser.GetTagName();
		std::string val=parser.GetSubDoc();
		Float* value_item=new Float(str);
		value_item->ParseXMLInstance(val);
		elements[0].AddValue(value_item);
	}
	return true;
}
예제 #17
0
파일: Xml.cpp 프로젝트: Bam4d/Neuretix
int SaveLoadCNN::GetAxonVec(CMarkup AxonXml,AxonList * axonList, std::vector<Group*>* Cluster)
{
//	axon_iter = 0;
	bool _sourceFound, _destFound;
	axonList->Clear();
	AxonXml.FindElem("AxonData");
	AxonXml.IntoElem();
	while ( AxonXml.FindElem("Axon") )
	{
		//get a pointer to the source Neuron
		Neuron* source = Neuron::FindNeuronByID(atoi(AxonXml.GetAttrib("NsID").c_str()),&Group::FindGroupByID(atoi(AxonXml.GetAttrib("GsID").c_str()),Cluster)->neurons);
		//get a pointer to the destination Neuron
		Neuron* destination = Neuron::FindNeuronByID(atoi(AxonXml.GetAttrib("NdID").c_str()),&Group::FindGroupByID(atoi(AxonXml.GetAttrib("GdID").c_str()),Cluster)->neurons);
		
		if(source == NULL)
		{
			printf("Could not load axon: source Neuron not found. NsID=%s, GsID=%s\n", AxonXml.GetAttrib("NsID").c_str(),AxonXml.GetAttrib("GsID").c_str());
			_sourceFound = false;
		}
		else
			_sourceFound = true;

		if(destination==NULL)
		{
			printf("Could not load axon: destination Neuron not found NdID=%s, GdID=%s\n", AxonXml.GetAttrib("NdID").c_str(),AxonXml.GetAttrib("GdID").c_str());
			_destFound = false;
		}
		else
			_destFound = true;

		if(_destFound &&_sourceFound)
		{
			//generate axons in specified cluster
			axonList->Add(new Axon(source,destination,atof(AxonXml.GetAttrib("Mag").c_str()),atoi(AxonXml.GetAttrib("SynDelay").c_str())));
			axonList->ID = atol(AxonXml.GetAttrib("AID").c_str());
		}
	}
        
        return axonList->Count();

}
예제 #18
0
	//This method allow you to load the XML file
	std::vector<Stage*>* Stage::LoadFromXML(std::string path)
	{
		//creating object
		std::vector<Stage*>* stages = nullptr;		//creating a vector of stage object
		CMarkup xml;

		//if cant load file return
		if (!xml.Load(path))
			return stages;
		//it cant find element return stages
		if (!xml.FindElem("Stages"))
			return stages;

		stages = new std::vector<Stage*>();		//creating a vector of stages object
		xml.IntoElem();							//go up 1 level
		while (xml.FindElem("Stage"))			//find stage
		{
			Stage* stage = new Stage();			
			stages->push_back(stage);			//push each stage into vector of stage
			xml.IntoElem();						//go up 1 level
			if (xml.FindElem("Flag"))			//find the flag
			{
				int x, y;								
				xml.IntoElem();								//go up 1 level
				xml.FindElem("x");							//find x
				x = atoi(xml.GetData().c_str());			//assign x cord from xml into int
				xml.FindElem("y");							//find y
				y = atoi(xml.GetData().c_str());			//assign y cord from xml into int
				stage->flagPosition = new Vector2(x, y);	//push x and y into vector for flag position
				xml.OutOfElem();							//go back 1 level
			}
			while (xml.FindElem("Block"))		//find block and do the same as flag
			{
				Block* block;
				int x;
				int y;
				xml.IntoElem();
				xml.FindElem("x");
				x = atoi(xml.GetData().c_str());
				xml.FindElem("y");
				y = atoi(xml.GetData().c_str());
				block = new Block(x, y);
				stage->Blocks->push_back(block);
				xml.OutOfElem();
			}
			xml.OutOfElem();
		}
		return stages;
	}
예제 #19
0
bool populate_from_xml(vector<Type*>& types,string file,Log& log)
{
   CMarkup xml;
   if(!xml.Load(string(artdir)+file))
   { // File is missing or not valid XML.
      addstr("Failed to load "+file+"!",log);

      getkey();

      // Will cause abort here or else if file is missing all unrecognized types
      // loaded from a saved game will be deleted. Also, you probably don't want
      // to play with a whole category of things missing anyway. If the file
      // does not have valid xml, then behaviour is kind of undefined so it's
      // best to abort then too.
      return false;
   }

   xml.FindElem();
   xml.IntoElem();
   while(xml.FindElem()) types.push_back(new Type(xml.GetSubDoc()));
   return true;
}
예제 #20
0
bool
ESDBXMLResponse::ParseXMLString(CString sXML, ESDBXMLRequestMan* pReqMan){
	CMarkup xmlDoc;
	if( !xmlDoc.SetDoc(sXML) )
		return false;

	if( !xmlDoc.FindElem() )
		return false;

	StringToIntArray*	pReqTypes	= ESDBXMLRequest::GetRequestTypes();
 	RequestType			reqType		= (RequestType)pReqTypes->GetValue(xmlDoc.GetTagName());
	if( reqType == RequestType::db_unknown )
		return false;

	if( !xmlDoc.IntoElem() )
		return false;

	// Fill params array. ######
	if( m_pParams )
		delete m_pParams;	
	m_pParams = new StringToStringArray();

	while( xmlDoc.FindElem() ){
		m_pParams->Add(xmlDoc.GetTagName(), xmlDoc.GetData());
		}
	// #########################

	int	nReqId	= atoi(m_pParams->GetValue("req_id"));
	ESDBXMLRequest* req	= pReqMan->GetRequestById(nReqId);
	if( req == NULL || req->GetResponse() != NULL )
		return false;

	// Attach to request object.
	m_pRequest = req;
	req->SetType	(reqType);
	req->SetResponse(this);
	return true;
	}
예제 #21
0
bool populate_masks_from_xml(vector<ArmorType*>& masks,string file,Log& log)
{
   CMarkup xml;
   if(!xml.Load(string(artdir)+file))
   { //File is missing or not valid XML.
      addstr("Failed to load "+file+"!",log);

      getkey();

      return false; //Abort.
   }

   xml.FindElem();
   xml.IntoElem();
   int defaultindex;
   if(xml.FindElem("default")) defaultindex=getarmortype(xml.GetData());
   else
   {
      addstr("Default missing for masks!",log);

      getkey();

      return false; //Abort.
   }
   if(defaultindex==-1)
   {
      addstr("Default for masks is not a known armor type!",log);

      getkey();

      return false; //Abort.
   }

   xml.ResetMainPos();
   while(xml.FindElem("masktype")) armortype.push_back(new ArmorType(*armortype[defaultindex],xml.GetSubDoc()));
   return true;
}
예제 #22
0
void XMLSerialized::SaveInfo(const CString& sName,const int& iValue,TagType tagType,const CString& parent){
	CMarkup xml = OpenFile();
	if(FindPath(parent,&xml)){
		if(tagType== TagType::Element)
		{
			if(!xml.FindElem(sName))
				xml.AddElem( sName);
			xml.SetData(iValue);
			return;
		}
		if(tagType== TagType::Attribute)
		{
			xml.SetAttrib(sName,iValue);
			return;
		}
	}
	xml.Save(sFileName);
}
예제 #23
0
/* Used by load() to create items of the correct class. */
Item* create_item(const std::string& inputXml)
{
   Item* it = NULL;
   CMarkup xml;
   xml.SetDoc(inputXml);
   xml.FindElem();
   string itemclass = xml.GetTagName();
   if (itemclass == "clip")
      it = new Clip(inputXml);
   else if (itemclass == "weapon")
      it = new Weapon(inputXml);
   else if (itemclass == "armor")
      it = new Armor(inputXml);
   else if (itemclass == "loot")
      it = new Loot(inputXml);
   else if (itemclass == "money")
      it = new Money(inputXml);

   return it;
}
예제 #24
0
/**
调用此函数前需保证xml中已经通过FindElem()定位到当前元素。
*/
void CXmlElement::Load(CMarkup& xml)
{
	_name = xml.GetTagName();
	CString attrib_name, attrib_value;
	int i = 0;
	while(xml.GetNthAttrib(i, attrib_name, attrib_value))
	{
		_attributes.push_back(std::make_pair(attrib_name, attrib_value));
		++i;
	}
	_value = xml.GetData();
	if (_value.IsEmpty())
	{
		xml.IntoElem();
		while (xml.FindElem())
		{
			CXmlElement* element = new CXmlElement;
			element->Load(xml);
			_children.push_back(element);
		}
		xml.OutOfElem();
	}
}
예제 #25
0
// 保存配置信息
BOOL COBDPNDConfigReadWrite::fSaveAppConfig(void)
{
	CMarkup xml;

	CString strAppConfigFile = fCommGetAppPath() + _T("\\Config.xml");
	if (!xml.Load(strAppConfigFile))
	{		
		return CONFIG_ERR_LOAD_FILE; 
	}
	CString strText;

	xml.ResetMainPos();
	xml.FindElem();	
	if(xml.FindChildElem(_T("System")))
	{		
		xml.IntoElem();	
		if(xml.FindChildElem(_T("COM_OBD")))
		{
			strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.wPort);
			xml.SetChildAttrib(_T("Port"),strText);
			//strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.dwBPS);
			//xml.SetChildAttrib(_T("BPS"),strText);
			//strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.wData_Bits);
			//xml.SetChildAttrib(_T("Data_Bits"),strText);
			//strText.Format(_T("%d"),m_tagAppConfig.tagComOBD.wStop_Bits);
			//xml.SetChildAttrib(_T("Stop_Bits"),strText);
			//xml.SetChildAttrib(_T("Parity"),_T("None"));
		}

		//if(xml.FindChildElem(_T("COM_GPS")))
		//{
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.wPort);
		//	xml.SetChildAttrib(_T("Port"),strText);
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.dwBPS);
		//	xml.SetChildAttrib(_T("BPS"),strText);
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.wData_Bits);
		//	xml.SetChildAttrib(_T("Data_Bits"),strText);
		//	strText.Format(_T("%d"),m_tagAppConfig.tagComGPS.wStop_Bits);
		//	xml.SetChildAttrib(_T("Stop_Bits"),strText);
		//	xml.SetChildAttrib(_T("Parity"),_T("None"));
		//}

		if(xml.FindChildElem(_T("Setting")))
		{

			xml.SetChildAttrib(_T("LANGUAGE"),m_tagAppConfig.tagSetting.strLanguage);

			if (m_tagAppConfig.tagSetting.bSaveErrorLog)
				xml.SetChildAttrib(_T("Save_ErrorLog"),_T("ON"));
			else
				xml.SetChildAttrib(_T("Save_ErrorLog"),_T("OFF"));

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBacklightDay);
			xml.SetChildAttrib(_T("BACKLIGHT_DAY"),strText);
			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBacklightNight);
			xml.SetChildAttrib(_T("BACKLIGHT_NIGHT"),strText);
			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBacklightDayStart);
			xml.SetChildAttrib(_T("BACKLIGHT_DAY_START"),strText);
			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.wBackLightDayEnd);
			xml.SetChildAttrib(_T("BACKLIGHT_DAY_END"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwSystemOffTime);
			xml.SetChildAttrib(_T("System_Off_Time"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwSystemOffMode);
			xml.SetChildAttrib(_T("System_Off_Mode"),strText);


			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwAutoSelPanelTime);
			xml.SetChildAttrib(_T("Auto_Sel_Panel_Time"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagSetting.dwDefaultStartPanel);
			xml.SetChildAttrib(_T("Default_Start_Panel"),strText);

			strText.Format(_T("%0.5f"),m_tagAppConfig.tagSetting.fInstantFuelParameter);
			xml.SetChildAttrib(_T("Parameter_Fuel_Instant"),strText);

			strText.Format(_T("%0.5f"),m_tagAppConfig.tagSetting.fAvgFuelParameter);
			xml.SetChildAttrib(_T("Parameter_Fuel_Avg"),strText);

			strText.Format(_T("%0.5f"),m_tagAppConfig.tagSetting.fFuelPrice);
			xml.SetChildAttrib(_T("Fuel_Price"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagSetting.dwActiveEcuID);
			xml.SetChildAttrib(_T("Active_ECU_ID"),strText);
		}	
		if(xml.FindChildElem(_T("Set_Alarm")))
		{
			if (m_tagAppConfig.tagAlarmSet.bTroubleCode)
				xml.SetChildAttrib(_T("TroubleCode"),_T("ON"));
			else
				xml.SetChildAttrib(_T("TroubleCode"),_T("OFF"));

			strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wSpeed);
			xml.SetChildAttrib(_T("Speed"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wCoolant);
			xml.SetChildAttrib(_T("Coolant"),strText);

			strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wFatigue_Driving);
			xml.SetChildAttrib(_T("Fatigue_Driving"),strText);

			strText.Format(_T("%0.2f"),m_tagAppConfig.tagAlarmSet.dbFuel);
			xml.SetChildAttrib(_T("Fuel"),strText);

			xml.IntoElem();
			if(xml.FindChildElem(_T("Shift")))
			{
				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wShiftRpm);
				xml.SetChildAttrib(_T("Shift_Rpm"),strText);

				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wShiftSpeed);
				xml.SetChildAttrib(_T("Shift_Speed"),strText);
			}
			if(xml.FindChildElem(_T("Volt")))
			{
				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wVoltMin);
				xml.SetChildAttrib(_T("Volt_Min"),strText);

				strText.Format(_T("%d"),m_tagAppConfig.tagAlarmSet.wVoltMax);
				xml.SetChildAttrib(_T("Volt_Max"),strText);
			}
			xml.OutOfElem();
		}
		xml.OutOfElem();
	}

	if(xml.FindChildElem(_T("Mini_Dlg")))
	{
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw480X272_X);
		xml.SetChildAttrib(_T("X_480X272"),strText);
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw480X272_Y);
		xml.SetChildAttrib(_T("Y_480X272"),strText);
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw800X480_X);
		xml.SetChildAttrib(_T("X_800X480"),strText);
		strText.Format(_T("%d"),m_tagAppConfig.tagMiniSpeed.dw800X480_Y);
		xml.SetChildAttrib(_T("Y_800X480"),strText);
	}	

	if(xml.FindChildElem(_T("UiData")))
	{
		xml.IntoElem();

		if(xml.FindChildElem(_T("Idle")))
		{	
			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwLeftUpID);
			xml.SetChildAttrib(_T("ID_Left_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwLeftMiddleID);
			xml.SetChildAttrib(_T("ID_Left_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwLeftDownID);
			xml.SetChildAttrib(_T("ID_Left_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwRightUpID);
			xml.SetChildAttrib(_T("ID_Right_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwRightMiddleID);
			xml.SetChildAttrib(_T("ID_Right_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataIdle.dwRightDownID);
			xml.SetChildAttrib(_T("ID_Right_Down"),strText);
		}
		if(xml.FindChildElem(_T("Tour")))
		{		
			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwLeftUpID);
			xml.SetChildAttrib(_T("ID_Left_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwLeftMiddleID);
			xml.SetChildAttrib(_T("ID_Left_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwLeftDownID);
			xml.SetChildAttrib(_T("ID_Left_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwRightUpID);
			xml.SetChildAttrib(_T("ID_Right_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwRightMiddleID);
			xml.SetChildAttrib(_T("ID_Right_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataTour.dwRightDownID);
			xml.SetChildAttrib(_T("ID_Right_Down"),strText);
		}

		if(xml.FindChildElem(_T("Race")))
		{		
			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwLeftUpID);
			xml.SetChildAttrib(_T("ID_Left_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwLeftDownID);
			xml.SetChildAttrib(_T("ID_Left_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwMiddleUpID);
			xml.SetChildAttrib(_T("ID_Middle_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwMiddleMiddleID);
			xml.SetChildAttrib(_T("ID_Middle_Middle"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwMiddleDownID);
			xml.SetChildAttrib(_T("ID_Middle_Down"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwRightUpID);
			xml.SetChildAttrib(_T("ID_Right_Up"),strText);

			strText.Format(_T("0x%08X"),m_tagAppConfig.tagUiDataRace.dwRightDownID);
			xml.SetChildAttrib(_T("ID_Right_Down"),strText);
		}
		xml.OutOfElem();
	}

	if(xml.FindChildElem(_T("APP_START_LIST")))
	{
		xml.IntoElem();

		while(xml.FindChildElem(_T("APP"))) 
		{	
			for (int i=0;i<m_vecAppList.size();i++)
			{
				if (xml.GetChildAttrib(_T("ID")) == m_vecAppList[i].strAppID)
				{
					xml.SetChildAttrib(_T("PATH"),m_vecAppList[i].strAppPath);
					if (m_vecAppList[i].bAutoRun)
						xml.SetChildAttrib(_T("AUTO_RUN"),_T("1"));
					else
						xml.SetChildAttrib(_T("AUTO_RUN"),_T("0"));
				}
			}
		}
		xml.OutOfElem();
	}	



	xml.Save(strAppConfigFile);

	return TRUE;
}
예제 #26
0
// 初始化应用配置信息
BOOL COBDPNDConfigReadWrite::fInitAppConfig(void)
{
	CMarkup xml;
	CString strAppPath = fCommGetAppPath() + _T("\\");

	CString strAppConfigFile = strAppPath + _T("Config.xml");
	if (!xml.Load(strAppConfigFile))
	{		
		return CONFIG_ERR_LOAD_FILE; 
	}

	xml.ResetMainPos();
	xml.FindElem();	

	if(xml.FindChildElem(_T("System")))
	{		
		xml.IntoElem();	
		if(xml.FindChildElem(_T("Base")))
		{			
			m_tagAppConfig.bIsDemo			= (xml.GetChildAttrib(_T("Demo_Mode"))==_T("ON")?TRUE:FALSE);
			m_tagAppConfig.strTextFile		= xml.GetChildAttrib(_T("File_Text"));
			m_tagAppConfig.strFilterAppList = xml.GetChildAttrib(_T("FILTER_APP_LIST"));
		}
		if(xml.FindChildElem(_T("COM_OBD")))
		{			
			m_tagAppConfig.tagComOBD.wPort = (WORD)_ttoi(xml.GetChildAttrib(_T("Port")));
			m_tagAppConfig.tagComOBD.dwBPS =(WORD) _ttoi(xml.GetChildAttrib(_T("BPS")));
			m_tagAppConfig.tagComOBD.wData_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Data_Bits")));
			m_tagAppConfig.tagComOBD.wStop_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Stop_Bits")));
			m_tagAppConfig.tagComOBD.wParity = 0;//_ttoi(xml.GetChildAttrib(_T("Parity")));
		}
		if(xml.FindChildElem(_T("COM_GPS")))
		{			
			m_tagAppConfig.tagComGPS.wPort = (WORD)_ttoi(xml.GetChildAttrib(_T("Port")));
			m_tagAppConfig.tagComGPS.dwBPS = (WORD)_ttoi(xml.GetChildAttrib(_T("BPS")));
			m_tagAppConfig.tagComGPS.wData_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Data_Bits")));
			m_tagAppConfig.tagComGPS.wStop_Bits = (WORD)_ttoi(xml.GetChildAttrib(_T("Stop_Bits")));
			m_tagAppConfig.tagComGPS.wParity = 0;//_ttoi(xml.GetChildAttrib(_T("Parity")));
		}
		if(xml.FindChildElem(_T("Setting")))
		{			
			m_tagAppConfig.tagSetting.strLanguage			= xml.GetChildAttrib(_T("LANGUAGE"));
			m_tagAppConfig.tagSetting.bSaveErrorLog			= (xml.GetChildAttrib(_T("Save_ErrorLog"))==_T("OFF")?FALSE:TRUE);
			m_tagAppConfig.tagSetting.wBacklightDay			= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_DAY")));
			m_tagAppConfig.tagSetting.wBacklightNight		= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_NIGHT")));
			m_tagAppConfig.tagSetting.wBacklightDayStart	= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_DAY_START")));
			m_tagAppConfig.tagSetting.wBackLightDayEnd		= _ttoi(xml.GetChildAttrib(_T("BACKLIGHT_DAY_END")));
			m_tagAppConfig.tagSetting.dwActiveEcuID			= _ttoi(xml.GetChildAttrib(_T("Active_EUC_ID")));
			m_tagAppConfig.tagSetting.str24or12				= xml.GetChildAttrib(_T("Time_24_12Hour"));
			m_tagAppConfig.tagSetting.dwSystemOffTime		= _ttoi(xml.GetChildAttrib(_T("System_Off_Time")));
			m_tagAppConfig.tagSetting.dwSystemOffMode		= _ttoi(xml.GetChildAttrib(_T("System_Off_Mode")));
			m_tagAppConfig.tagSetting.dwAutoSelPanelTime	= _ttoi(xml.GetChildAttrib(_T("Auto_Sel_Panel_Time")));
			m_tagAppConfig.tagSetting.fAvgFuelParameter		= wcstod(xml.GetChildAttrib(_T("Parameter_Fuel_Avg")),0);
			m_tagAppConfig.tagSetting.fInstantFuelParameter	= wcstod(xml.GetChildAttrib(_T("Parameter_Fuel_Instant")),0);
			m_tagAppConfig.tagSetting.fFuelPrice			= wcstod(xml.GetChildAttrib(_T("Fuel_Price")),0);
			m_tagAppConfig.tagSetting.dwActiveEcuID			= _ttoi(xml.GetChildAttrib(_T("Active_ECU_ID")));
		}
		if(xml.FindChildElem(_T("Language_list")))
		{
			xml.IntoElem(); 

			m_tagAppConfig.vecLanguage.clear();
			while(xml.FindChildElem(_T("LANGUAGE")))
			{	
				_TagLanguage tagLanData;
				tagLanData.strLanID		= xml.GetChildAttrib(_T("LANGUAGE_ID"));
				tagLanData.strLanName	= xml.GetChildAttrib(_T("LANGUAGE_NAME"));
				tagLanData.strLanSN		= xml.GetChildAttrib(_T("LANGUAGE_SN"));
				tagLanData.strResFiles	= xml.GetChildAttrib(_T("LANGUAGE_RES"));

				m_tagAppConfig.vecLanguage.push_back(tagLanData);
			}

			xml.OutOfElem();
		}
		if(xml.FindChildElem(_T("Set_Alarm")))
		{		
			m_tagAppConfig.tagAlarmSet.bTroubleCode				= xml.GetChildAttrib(_T("TroubleCode"))==_T("ON")?TRUE:FALSE;
			m_tagAppConfig.tagAlarmSet.wSpeed					= _ttoi(xml.GetChildAttrib(_T("Speed")));
			m_tagAppConfig.tagAlarmSet.wCoolant					= _ttoi(xml.GetChildAttrib(_T("Coolant")));
			m_tagAppConfig.tagAlarmSet.wFatigue_Driving			= _ttoi(xml.GetChildAttrib(_T("Fatigue_Driving")));
			m_tagAppConfig.tagAlarmSet.dbFuel					= wcstod(xml.GetChildAttrib(_T("Fuel")),0);

			xml.IntoElem();
			if(xml.FindChildElem(_T("Shift")))
			{
				m_tagAppConfig.tagAlarmSet.wShiftRpm				= _ttoi(xml.GetChildAttrib(_T("Shift_Rpm")));
				m_tagAppConfig.tagAlarmSet.wShiftSpeed			= _ttoi(xml.GetChildAttrib(_T("Shift_Speed")));
			}
			if(xml.FindChildElem(_T("Volt")))
			{
				m_tagAppConfig.tagAlarmSet.wVoltMin				= _ttoi(xml.GetChildAttrib(_T("Volt_Min")));
				m_tagAppConfig.tagAlarmSet.wVoltMax				= _ttoi(xml.GetChildAttrib(_T("Volt_Max")));
			}

			xml.OutOfElem();
		}
		xml.OutOfElem();
	}

	if(xml.FindChildElem(_T("Mini_Dlg")))
	{			
		m_tagAppConfig.tagMiniSpeed.dw480X272_X			= _ttoi(xml.GetChildAttrib(_T("X_480X272")));	
		m_tagAppConfig.tagMiniSpeed.dw480X272_Y			= _ttoi(xml.GetChildAttrib(_T("Y_480X272")));		
		m_tagAppConfig.tagMiniSpeed.dw800X480_X			= _ttoi(xml.GetChildAttrib(_T("X_800X480")));		
		m_tagAppConfig.tagMiniSpeed.dw800X480_Y			= _ttoi(xml.GetChildAttrib(_T("Y_800X480")));				
	}

	if(xml.FindChildElem(_T("UiData")))
	{		
		xml.IntoElem();	
		if(xml.FindChildElem(_T("Idle")))
		{	
			m_tagAppConfig.tagUiDataIdle.dwLeftUpID			= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Up")));
			m_tagAppConfig.tagUiDataIdle.dwLeftMiddleID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Middle")));
			m_tagAppConfig.tagUiDataIdle.dwLeftDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Down")));
			m_tagAppConfig.tagUiDataIdle.dwRightUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Up")));
			m_tagAppConfig.tagUiDataIdle.dwRightMiddleID	= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Middle")));
			m_tagAppConfig.tagUiDataIdle.dwRightDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Down")));
		}

		if(xml.FindChildElem(_T("Tour")))
		{		
			m_tagAppConfig.tagUiDataTour.dwLeftUpID			= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Up")));
			m_tagAppConfig.tagUiDataTour.dwLeftMiddleID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Middle")));
			m_tagAppConfig.tagUiDataTour.dwLeftDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Down")));
			m_tagAppConfig.tagUiDataTour.dwRightUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Up")));
			m_tagAppConfig.tagUiDataTour.dwRightMiddleID	= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Middle")));
			m_tagAppConfig.tagUiDataTour.dwRightDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Down")));
		}

		if(xml.FindChildElem(_T("Race")))
		{		
			m_tagAppConfig.tagUiDataRace.dwLeftUpID			= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Up")));
			m_tagAppConfig.tagUiDataRace.dwLeftDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Left_Down")));
			m_tagAppConfig.tagUiDataRace.dwRightUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Up")));
			m_tagAppConfig.tagUiDataRace.dwRightDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Right_Down")));
			m_tagAppConfig.tagUiDataRace.dwMiddleUpID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Middle_Up")));
			m_tagAppConfig.tagUiDataRace.dwMiddleMiddleID	= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Middle_Middle")));
			m_tagAppConfig.tagUiDataRace.dwMiddleDownID		= fCommStr2Hex(xml.GetChildAttrib(_T("ID_Middle_Down")));
		}
		xml.OutOfElem();
	}
	if(xml.FindChildElem(_T("Sound")))
	{
		m_tagAppConfig.tagSoundFile.strDong					=  strAppPath + xml.GetChildAttrib(_T("Dong"));
		m_tagAppConfig.tagSoundFile.strInitialze			=  strAppPath + xml.GetChildAttrib(_T("Initialze"));
		m_tagAppConfig.tagSoundFile.strStart				=  strAppPath + xml.GetChildAttrib(_T("Start"));
		m_tagAppConfig.tagSoundFile.strGetData				=  strAppPath + xml.GetChildAttrib(_T("GetData"));
		m_tagAppConfig.tagSoundFile.strAlarmCoolant			=  strAppPath + xml.GetChildAttrib(_T("AlarmCoolant"));
		m_tagAppConfig.tagSoundFile.strAlarmFatigueDriving	=  strAppPath + xml.GetChildAttrib(_T("AlarmFatigueDriving"));
		m_tagAppConfig.tagSoundFile.strAlarmOverSpeed		=  strAppPath + xml.GetChildAttrib(_T("AlarmOverSpeed"));
		m_tagAppConfig.tagSoundFile.strAlarmVoltHigh		=  strAppPath + xml.GetChildAttrib(_T("AlarmVoltHigh"));
		m_tagAppConfig.tagSoundFile.strAlarmVoltLow			=  strAppPath + xml.GetChildAttrib(_T("AlarmVoltLow"));
		m_tagAppConfig.tagSoundFile.strAlarmTrouble			=  strAppPath + xml.GetChildAttrib(_T("AlarmTrouble"));
	}
	if(xml.FindChildElem(_T("GPS_LIST")))
	{
		xml.IntoElem();

		m_vecGPSList.clear();
		while(xml.FindChildElem(_T("GPS")))
		{	
			TagAppInfo tagAppInfo;
			tagAppInfo.strAppID = xml.GetChildAttrib(_T("ID"));
			tagAppInfo.strAppName = xml.GetChildAttrib(_T("NAME_CHS"));
			tagAppInfo.strAppPath =  xml.GetChildAttrib(_T("FOLDER"));
			tagAppInfo.strAppExe = xml.GetChildAttrib(_T("EXE"));
			tagAppInfo.bAutoRun = FALSE;

			m_vecGPSList.push_back(tagAppInfo);
		}
		xml.OutOfElem();
	}	

	if(xml.FindChildElem(_T("DSA_LIST")))
	{
		xml.IntoElem();

		m_vecDSAList.clear();
		while(xml.FindChildElem(_T("DSA"))) 
		{	
			TagAppInfo tagAppInfo;
			tagAppInfo.strAppID = xml.GetChildAttrib(_T("ID"));
			tagAppInfo.strAppName = xml.GetChildAttrib(_T("NAME_CHS"));
			tagAppInfo.strAppPath =  xml.GetChildAttrib(_T("FOLDER"));
			tagAppInfo.strAppExe= xml.GetChildAttrib(_T("EXE"));
			tagAppInfo.bAutoRun = FALSE;

			m_vecDSAList.push_back(tagAppInfo);
		}
		xml.OutOfElem();
	}	
	
	if(xml.FindChildElem(_T("APP_START_LIST")))
	{
		xml.IntoElem();

		m_vecAppList.clear();
		while(xml.FindChildElem(_T("APP"))) 
		{	
			TagAppInfo tagAppInfo;
			tagAppInfo.strAppID = xml.GetChildAttrib(_T("ID"));
			if (tagAppInfo.strAppID == _T("1"))
				tagAppInfo.strAppName = theMainDlg->fGetBinText(DS_SETUP_GUIDE_DSA_TITLE);
			if (tagAppInfo.strAppID == _T("2"))
				tagAppInfo.strAppName = theMainDlg->fGetBinText(DS_SETUP_GUIDE_GPS_TITLE);
			tagAppInfo.strAppPath =  xml.GetChildAttrib(_T("PATH"));
			if (xml.GetChildAttrib(_T("AUTO_RUN")) == _T("1"))
				tagAppInfo.bAutoRun = TRUE;
			else
				tagAppInfo.bAutoRun = FALSE;

			m_vecAppList.push_back(tagAppInfo);
		}
		xml.OutOfElem();
	}	


	return TRUE;
}
예제 #27
0
CreatureType::CreatureType(const std::string& xmlstring)
    : age_(18,57), alignment_public_mood_(true),
      attribute_points_(40),
      gender_liberal_(GENDER_RANDOM), gender_conservative_(GENDER_RANDOM),
      infiltration_(0), juice_(0), money_(20,40)
{
    for(int i=0; i<ATTNUM; i++)
        attributes_[i].set_interval(1,10);

    id_=number_of_creaturetypes++;

    CMarkup xml;
    xml.SetDoc(xmlstring);
    xml.FindElem();

    idname_=xml.GetAttrib("idname");
    if(!len(idname_))
    {
        idname_ = "LACKS IDNAME "+tostring(id_);
        xmllog.log("Creature type "+tostring(id_)+" lacks idname.");
    }
    type_=creaturetype_string_to_enum(idname_);

    xml.IntoElem();
    // Loop over all the elements inside the creaturetype element.
    while(xml.FindElem())
    {
        std::string element = xml.GetTagName();

        if (element == "alignment")
        {
            std::string alignment = xml.GetData();
            if (alignment == "PUBLIC MOOD")
                alignment_public_mood_ = true;
            else if (alignment == "LIBERAL")
            {
                alignment_ = ALIGN_LIBERAL;
                alignment_public_mood_ = false;
            }
            else if (alignment == "MODERATE")
            {
                alignment_ = ALIGN_MODERATE;
                alignment_public_mood_ = false;
            }
            else if (alignment == "CONSERVATIVE")
            {
                alignment_ = ALIGN_CONSERVATIVE;
                alignment_public_mood_ = false;
            }
            else
                xmllog.log("Invalid alignment for " + idname_ + ": " + alignment);
        }
        else if (element == "age")
        {
            std::string age = xml.GetData();
            if (age == "DOGYEARS")
                age_.set_interval(2,6);
            else if (age == "CHILD")
                age_.set_interval(7,10);
            else if (age == "TEENAGER")
                age_.set_interval(14,17);
            else if (age == "YOUNGADULT")
                age_.set_interval(18,35);
            else if (age == "MATURE")
                age_.set_interval(20,59);
            else if (age == "GRADUATE")
                age_.set_interval(26,59);
            else if (age == "MIDDLEAGED")
                age_.set_interval(35,59);
            else if (age == "SENIOR")
                age_.set_interval(65,94);
            else
                assign_interval(age_, age, idname_, element);
        }
        else if (element == "attribute_points")
            assign_interval(attribute_points_, xml.GetData(), idname_, element);
        else if (element == "attributes")
        {
            while(xml.FindChildElem())
            {
                int attribute = attribute_string_to_enum(xml.GetChildTagName());
                if (attribute != -1)
                    assign_interval(attributes_[attribute], xml.GetChildData(), idname_, element);
                else
                    xmllog.log("Unknown attribute in " + idname_ + ": " + xml.GetTagName());
            }
        }
        else if (element == "juice")
            assign_interval(juice_, xml.GetData(), idname_, element);
        else if (element == "gender")
        {
            int gender = gender_string_to_enum(xml.GetData());
            if (gender != -1 && gender != GENDER_WHITEMALEPATRIARCH)
                gender_liberal_ = gender_conservative_ = gender;
            else
                xmllog.log("Invalid gender for " + idname_ + ": " + xml.GetData());
        }
        else if (element == "infiltration")
            assign_interval(infiltration_, xml.GetData(), idname_, element);
        else if (element == "money")
            assign_interval(money_, xml.GetData(), idname_, element);
        else if (element == "skills")
        {
            while(xml.FindChildElem())
            {
                int skill = skill_string_to_enum(xml.GetChildTagName());
                if (skill != -1)
                    assign_interval(skills_[skill], xml.GetChildData(), idname_, element);
                else
                    xmllog.log("Unknown skill for " + idname_ + ": " + xml.GetChildTagName());
            }
        }
        else if (element == "armor")
        {
            if (getarmortype(xml.GetData()) != -1)
                armortypes_.push_back(xml.GetData());
            else
                xmllog.log("Invalid armor type for " + idname_ + ": " + xml.GetData());;
        }
        else if (element == "weapon")
        {
            //xml.SavePos("creature");
            weapons_and_clips_.push_back(WeaponsAndClips(xml, idname_));
            //xml.RestorePos("creature");
        }
        else if (element == "encounter_name")
            encounter_name_ = xml.GetData();
        else if (element == "type_name")
            type_name_ = xml.GetData();
        else
            xmllog.log("Unknown element for " + idname_ + ": " + element);
    }

    if (!len(type_name_))
    {
        xmllog.log("type_name not defined for " + idname_ + ".");
        type_name_ = "UNDEFINED";
    }
    // If no weapon type has been given then use WEAPON_NONE.
    if (!len(weapons_and_clips_))
        weapons_and_clips_.push_back(WeaponsAndClips("WEAPON_NONE", 1, "NONE", 0));
    // If no armor type has been given then use ARMOR_NONE.
    if (!len(armortypes_))
        armortypes_.push_back("ARMOR_NONE");
}
예제 #28
0
int getChavesProfessor(string path, chavesProfessor *temp)
{
    CMarkup xml;
    int nTrab = 0, nArt = 0;

    if(!xml.Load(path)){
        cout << "Erro de abertura do arquivo xml." << endl;
        return 1;
    }


    strcpy (temp->nomeArquivo, path.c_str());
    if (!xml.FindElem("CURRICULO-VITAE")){
        cout << "Sem CV" << endl;
        return ERROR;
    }
// ================ NOME ===================

    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("DADOS-GERAIS")){
        cout << "Sem DADOS-GERAIS." << endl;
        return ERROR;
    }
    strcpy (temp->nome, xml.GetAttrib("NOME-COMPLETO").c_str());
    //cout << temp.nome << endl;
    xml.IntoElem(); // define DADOS-GERAIS como parent



    xml.ResetPos();


// ========= TRABALHOS EM EVENTOS ===================
    xml.FindElem("CURRICULO-VITAE"); // se passou pelo primeiro findelem(curriculo vitae)
    //passa por esse
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("PRODUCAO-BIBLIOGRAFICA")){
        cout << "Sem PRODUCAO-BIBLIOGRAFICA." <<temp->nome<< endl;
        return ERROR;
    }
    xml.IntoElem();

    if(!xml.FindElem("TRABALHOS-EM-EVENTOS")){
        cout << "Sem TRABALHOS-EM-EVENTOS." << endl;
        return ERROR;
    }
    xml.IntoElem();// define TRABALHOS-EM-EVENTOS como parent

    while(xml.FindElem()){
        nTrab++;
    }
    temp->nPEventos = nTrab;
    xml.ResetPos();


// ========= ARTIGOS PUBLICADOS ===================
    xml.FindElem("CURRICULO-VITAE"); // se passou pelo primeiro findelem(curriculo vitae)
    //passa por esse
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("PRODUCAO-BIBLIOGRAFICA")){
        cout << "Sem PRODUCAO-BIBLIOGRAFICA."<<temp->nome << endl;
        return ERROR;
    }
    xml.IntoElem();

    if(!xml.FindElem("ARTIGOS-PUBLICADOS")){
        cout << "Sem ARTIGOS-PUBLICADOS."<<temp->nome << endl;
        return ERROR;
    }
    xml.IntoElem();// define ARTIGOS-PUBLICADOS como parent

    while(xml.FindElem()){
        nArt++;
    }
    temp->nPPeriodicos = nArt;


    return SUCCESS;
}
예제 #29
0
int parseProfessor(string path, dadosProfessor *temp){
    CMarkup xml;
    int nTrab = 0, nArt = 0;

    if(!xml.Load(path)){
        cout << "Erro de abertura do arquivo xml." << endl;
        return 1;
    }

// ========= DADOS GERAIS ===================
    if (!xml.FindElem("CURRICULO-VITAE")){
        cout << "Sem CV" << endl;
        return ERROR;
    }
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("DADOS-GERAIS")){
        cout << "Sem DADOS-GERAIS." << endl;
        return ERROR;
    }
    temp->nome = xml.GetAttrib("NOME-COMPLETO");
    //cout << temp.nome << endl;
    xml.IntoElem(); // define DADOS-GERAIS como parent

    if(!xml.FindElem("ATUACOES-PROFISSIONAIS")){
        cout << "Sem ATUACOES-PROFISSIONAIS" <<endl;
        return ERROR;
    }
    if(!xml.FindChildElem("ATUACAO-PROFISSIONAL")){
        cout << "Sem ATUACAO-PROFISSIONAL" << endl;
        return ERROR;
    }
    temp->instituicao = xml.GetChildAttrib("NOME-INSTITUICAO");
    //cout << temp.instituicao << endl;
    xml.IntoElem(); // define ATUACAO-PROFISSIONAL como parent

    if(!xml.FindChildElem("ATIVIDADES-DE-PESQUISA-E-DESENVOLVIMENTO")){
        cout << "Sem linha de pesquisa" << endl;
        return ERROR;
    }
    xml.IntoElem(); //define APD como parent

    if(!xml.FindChildElem("PESQUISA-E-DESENVOLVIMENTO")){
        cout << "Sem linha de pesquisa" << endl;
        return ERROR;
    }
    xml.IntoElem(); // define PD como parent

    if(!xml.FindChildElem("LINHA-DE-PESQUISA")){
        cout << "Sem linha de pesquisa" << endl;
        return ERROR;
    }
    temp->area = xml.GetChildAttrib("TITULO-DA-LINHA-DE-PESQUISA");
    //cout << temp.area << endl;

    xml.ResetPos();


// ========= TRABALHOS EM EVENTOS ===================
    xml.FindElem("CURRICULO-VITAE"); // se passou pelo primeiro findelem(curriculo vitae)
    //passa por esse
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("PRODUCAO-BIBLIOGRAFICA")){
        cout << "Sem PRODUCAO-BIBLIOGRAFICA." << endl;
        return ERROR;
    }
    xml.IntoElem();

    if(!xml.FindElem("TRABALHOS-EM-EVENTOS")){
        cout << "Sem TRABALHOS-EM-EVENTOS." << endl;
        return ERROR;
    }
    xml.IntoElem();// define TRABALHOS-EM-EVENTOS como parent

    while(xml.FindElem()){
        Trabalho trab;
        xml.FindChildElem("DADOS-BASICOS-DO-TRABALHO");
        trab.titulo = xml.GetChildAttrib("TITULO-DO-TRABALHO");
        trab.ano = xml.GetChildAttrib("ANO-DO-TRABALHO");
        temp->pubEventos.push_back(trab);
        nTrab++;
    }
    temp->nPubEventos = nTrab;
    xml.ResetPos();


// ========= ARTIGOS PUBLICADOS ===================
    xml.FindElem("CURRICULO-VITAE"); // se passou pelo primeiro findelem(curriculo vitae)
    //passa por esse
    xml.IntoElem(); //seta CV como tag pai

    if(!xml.FindElem("PRODUCAO-BIBLIOGRAFICA")){
        cout << "Sem PRODUCAO-BIBLIOGRAFICA." << endl;
        return ERROR;
    }
    xml.IntoElem();

    if(!xml.FindElem("ARTIGOS-PUBLICADOS")){
        cout << "Sem ARTIGOS-PUBLICADOS." << endl;
        return ERROR;
    }
    xml.IntoElem();// define ARTIGOS-PUBLICADOS como parent

    while(xml.FindElem()){
        Artigo artigo;
        xml.FindChildElem("DADOS-BASICOS-DO-ARTIGO");
        artigo.titulo = xml.GetChildAttrib("TITULO-DO-ARTIGO");
        artigo.ano = xml.GetChildAttrib("ANO-DO-ARTIGO");
        temp->pubPeriodicos.push_back(artigo);
        nArt++;
    }
    temp->nPubPeriodicos = nArt;


    return SUCCESS;
}
예제 #30
0
/*			
SET_ITEM_DATA(type, Type, false);
SET_ITEM_DATA(version, Version, true);
SET_ITEM_DATA(downurl, DownURL, true);
SET_ITEM_DATA(downpath, DownPath, false);
SET_ITEM_DATA(description, Description, false);
SET_ITEM_DATA(force, Force, false);
SET_ITEM_DATA(regsrv, RegSrv, false);
*/
BOOL CUpdateUtil::ReadXML(CString& strXMLdoc, CItemList* pSourceItemList, int nKind)
{
	CString strData = "";
	
	if(strXMLdoc.IsEmpty())
		return FALSE;

	CMarkup xml;
	
	if(!xml.SetDoc(strXMLdoc))
		return FALSE;

	xml.ResetPos();

	if(!xml.FindElem(_T("update-data")))
		return FALSE;

	UTIL_CANCEL();
	while(xml.FindChildElem(_T("file")))
	{	
		UTIL_CANCEL();
		strData = "";
		strData = xml.GetChildAttrib(_T("name"));
		
		if(!strData.IsEmpty())
		{
			xml.IntoElem();
			if(nKind == UPDATE_KIND_SOURCE)
			{
				PUPDATE_DATA pFileData = (PUPDATE_DATA)pSourceItemList->GetNewItem();
				memset(pFileData, 0, sizeof(UPDATE_DATA));

				STRCPY(Name);
				if(xml.FindChildElem(_T("type")))
				{
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Type);
				}

				if(xml.FindChildElem(_T("version")))
				{
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Version);
				}
				
				if(xml.FindChildElem(_T("size")))
				{				
					DATA_INIT_AND_DEPOSIT();					
					pFileData->Size = CString2Integer(strData);
				}

				if(xml.FindChildElem(_T("downurl")))
				{				
					DATA_INIT_AND_DEPOSIT();
					STRCPY(DownURL);
				}
				else											
					return FALSE;							

				if(xml.FindChildElem(_T("downpath")))
				{				
					DATA_INIT_AND_DEPOSIT();
					strData = GetFolderPath(strData);
					STRCPY(DownPath);
				}
				
				if(xml.FindChildElem(_T("description")))
				{				
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Description);
				}

				if(xml.FindChildElem(_T("force")))
				{				
					DATA_INIT_AND_DEPOSIT_NOCASE();
					STRCPY(Force);
				}

				if(xml.FindChildElem(_T("regsrv")))
				{				
					DATA_INIT_AND_DEPOSIT_NOCASE();
					STRCPY(RegSrv);
				}

				if(xml.FindChildElem(_T("checksum")))
				{
					DATA_INIT_AND_DEPOSIT_NOCASE();
					STRCPY(CheckSum);
				}
				
				if(xml.FindChildElem(_T("optionflag")))
				{
					DATA_INIT_AND_DEPOSIT();
					pFileData->OptionFlag = CString2Integer(strData);
				}
			}
			else
			{
				PUPDATE_DATA pFileData = (PUPDATE_DATA)pSourceItemList->GetNewItem();
				memset(pFileData, 0, sizeof(UPDATE_DATA));
				
				STRCPY(Name);
				if(xml.FindChildElem(_T("version")))
				{				
					DATA_INIT_AND_DEPOSIT();
					STRCPY(Version);
				}
				else
				{											
					return FALSE;							
				}

				if(xml.FindChildElem(_T("downpath")))
				{				
					DATA_INIT_AND_DEPOSIT();
					strData = GetFolderPath(strData);
					STRCPY(DownPath);
				}
			}
			xml.OutOfElem();
		}
	}
	
	return TRUE;
}