Beispiel #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;
}
void XMLFileSave()
{
	CMarkup xml;

	xml.AddElem(L"SERVERLIST");
	xml.AddChildElem(L"SERVER");
	xml.IntoElem();
	xml.AddChildElem(L"IP", L"127.0.0.1");
	xml.AddChildElem(L"PORT", 10000);
	xml.AddChildElem(L"IDENTIFER", 10000);
	xml.AddChildElem(L"DESC", L"GAME DATABASE SERVER");
	xml.OutOfElem();

	xml.AddChildElem(L"SERVER");
	xml.IntoElem();
	xml.AddChildElem(L"IP", L"127.0.0.1");
	xml.AddChildElem(L"PORT", 10001);
	xml.AddChildElem(L"IDENTIFER", 9000);
	xml.AddChildElem(L"DESC", L"AUTH SERVER");
	xml.OutOfElem();

	std::wstring csXML = xml.GetDoc();
	xml.Save(L"ServerConnection.xml");

	wprintf(L"%s", csXML.c_str());
}
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;
}
Beispiel #4
0
void CRequestXmlMessage::packedSendMessage(NetMessage& netMessage)
{
	CMarkup xml;
	xml.SetDoc("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
	xml.AddElem("Message");
	xml.AddChildElem("Header");
	xml.IntoElem();
	xml.AddAttrib("MsgType", "EMSG_REQUESTXML_RSP");
	xml.OutOfElem();
	xml.AddChildElem("Result");
	xml.IntoElem();
	xml.AddAttrib("ErrorCode", 0);
	xml.AddAttrib("Value", QString::fromLocal8Bit("成功").toStdString().c_str());
	xml.OutOfElem();
	xml.AddChildElem("SvrInfo");
	xml.IntoElem();
	xml.AddAttrib("UpdateXmlUrl", MessageDataMediator->m_strUpdateXMLUrl.toStdString().c_str());
	xml.AddAttrib("HelpInfoXmlUrl", MessageDataMediator->m_strHelpXMLUrl.toStdString().c_str());
	xml.AddAttrib("VersionCheckFileUrl", MessageDataMediator->m_strClientVersionUrl.toStdString().c_str());
	xml.AddAttrib("TextMode", MessageDataMediator->m_bTextMode ? "1" : "0");
	xml.OutOfElem();

	netMessage.msgBuffer = packXml(&xml);
	netMessage.msgLen = xml.GetDoc().length();
}
Beispiel #5
0
bool CInstrOffsetData::Save(LPCTSTR filePath) {
	CMarkup xml;
	xml.SetDoc("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
	xml.AddNode(CMarkup::MNT_ELEMENT, "root");
	xml.IntoElem();

	M2::iterator m2it;

	xml.AddNode(CMarkup::MNT_ELEMENT, "header");
	xml.SetAttrib("version", 1);

	xml.AddNode(CMarkup::MNT_ELEMENT, "data");
	xml.IntoElem();

	for (m2it = m_data.begin(); m2it != m_data.end(); m2it++) {
		CString frequency;
		frequency.Format("%f", m2it->first);
		xml.AddNode(CMarkup::MNT_ELEMENT, "frequency");
		xml.SetAttrib("value", frequency);
		xml.IntoElem();
		M1::iterator m1it;
		for (m1it = m2it->second.begin(); m1it != m2it->second.end(); m1it++) {
			CString dbm, offset;
			dbm.Format("%f", m1it->first);
			offset.Format("%f", m1it->second);
			
			xml.AddNode(CMarkup::MNT_ELEMENT, "power");
			
			xml.SetAttrib("dest_power", dbm);
			xml.SetAttrib("offset", offset);
		}
		xml.OutOfElem();
	}
	return xml.Save(filePath);
}
Beispiel #6
0
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();
}
Beispiel #7
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;
	}
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());
      }
   }
}
Beispiel #9
0
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();

}
void XMLFileRead()
{
	CMarkup xml;
	xml.Load(L"ServerConnection.xml");

	while (xml.FindChildElem(L"SERVER"))
	{
		_ConnectorInfo connectorInfo;
		xml.IntoElem();

		xml.FindChildElem(L"IP");
		connectorInfo.szIP = xml.GetChildData();

		xml.FindChildElem(L"PORT");
		connectorInfo.port = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"IDENTIFER");
		connectorInfo.identifier = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"DESC");
		connectorInfo.szDesc = xml.GetChildData();

		xml.OutOfElem();
	}

}
Beispiel #11
0
// 根据配置索引获取配置信息
CString CVCheckerClsConfig::fGetConfigData(int nConfigIndex)
{
	if (m_strConfigFile == _T(""))
		return _T("");

	CMarkup xml;
	BOOL bLoad = FALSE;
	bLoad = xml.Load(m_strConfigFile);
	if (!bLoad)
		return _T(""); 

	xml.ResetPos();
	while ( xml.FindChildElem(_T("System_Config")))
	{
		xml.IntoElem();
		
		//xml.ResetMainPos();
		//xml.FindChildElem( "NAME" );
		////	xml.FindChildElem();
		//CString csName = xml.GetChildData();
		//AfxMessageBox(csName);

		//xml.ResetMainPos(); //注意复位
		//xml.FindChildElem( "SN" );
		////	xml.FindChildElem();
		//CString csSN = xml.GetChildData();
		//AfxMessageBox(csSN);

		xml.OutOfElem();
	}	

	return CString();
}
Beispiel #12
0
bool CRequestXmlMessage::treatMessage(const NetMessage& netMessage, CMessageFactory* pFactory, SocketContext* clientSocket)
{
	//请求XML时检测客户端ID,如果不存在,执行注册ID流程
	CMarkup xml;
	if(xml.SetDoc(netMessage.msgBuffer))
	{
		if(xml.FindChildElem("Info"))
		{
			xml.IntoElem();
			QString strId = QString::fromStdString(xml.GetAttrib("Id"));
			if(!DataManagerThread->IsClientExist(strId))
			{
				DataMotion dataMotion;
				dataMotion.msg = EMSG_REGISTERID;
				dataMotion.clientInfo.id = strId;
				dataMotion.clientInfo.version = ""; //yhb 版本号暂时不用
				DataManagerThread->AddDataMotion(dataMotion);
			}
		}
	}

	if(NULL != pFactory)
	{
		return pFactory->sendMessage(clientSocket, netMessage.msgHead);
	}

	return true;
}
bool SFServerConnectionManager::InitServerList(WCHAR* szFileName)
{
	CMarkup xml;
	xml.Load(L"ServerConnection.xml");

	while (xml.FindChildElem(L"SERVER"))
	{
		_ServerInfo serverInfo;
		xml.IntoElem();

		xml.FindChildElem(L"IP");
		serverInfo.szIP = xml.GetChildData();

		xml.FindChildElem(L"PORT");
		serverInfo.port = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"IDENTIFER");
		serverInfo.identifer = _ttoi(xml.GetChildData().c_str());

		xml.FindChildElem(L"DESC");
		serverInfo.szDesc = xml.GetChildData();

		xml.OutOfElem();

		SFServerBridge* pServer = new SFServerBridge(serverInfo);

		m_mapServerInfo.insert(std::make_pair(serverInfo.identifer, pServer));
	}

	return true;
}
Beispiel #14
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;
}
Beispiel #15
0
BOOL WriteMarkupString(CMarkup& markDoc, ST_MARKITEM& itemIn)
{	
	if (!itemIn.strKey.IsEmpty() && itemIn.strKey.Compare(TEXT(".")) != 0)
	{
		markDoc.AddElem(itemIn.strKey, itemIn.strVal);		
	}
	MAPKEYATTRIB ::iterator itb = itemIn.mapAttrib.begin();
	MAPKEYATTRIB ::iterator ite = itemIn.mapAttrib.end();
	for (; itb != ite; ++itb)
	{
		markDoc.AddAttrib(itb->first, itb->second);
	}

	MAPKEYVALUE& mapchild = itemIn.mapChildItem;
	MAPKEYVALUE::iterator itkvb = mapchild.begin();
	MAPKEYVALUE::iterator itkve = mapchild.end();
	for (; itkvb != itkve; ++itkvb)
	{
		markDoc.IntoElem();
		WriteMarkupString(markDoc, itkvb->second);
		markDoc.OutOfElem();
	}

	return TRUE;
}
string Vehicle::showXml () const
{
   char buf[256];

   CMarkup xml;
   xml.AddElem ("vehicle");
   xml.IntoElem ();
   xml.AddElem ("vtypeidname", vtypeidname_);

   snprintf (buf, 256, "%li", vtypeid_);
   xml.AddElem ("vtypeid", buf);

   xml.AddElem ("color", color_);

   snprintf (buf, 256, "%i", heat_);
   xml.AddElem ("heat", buf);

   snprintf (buf, 256, "%li", location_);
   xml.AddElem ("location", buf);

   snprintf (buf, 256, "%i", myear_);
   xml.AddElem ("myear", buf);

   snprintf (buf, 256, "%li", id_);
   xml.AddElem ("id", buf);

   return xml.GetDoc();
}
Beispiel #17
0
bool TestMarkup::AddElemTest()
{
	CMarkup markup;
	markup.AddElem(_U("Gis"), 234);
	markup.AddChildElem(_U("ABC"), _U("FALSE"));
	markup.IntoElem();
	markup.AddElem(_U("zhangkai"), 20);
	return TRUE;
}
Beispiel #18
0
bool CRegisterIdMessage::packedSendMessage(NetMessage& netMessage)
{
	CMarkup xml;
	xml.SetDoc("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
	xml.AddElem("Message");
	xml.AddChildElem("Header");
	xml.IntoElem();
	xml.AddAttrib("MsgType", "EMSG_REGISTERID_REQ");
	xml.OutOfElem();
	xml.AddChildElem("Info");
	xml.IntoElem();
	xml.AddAttrib("Id", MessageDataMediator->m_strNewId.toStdString().c_str());
	//xml.AddAttrib("Id", "23423");
	xml.OutOfElem();

	netMessage.msgBuffer = packXml(&xml);
	netMessage.msgLen = xml.GetDoc().length();
	return true;
}
Beispiel #19
0
void db_leos::DownloadLyrics(window_config *wcfg, lyric_data* data)
{
  data->Text = _T("");
  tstring xmltext;

  if (!ReadInternetTextFromUrl(xmltext, _T("FOO_UIE_LYRICS2"), data->Source, wcfg->cfg_timeout, wcfg))
    return ;

  tstring info_text;

  CMarkup xml;

  if (!xml.SetDoc(xmltext.c_str()))
    return ;

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

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

      info_text = xml.GetData();

      xml.OutOfElem();
    }

    xml.OutOfElem();
  }

  data->Text = info_text;

  data->Text = ReplaceString(_T("\r"), _T(""), data->Text);
  data->Text = ReplaceString(_T("\n"), _T("\r\n"), data->Text);
  data->IsLoaded = true;

  if (data->Text.find(_T("[")) != tstring::npos)
    data->IsTimestamped = true;
  else
    data->IsTimestamped = false;

}
string Clip::showXml () const
{
   CMarkup xml;
   xml.AddElem("clip");
   xml.IntoElem();

   addBaseValues(xml);

   return xml.GetDoc();
}
Beispiel #21
0
void XmlProxyCallback::_sendXmlMessage(const std::string & sMessage)
{
	CMarkup xmlMessage;

    xmlMessage.AddElem("response");
    xmlMessage.IntoElem();
    xmlMessage.AddElem("message", sMessage);
	xmlMessage.OutOfElem();

	_sendXmlResponse(xmlMessage, _sResponseEncode);
}
Beispiel #22
0
string Money::showXml () const
{
   CMarkup xml;
   xml.AddElem("money");
   xml.IntoElem();

   addBaseValues(xml);
   
   xml.AddElem("amount", tostring(amount_));

   return xml.GetDoc();
}
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;
      }
   }
}
Beispiel #24
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;
}
Beispiel #25
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());
   }
}
Beispiel #26
0
void CSoftInstallMessage::packedSendMessage(NetMessage& netMessage)
{
	CMarkup xml;
	xml.SetDoc("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
	xml.AddElem("Message");
	xml.AddChildElem("Header");
	xml.IntoElem();
	xml.AddAttrib("MsgType", "EMSG_SOFTINSTALL_RSP");
	xml.OutOfElem();
	xml.AddChildElem("Result");
	xml.IntoElem();
	xml.AddAttrib("ErrorCode", 0);
	xml.AddAttrib("Value", QString::fromLocal8Bit(m_bAddSuccess ? "添加成功" : "添加失败,XML无法解析").toStdString().c_str());
	xml.OutOfElem();
	xml.AddChildElem("Info");
	xml.IntoElem(); 
	xml.AddAttrib("Name", m_strName.toStdString().c_str());  //中文问题测试 yhb
	xml.AddAttrib("Version", m_strVersion.toStdString().c_str());
	xml.OutOfElem();

	netMessage.msgBuffer = packXml(&xml);;
	netMessage.msgLen = xml.GetDoc().length();
}
Beispiel #27
0
void CDistributeMessage::packedSendMessage(NetMessage& netMessage)
{
	CMarkup xml;
	xml.SetDoc("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n");
	xml.AddElem("Message");
	xml.AddChildElem("Header");
	xml.IntoElem();
	xml.AddAttrib("MsgType", "EMSG_DISTRIBUTEMSG_REQ");
	xml.OutOfElem();
	xml.AddChildElem("Result");
	xml.IntoElem();
	xml.AddAttrib("ErrorCode", 0);
	xml.AddAttrib("Value", QString::fromLocal8Bit("³É¹¦").toStdString().c_str());
	xml.OutOfElem();
	xml.AddChildElem("Info");
	xml.IntoElem();
	xml.AddAttrib("Msg", MessageDataMediator->m_strDistributeMsg.toStdString().c_str());
	xml.AddAttrib("Time", MessageDataMediator->m_strDistributeTime.toStdString().c_str());
	xml.OutOfElem();

	netMessage.msgBuffer = packXml(&xml);
	netMessage.msgLen = xml.GetDoc().length();
}
Beispiel #28
0
void CXmlElement::Save(CMarkup& xml)
{
	xml.AddElem(_name, _value);
	for (unsigned int i = 0; i < _attributes.size(); ++i)
	{
		xml.AddAttrib(_attributes[i].first, _attributes[i].second);
	}
	xml.IntoElem();
	for (unsigned int i = 0; i < _children.size(); ++i)
	{
		_children[i]->Save(xml);
	}
	xml.OutOfElem();
}
string Weapon::showXml () const
{
   CMarkup xml;
   xml.AddElem("weapon");
   xml.IntoElem();

   addBaseValues(xml);
   
   xml.AddElem("loaded_cliptype", loaded_cliptype_);
   
   xml.AddElem("ammo", tostring(ammo_));

   return xml.GetDoc();
}
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;*/
      }
   }
}