void Item::addBaseValues(CMarkup &xml) const { xml.AddElem("itemtypename", itemtypename_); xml.AddElem("itemtypeid", itemtypeid_); xml.AddElem("number", tostring(number_)); }
bool TestMarkup::ReadTextFile() { CMarkup markup; GKString strDoc; //return markup.ReadTextFile(pSrcFilePath, strDoc); return markup.ReadTextFile(_U("E:/trunk/01_SourceCode/Src/TestProject/TestMarkup.xml"), strDoc); }
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; }
int SaveLoadCNN::LoadAxonData(std::string FileName, AxonList* axon, std::vector<Group*>* cluster) { CMarkup axonXml; axonXml.Load(FileName); return GetAxonVec(axonXml, axon, cluster); }
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; }
bool CRegisterIdMessage::treatMessage(const NetMessage& netMessage, CNetClt* pNet) { CMarkup xml; if(xml.SetDoc(netMessage.msgBuffer)) { int errCode = 0; QString errorInfo = ""; if(checkError(&xml, errCode, errorInfo)) { if(0 != errCode) { ClientLogger->AddLog(QString::fromLocal8Bit("RegisterId [%1] : \r\n[%2]").arg(errorInfo).arg(netMessage.msgBuffer)); emit NetClass->m_pMessageEventMediator->sigError(netMessage.msgHead, errorInfo); return true; } } emit NetClass->m_pMessageEventMediator->sigRegisterSuccess(); } else { ClientLogger->AddLog(QString::fromLocal8Bit("RegisterId收到的消息错误, 无法被正确解析 : [%1]").arg(netMessage.msgBuffer)); emit NetClass->m_pMessageEventMediator->sigError(netMessage.msgHead, QString::fromLocal8Bit("收到的消息错误, 无法被正确解析")); } return true; }
int SaveLoadCNN::LoadClusterData(std::string fileName, std::vector<Group*>* cluster) { CMarkup clusterXml; clusterXml.Load(fileName); return GetClusterVec(clusterXml, cluster); }
int SaveLoadCNN::LoadAxonData(std::string fileName, AxonList * axon, std::vector<Group*>* destCluster, std::vector<Group*>* srcCluster) { CMarkup axonXml; axonXml.Load(fileName); return GetAxonVec(axonXml, axon, destCluster, srcCluster); }
CMarkup XMLSerialized::OpenFile(CString sFile){ CMarkup xml; XMLSerialized::ConvertFileName(sFile); xml.Load(sFile); if(xml.GetDoc().GetLength()>0) return xml; return NULL; }
BOOL CTxParamString::UpdateData( BOOL bToReal /*= TRUE*/ ) { CString strTmp; CMarkup markDoc; WriteMarkupString(markDoc, m_kvData); m_strRealString = markDoc.GetDoc(); return TRUE; }
/* active squad visits the pawn shop */ void pawnshop(int loc) { music.play(MUSIC_SHOPPING); locatesquad(activesquad,loc); CMarkup xml; // -XML xml.Load(string(artdir) + "pawnshop.xml"); Shop pawnshop(xml.GetDoc()); pawnshop.enter(*activesquad); }
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; }
BOOL CResourceManager::LoadLanguage(LPCTSTR pstrXml) { CMarkup xml; if( *(pstrXml) == _T('<') ) { if( !xml.Load(pstrXml) ) return FALSE; } else { if( !xml.LoadFromFile(pstrXml) ) return FALSE; } CMarkupNode Root = xml.GetRoot(); if( !Root.IsValid() ) return FALSE; LPCTSTR pstrClass = NULL; int nAttributes = 0; LPCTSTR pstrName = NULL; LPCTSTR pstrValue = NULL; LPTSTR pstr = NULL; //¼ÓÔØͼƬ×ÊÔ´ LPCTSTR pstrId = NULL; LPCTSTR pstrText = NULL; for( CMarkupNode node = Root.GetChild() ; node.IsValid(); node = node.GetSibling() ) { pstrClass = node.GetName(); if ((_tcsicmp(pstrClass,_T("Text")) == 0) && node.HasAttributes()) { //¼ÓÔØͼƬ×ÊÔ´ nAttributes = node.GetAttributeCount(); for( int i = 0; i < nAttributes; i++ ) { pstrName = node.GetAttributeName(i); pstrValue = node.GetAttributeValue(i); if( _tcsicmp(pstrName, _T("id")) == 0 ) { pstrId = pstrValue; } else if( _tcsicmp(pstrName, _T("value")) == 0 ) { pstrText = pstrValue; } } if( pstrId == NULL || pstrText == NULL) continue; CDuiString *lpstrFind = static_cast<CDuiString *>(m_mTextResourceHashMap.Find(pstrId)); if(lpstrFind != NULL) { lpstrFind->Assign(pstrText); } else { m_mTextResourceHashMap.Insert(pstrId, (LPVOID)new CDuiString(pstrText)); } } else continue; } return TRUE; }
/* active squad visits the arms dealer */ void armsdealer(int loc) { music.play(MUSIC_SHOPPING); locatesquad(activesquad,loc); CMarkup xml; // -XML xml.Load(string(artdir) + "armsdealer.xml"); Shop armsdealer(xml.GetDoc()); armsdealer.enter(*activesquad); }
/* active squad visits the oubliette */ void halloweenstore(int loc) { music.play(MUSIC_SHOPPING); locatesquad(activesquad,loc); CMarkup xml; xml.Load(string(artdir) + "oubliette.xml"); Shop oubliette(xml.GetDoc()); oubliette.enter(*activesquad); }
/* active squad visits the department store */ void deptstore(int loc) { music.play(MUSIC_SHOPPING); locatesquad(activesquad,loc); CMarkup xml; // -XML xml.Load(string(artdir) + "deptstore.xml"); Shop deptstore(xml.GetDoc()); deptstore.enter(*activesquad); }
string Clip::showXml () const { CMarkup xml; xml.AddElem("clip"); xml.IntoElem(); addBaseValues(xml); return xml.GetDoc(); }
BOOL COCSInventoryState::ReadFromFile(LPCTSTR lpstrFilename, LPCTSTR lpstrSection) { CMarkup myXml; // Fill Device hardware properties from string if (!myXml.LoadFile( lpstrFilename)) return FALSE; if (!ParseFromXML( &myXml, lpstrSection)) return FALSE; return TRUE; }
void XmlProxyCallback::_sendXmlMessage(const std::string & sMessage) { CMarkup xmlMessage; xmlMessage.AddElem("response"); xmlMessage.IntoElem(); xmlMessage.AddElem("message", sMessage); xmlMessage.OutOfElem(); _sendXmlResponse(xmlMessage, _sResponseEncode); }
string Money::showXml () const { CMarkup xml; xml.AddElem("money"); xml.IntoElem(); addBaseValues(xml); xml.AddElem("amount", tostring(amount_)); return xml.GetDoc(); }
CString XMLSerialized::LoadInfo(const CString& sName,TagType tagType,const CString parent=L""){ CMarkup xml = OpenFile(); if(tagType== TagType::Element){ if(FindPath(sName,&xml)) return xml.GetData(); } if(tagType== TagType::Attribute){ if(FindPath(parent,&xml)) return xml.GetAttrib(sName); } return L""; }
BOOL COCSInventoryState::WriteToFile(LPCTSTR lpstrFilename, LPCTSTR lpstrSection) { CMarkup myXml; TiXmlElement *pNode, *pTemp; // Load current state file if (myXml.LoadFile( lpstrFilename)) { // File already exists, so remove existing section from XML myXml.ResetPos(); pNode = myXml.FindFirstElem( lpstrSection); while (pNode) { pTemp = pNode; pNode = myXml.FindNextElem( lpstrSection, pTemp); myXml.DeleteElem( pTemp); } } // Add new section myXml.ResetPos(); if (!FormatXML( &myXml, lpstrSection)) return FALSE; // Save state file if (!myXml.SaveFile( lpstrFilename)) return FALSE; return TRUE; }
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(); }
void ClusterMapLink::SaveLinkData(string _sUUID,string _dUUID,string filename) { char buf[50];//used for conversion operations CMarkup LinkXml; LinkXml.AddElem( "LinkData" ); sprintf(buf,"%s",_sUUID.c_str()); LinkXml.SetAttrib("SrcUUID",buf); sprintf(buf,"%s",_dUUID.c_str()); LinkXml.SetAttrib("DstUUID",buf); LinkXml.Save(filename); }
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; }
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()); } }
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(); }
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;*/ } } }
void XmlProxyCallback::_sendXmlResponse(const CMarkup &outXml, const std::string & sEncode) { std::map<std::string, TTransFunc>::iterator it = _mapTransFunc.find(sEncode); TC_HttpResponse response; if (it != _mapTransFunc.end()) { std::string s; bool bTrans = (it->second)(outXml.GetDoc(), s); response.setResponse(200, "OK", bTrans?s:outXml.GetDoc()); } else { response.setResponse(200, "OK", outXml.GetDoc()); } response.setConnection("close"); std::string buffer = response.encode(); getCurrent()->sendResponse(buffer.data(), buffer.size()); }
/* 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; }