コード例 #1
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();

}
コード例 #2
0
ファイル: InstrOffsetData.cpp プロジェクト: Andydingbing/git
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;
}
コード例 #3
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;
}
コード例 #4
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();
}
コード例 #5
0
ファイル: Serialize.cpp プロジェクト: zidane168/AutoPlay
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;
}
コード例 #6
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;
	
}
コード例 #7
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;
}
コード例 #8
0
ファイル: CRequestXmlMessage.cpp プロジェクト: ray-x/SMonitor
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;
}
コード例 #9
0
ファイル: Serialize.cpp プロジェクト: zidane168/AutoPlay
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"";
}
コード例 #10
0
bool CSoftInstallMessage::treatMessage(const NetMessage& netMessage, CMessageFactory* pFactory, SocketContext* clientSocket)
{
	m_bAddSuccess = false;
	CMarkup xml;
	if(xml.SetDoc(netMessage.msgBuffer))
	{
		if(xml.FindChildElem("Info"))
		{
			xml.IntoElem();
			QString strId = QString::fromStdString(xml.GetAttrib("Id"));
			m_strName = QString::fromStdString(xml.GetAttrib("Name"));
			m_strVersion = QString::fromStdString(xml.GetAttrib("Version"));

			 /*&&  判断当前提交的软件名称,版本号是否与软件列表里的一致 */
			if(DatabaseManager::Instance()->IsSoftwareExist(m_strName, m_strVersion) && !DataManagerThread->IsSoftInstallInfoExist(strId, m_strName, m_strVersion))
			{
				//接上,软件列表为共用列表,不从数据库判断,节省效率 yhb

				DataMotion dataMotion;
				dataMotion.msg = netMessage.msgHead;
				dataMotion.clientInfo.id = strId;
				dataMotion.softwareInfo.name = m_strName;
				dataMotion.softwareInfo.version = m_strVersion;
				DataManagerThread->AddDataMotion(dataMotion);
			}
			xml.OutOfElem();
			m_bAddSuccess = true;
		}
	}

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

	return true;
}
コード例 #11
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();

}
コード例 #12
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");
}
コード例 #13
0
ファイル: GameSetting.cpp プロジェクト: kuna/LR2csv
void GameSetting::LoadSetting() {
	TCHAR settingXMLPath[256];
	CSVFile::GetAbsolutePath(L"settings.xml", settingXMLPath);
	
	CMarkup xml;
	if (xml.Load( settingXMLPath )) {
		xml.FindElem();
		xml.IntoElem();
		while (xml.FindElem(L"scene")) {
			if (xml.GetAttrib(L"name").compare(L"select") == 0) {
				xml.IntoElem();
				xml.FindElem();
				wcscpy(scene.select, xml.GetData().c_str());
				xml.OutOfElem();
			} else if (xml.GetAttrib(L"name").compare(L"decide") == 0) {
				xml.IntoElem();
				xml.FindElem();
				wcscpy(scene.decide, xml.GetData().c_str());
				xml.OutOfElem();
			} else if (xml.GetAttrib(L"name").compare(L"play") == 0) {
				xml.IntoElem();
				xml.FindElem();
				wcscpy(scene.play, xml.GetData().c_str());
				xml.OutOfElem();
			} else if (xml.GetAttrib(L"name").compare(L"result") == 0) {
				xml.IntoElem();
				xml.FindElem();
				wcscpy(scene.result, xml.GetData().c_str());
				xml.OutOfElem();
			} else if (xml.GetAttrib(L"name").compare(L"keysetting") == 0) {
				xml.IntoElem();
				xml.FindElem();
				wcscpy(scene.keysetting, xml.GetData().c_str());
				xml.OutOfElem();
			} else if (xml.GetAttrib(L"name").compare(L"skinselect") == 0) {
				xml.IntoElem();
				xml.FindElem();
				wcscpy(scene.skinselect, xml.GetData().c_str());
				xml.OutOfElem();
			}
		}

		while (xml.FindElem(L"setting")) {
			if (xml.GetAttrib(L"name").compare(L"screen")==0) {
				xml.IntoElem();
				xml.FindElem(L"width");
				screen.width = _wtoi(xml.GetData().c_str());
				xml.FindElem(L"height");
				screen.height = _wtoi(xml.GetData().c_str());
				xml.OutOfElem();
			} else if (xml.GetAttrib(L"name").compare(L"key")==0) {
				// TODO: save key
			} else if (xml.GetAttrib(L"name").compare(L"play")==0) {
				xml.IntoElem();
				xml.FindElem(L"speed");
				play.speed = _wtoi(xml.GetData().c_str());
				xml.FindElem(L"shutter");
				play.shutter = _wtoi(xml.GetData().c_str());
				xml.OutOfElem();
			}
		}
	}
}
コード例 #14
0
ファイル: Serialize.cpp プロジェクト: zidane168/AutoPlay
bool  XMLSerialized::Deserialize(){
	if(m_mapping.size()==0)
		return false;
	CMarkup * xml = new CMarkup();
	if(!xml->Load(sFileName)){
		delete xml;
		xml = NULL;
		return false;
	}
	std::map<int,DATA*>::const_iterator item;
	for(item=  m_mapping.begin(); item != m_mapping.end(); item ++){
		DATA* data = item->second;
	
		if(data->_tagType== TagType::Attribute){
			if(FindPath(data->_parent,xml)){
				xml->OutOfElem();
				switch(data->_dataType){
					case DataType::Int:
						(*(int*)data->_value) = _ttoi(xml->GetAttrib(data->_tagName));
					break;
					case DataType::Bool:
						(*(bool*)data->_value) = (bool)_ttoi(xml->GetAttrib(data->_tagName));
					break;
					case DataType::ByteArray:
						StringToByteArray(xml->GetAttrib(data->_tagName),L"|",(byte*)data->_value);
					break;
					case DataType::IntArray:
						StringToIntArray(xml->GetAttrib(data->_tagName),L"|",(int*)data->_value);
					break;
					case DataType::String:
						(*(CString*)data->_value) = (CString)(xml->GetAttrib(data->_tagName));
					break;
				}
			}
		}
		if(data->_tagType== TagType::Element && data->_dataType!=DataType::None){
			if(FindPath(data->_parent,xml)){
				if(xml->FindElem(data->_tagName)){
					switch(data->_dataType){
						case DataType::Int:
							(*(int*)data->_value) = _ttoi(xml->GetData());
						break;
						case DataType::Bool:
							(*(bool*)data->_value) = (bool)_ttoi(xml->GetData());
						break;
						case DataType::ByteArray:
							StringToByteArray(xml->GetData(),L"|",(byte*)data->_value);
						break;
						case DataType::IntArray:
							StringToIntArray(xml->GetData(),L"|",(int*)data->_value);
						break;
						case DataType::String:
							(*(CString*)data->_value) = (CString)(xml->GetData());
						break;
					}
				}
			}
		}
	}
	delete xml;
	xml = NULL;
	return true;
}
コード例 #15
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;
}
コード例 #16
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;
}
コード例 #17
0
ファイル: EventInfo.cpp プロジェクト: Bitfall/AppWhirr-client
void CEventInfo::ParseEvent(CMarkup & xml, CEventData * pEventData)
{
	// Declare variables
	CString sTemp;
	CEventActionBase * pAction;

	// Jump into element
	xml.IntoElem();

	// While we find actions
	while (xml.FindElem(_T("ACTION")))
	{
		// Check what action we need to parse
		sTemp = xml.GetAttrib(_T("type"));		

		// Run action
		if (sTemp == EVENTACTION_RUN)
		{
			pAction = ParseActionRun(xml);
		}

		// Close action
		if (sTemp == EVENTACTION_CLOSE)
		{
			// We know we should close
			pAction = new CEventActionClose();
		}

		// Set mode action
		if (sTemp == EVENTACTION_SETMODE)
		{
			pAction = ParseActionSetMode(xml);
		}

		// Skip next task action
		if (sTemp == EVENTACTION_SKIPNEXTTASK)
		{
			// We know we should skip next task
			pAction = new CEventActionSkipNextTask();
		}

		// Start next task action
		if (sTemp == EVENTACTION_STARTNEXTTASK)
		{
			// We know we should start next task
			pAction = new CEventActionStartNextTask();
		}

		// Close application action
		if (sTemp == EVENTACTION_CLOSEAPPLICATION)
		{
			pAction = ParseActionCloseApplication(xml);
		}

		// Show notifier action
		if (sTemp == EVENTACTION_SHOWNOTIFIER)
		{
			pAction = ParseActionShowNotifier(xml);
		}

		// Add the action to the event
		if (pEventData != NULL)
			pEventData->AddAction(pAction);
	}

	// Jump out of element
	xml.OutOfElem();
}
コード例 #18
0
BOOL CPackage::load( LPCTSTR lpstrFile)
{
	CString csBuffer;
	CMarkup myXml;
	TCHAR	cPath[_MAX_PATH], 
			cCommand[255];

	try
	{
		// Load "info" file content
		if (!myXml.LoadFile( lpstrFile))
			return FALSE;
		myXml.ResetPos();
		if (!myXml.FindFirstElem( _T( "DOWNLOAD")))
			return FALSE;
		m_csID = myXml.GetAttrib( _T( "ID"));
		csBuffer = myXml.GetAttrib( _T( "PRI"));
		if (csBuffer.IsEmpty())
			return FALSE;
		m_uPriority = _ttoi( csBuffer);
		m_csAction = myXml.GetAttrib( _T( "ACT"));
		m_csName = myXml.GetAttrib( _T( "NAME"));
		m_csDigest = myXml.GetAttrib( _T( "DIGEST"));
		m_csLocation = myXml.GetAttrib( _T( "LOC"));
		m_csProtocol = myXml.GetAttrib( _T( "PROTO"));
		csBuffer = myXml.GetAttrib( _T( "FRAGS"));
		if (csBuffer.IsEmpty())
			return FALSE;
		m_uFrags = _ttoi( csBuffer);
		m_csDigestAlgo = myXml.GetAttrib( _T( "DIGEST_ALGO"));
		m_csDigestAlgo.MakeLower();
		m_csDigestEncode = myXml.GetAttrib( _T( "DIGEST_ENCODE"));
		m_csDigestEncode.MakeLower();

		if (m_csAction == OCS_DOWNLOAD_ACTION_STORE)
		{
			// Store only action, get path where to store data
			if( !ExpandEnvironmentStrings( myXml.GetAttrib( _T( "PATH")), cPath, _MAX_PATH ))
			{
				return FALSE;
			}
			else
			{
				m_csPath = cPath;
				m_csPath.Replace( _T( "/"), _T( "\\"));
				m_csPath.Replace( _T( "INSTALL_PATH"), getInstallFolder());
			}
		}
		else
		{
			// Put into path tmp folder to unzip package
			if (GetTempPath( _MAX_PATH, m_csPath.GetBufferSetLength( _MAX_PATH+1)) == 0)
				return FALSE;
			m_csPath.ReleaseBuffer();
			m_csPath.AppendFormat( _T( "\\%s.OCS"), m_csID);
		}

		if (m_csAction == OCS_DOWNLOAD_ACTION_LAUNCH)
		{
			// In LAUNCH, command is in the NAME atribute
			if( !ExpandEnvironmentStrings( m_csName, cCommand, 255 ))
			{
				return FALSE;
			}
			else
			{
				m_csCommand = cCommand;
				m_csCommand.Replace( _T( "INSTALL_PATH"), getInstallFolder());
			}
		}
		else
		{
			// In Store or Execute mode, command is in the COMMAND attribute
			if( !ExpandEnvironmentStrings( myXml.GetAttrib( _T( "COMMAND")), cCommand, 255 ))
			{
				return FALSE;
			}
			else
			{
				m_csCommand = cCommand;
				m_csCommand.Replace( _T( "INSTALL_PATH"), getInstallFolder());
			}
		}
		m_csGardeFou = myXml.GetAttrib( _T( "GARDEFOU"));
		
		/* User notification */
		csBuffer = myXml.GetAttrib( _T( "NOTIFY_USER"));
		// Ensure non empty value
		if (!csBuffer.IsEmpty())
			m_bNotifyUser = (_ttoi( csBuffer) != 0);
		else
			m_bNotifyUser = FALSE;
		if (m_bNotifyUser)
		{
			csBuffer = myXml.GetAttrib( _T( "NOTIFY_COUNTDOWN"));
			// Ensure non empty value
			if (csBuffer.IsEmpty())
				csBuffer = COMMAND_TIMEOUT_DEFAULT;
			m_uNotifyCountdown = _ttoi( csBuffer);
			m_csNotifyText = myXml.GetAttrib( _T( "NOTIFY_TEXT"));
			if (myXml.GetAttrib( _T( "NOTIFY_CAN_ABORT")))
				m_bNotifyCanAbort = ( _ttoi( myXml.GetAttrib( _T( "NOTIFY_CAN_ABORT"))) != 0);
			else
				m_bNotifyCanAbort = FALSE;
			if (myXml.GetAttrib( _T( "NOTIFY_CAN_DELAY")))
				m_bNotifyCanDelay = ( _ttoi( myXml.GetAttrib( _T( "NOTIFY_CAN_DELAY"))) != 0);
			else
				m_bNotifyCanDelay = FALSE;
		}
		csBuffer = myXml.GetAttrib( _T( "NEED_DONE_ACTION"));
		// Ensure non empty value
		if (!csBuffer.IsEmpty())
			m_bNeedDoneAction = (_ttoi( csBuffer) != 0);
		else
			m_bNeedDoneAction = FALSE;
		if (m_bNeedDoneAction)
		{
			m_csNeedDoneActionText = myXml.GetAttrib( _T( "NEED_DONE_ACTION_TEXT"));
		}
		m_csSchedule = myXml.GetAttrib( _T( "SCHEDULE"));
		m_csPostCmd = myXml.GetAttrib( _T( "POSTCMD"));
	}
	catch( CException *pEx)
	{
		pEx->Delete();
		return FALSE;
	}
	return TRUE;
}
コード例 #19
0
ファイル: main.cpp プロジェクト: fdxuwei/daq
int main()
{
	CMarkup cfg;
	if(!cfg.Load("daq.conf"))
		err_exit("load config file failed");
	while(cfg.FindElem("device"))
	{
		string devid;
		devid = cfg.GetAttrib("id");
		if(devid.empty())
			err_exit("device must have an id");
		// add device
		dev *devp = new dev(devid);
		dev_pool::instance().add_dev(devp);
		//
		cfg.IntoElem();
		while(cfg.FindElem("acqer"))
		{
			string proto;
			proto = cfg.GetAttrib("proto");
			if(proto.empty())
				err_exit("acqer must have a proto");

			if(proto == "modbus")
			{
				acqer_modbus *amp = NULL;
				string ip;
				string serialportstr;
				string devaddrstr;
				uint8 devaddr;
				devaddrstr = cfg.GetAttrib("devaddr");
				if(devaddrstr.empty())
					err_exit("modbus acqer must have devaddr");
				devaddr = str2uint(devaddrstr);
				ip = cfg.GetAttrib("ip");
				if(!ip.empty())
				{
//					acqer_modbus_tcp *amcp = new acqer_modbus_tcp;
//					acqer_modbus = acqer_modbus_tcp;
				}
				else if(!((serialportstr = cfg.GetAttrib("serialport")).empty()))
				{
					uint16 port;
					uint32 baudrate;
					uint8 databits;
					uint8 stopbits;
					uint8 flowctl;
					uint8 parity;
					string stemp;
					port = str2uint(serialportstr);
					// baudrate
					stemp = cfg.GetAttrib("baudrate");
					if(stemp.empty())
						err_exit("serialport must hav baudrate");
					baudrate = str2uint(stemp);
					// databits
					stemp = cfg.GetAttrib("databits");
					if(stemp.empty())
						err_exit("serialport must have databits");
					databits = str2uint(stemp);
					// stopbits
					stemp = cfg.GetAttrib("stopbits");
					if(stemp.empty())
						err_exit("serialport must have stopbits");
					stopbits = str2uint(stemp);
					// flowctl
					stemp = cfg.GetAttrib("flowctl");
					if(stemp.empty())
						err_exit("serialport must have flowctl");
					flowctl = str2uint(stemp);

					//create acqer
					acqer_modbus_serialport *amsp = new acqer_modbus_serialport(devaddr, port, baudrate, databits, stopbits, flowctl, parity);
					amp = amsp;
					devp->add_acqer(amsp);
					serialport_pool::instance().add_serialport(port);
					// items
					cfg.IntoElem();
					while(cfg.FindElem("item"))
					{
						int itemid;
						string itemname;
						unsigned int itemcycle;
						uint8 funcode;
						uint8 startaddr;
						uint8 count;
						uint8 offset;
						string expr;
						string stemp;
						string valtypestr;
						ITEM_VALUE_TYPE ivt;
						// create item
						item_modbus *imp = NULL;
						stemp = cfg.GetAttrib("id");
						if(stemp.empty())
							err_exit("item must have id");
						itemid = str2int(stemp);
						/* name */
						itemname = cfg.GetAttrib("name");
						/* cycle */
						stemp = cfg.GetAttrib("cycle");
						if(stemp.empty())
							err_exit("item must have cycle");
						itemcycle = str2uint(stemp);
						/* expression */
						expr = cfg.GetAttrib("expr");
						/* valuetype */
						valtypestr = cfg.GetAttrib("valtype");
						if(valtypestr.empty())
							valtypestr = "integer";
						if(valtypestr == "float")	
							ivt = IVT_FLOAT;
						else if(valtypestr == "string")	
							ivt = IVT_STRING;
						else
							ivt = IVT_INTEGER;
						/* modbus items */
						stemp = cfg.GetAttrib("funcode");
						if(!stemp.empty())
						{
							funcode = str2uint(cfg.GetAttrib("funcode"));
							/* startaddr */
							stemp = cfg.GetAttrib("startaddr");
							if(stemp.empty())
								err_exit("modbus item must have startaddr");
							startaddr = str2uint(stemp);
							// count
							stemp = cfg.GetAttrib("count");
							if(stemp.empty())
								err_exit("modbus item must have count");
							count = str2uint(stemp);
							// offset
							stemp = cfg.GetAttrib("offset");
							offset = str2uint(stemp);
							imp = new item_modbus(itemid, itemname, itemcycle, expr, ivt, false, funcode, startaddr, offset, count);
						}
						else
						{
							imp = new item_modbus(itemid, itemname, itemcycle, expr, ivt);
						}
						// add an item to acqer
						amp->add_item(imp);
					} // cfg.Find("item")
					cfg.OutOfElem();

					//test expression configuration
					if(!amp->calc_items())
						err_exit("wrong expression config");
				}
				else
				{
					err_exit("modbus acqer must have an ip or com");
				}
			}// modbus
			else
			{
				err_exit("protocol %s not supported",  proto.c_str());
			}
		}
		cfg.OutOfElem();
	}
	// acq loop
	while(run)
	{
		dev_pool::instance().acq_once();
		dev_pool::instance().handle_item();
		sleep(1);
	}

	err_exit("exited");
	return 0;
}
コード例 #20
0
VehicleType::VehicleType(MCD_STR xmlstring)
 : /*idname_("UNDEFINED"), id_(-1),*/ year_startcurrent_(true), year_start_(0), //Default values
 year_randomuptocurrent_(false), year_addrandom_(0), year_add_(0), displaycolor_(true),
 longname_("UNDEFINED"), shortname_("UNDEF"), 
 steal_difficultytofind_(1), steal_juice_(0), steal_extraheat_(0),
 sensealarmchance_(0), touchalarmchance_(0), availableatshop_(true), price_(1234), sleeperprice_(1111), 
 armormidpoint_(50), lowarmormin_(4), lowarmormax_(6), higharmormin_(0), higharmormax_(2),
 drivebonus_(0), drivebonus_factor_(1), drivebonus_limit1_(8), drivebonus_limit2_(99), 
 dodgebonus_(0), dodgebonus_factor_(1), dodgebonus_limit1_(8), dodgebonus_limit2_(99), 
 attackbonus_driver_(-2), attackbonus_passenger_(0)
{
   id_ = number_of_vehicletypes++;

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

   idname_ = xmlfile.GetAttrib("idname");
   if (idname_ == "")
      idname_ = "LACKS IDNAME " + tostring(id_);

   xmlfile.IntoElem();

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

      if (element == "year")
      {
         xmlfile.IntoElem();

         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "start_at_current_year")
            {
               int b = stringtobool(xmlfile.GetData());
               if (b == 1)
                  year_startcurrent_ = true;
               else if (b == 0)
                  year_startcurrent_ = false;
               /*else
                  std::cerr << "Invalid boolean value for vehicle type " << idname
                            << "::year::start_at_current_year: " << xmlfile.GetData() << std::endl;*/
            }
            else if (element == "start_at_year")
               year_start_ = atoi(xmlfile.GetData());
            else if (element == "add_random_up_to_current_year")
            {
               int b = stringtobool(xmlfile.GetData());
               if (b == 1)
                  year_randomuptocurrent_ = true;
               else if (b == 0)
                  year_randomuptocurrent_ = false;
               /*else
                  std::cerr << "Invalid boolean value for vehicle type " << idname
                            << "::year::add_random_up_to_current_year: " << xmlfile.GetData() << std::endl;*/
            }
            else if (element == "add_random")
               year_addrandom_ = atoi(xmlfile.GetData());
            else if (element == "add")
               year_add_ = atoi(xmlfile.GetData());
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::year: "
                         << element << std::endl;*/
         }

         xmlfile.OutOfElem();
      }
      else if (element == "colors")
      {
         xmlfile.IntoElem();
         //std::string color;
         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "color")
            {
               color_.push_back(xmlfile.GetData());
            }
            else if (element == "display_color")
            {
               int b = stringtobool(xmlfile.GetData());
               if (b == 1)
                  displaycolor_ = true;
               else if (b == 0)
                  displaycolor_ = false;
               /*else
                  std::cerr << "Invalid boolean value for vehicle type " << idname
                            << "::colors::display_color: " << xmlfile.GetData() << std::endl;*/
            }
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::colors: "
                         << element << std::endl;*/
         }
         xmlfile.OutOfElem();
      }
      else if (element == "drivebonus")
      {
         xmlfile.IntoElem();
         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "base")
               drivebonus_ = atoi(xmlfile.GetData());
            else if (element == "skillfactor")
               drivebonus_factor_ = atof(xmlfile.GetData());
            else if (element == "softlimit")
               drivebonus_limit1_ = atoi(xmlfile.GetData());
            else if (element == "hardlimit")
               drivebonus_limit2_ = atoi(xmlfile.GetData());
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::stealing: "
                         << element << std::endl;*/
         }
         xmlfile.OutOfElem();
      }
      else if (element == "dodgebonus")
      {
         xmlfile.IntoElem();
         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "base")
               dodgebonus_ = atoi(xmlfile.GetData());
            else if (element == "skillfactor")
               dodgebonus_factor_ = atof(xmlfile.GetData());
            else if (element == "softlimit")
               dodgebonus_limit1_ = atoi(xmlfile.GetData());
            else if (element == "hardlimit")
               dodgebonus_limit2_ = atoi(xmlfile.GetData());
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::stealing: "
                         << element << std::endl;*/
         }
         xmlfile.OutOfElem();
      }
      else if (element == "attackbonus")
      {
         xmlfile.IntoElem();
         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "driver")
               attackbonus_driver_ = atoi(xmlfile.GetData());
            else if (element == "passenger")
               attackbonus_passenger_ = atoi(xmlfile.GetData());
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::stealing: "
                         << element << std::endl;*/
         }
         xmlfile.OutOfElem();
      }
      else if (element == "longname")
         longname_ = xmlfile.GetData();
      else if (element == "shortname")
      {
         shortname_ = xmlfile.GetData();
         if (len(shortname_) > 7)
            shortname_.resize(7); //Only seven characters allowed for shortname_.
      }
      else if (element == "stealing")
      {
         xmlfile.IntoElem();
         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "difficulty_to_find")
               steal_difficultytofind_ = atoi(xmlfile.GetData());
            else if (element == "juice")
               steal_juice_ = atoi(xmlfile.GetData());
            else if (element == "extra_heat")
               steal_extraheat_ = atoi(xmlfile.GetData());
            else if (element == "sense_alarm_chance")
               sensealarmchance_ = atoi(xmlfile.GetData());
            else if (element == "touch_alarm_chance")
               touchalarmchance_ = atoi(xmlfile.GetData());
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::stealing: "
                         << element << std::endl;*/
         }
         xmlfile.OutOfElem();
      }
      else if (element == "armor")
      {
         xmlfile.IntoElem();
         while(xmlfile.FindElem())
         {
            element = xmlfile.GetTagName();

            if (element == "low_armor_min")
               lowarmormin_ = atoi(xmlfile.GetData());
            else if (element == "low_armor_max")
               lowarmormax_ = atoi(xmlfile.GetData());
            else if (element == "high_armor_min")
               higharmormin_ = atoi(xmlfile.GetData());
            else if (element == "high_armor_max")
               higharmormax_ = atoi(xmlfile.GetData());
            else if (element == "armor_midpoint")
               armormidpoint_ = atoi(xmlfile.GetData());
            /*else
               std::cerr << "Unknown element for vehicle type " << idname << "::stealing: "
                         << element << std::endl;*/
         }
         xmlfile.OutOfElem();
      }
      else if (element == "available_at_dealership")
      {
         int b = stringtobool(xmlfile.GetData());
         if (b == 1)
            availableatshop_ = true;
         else if (b == 0)
            availableatshop_ = false;
         /*else
            std::cerr << "Invalid boolean value for vehicle type " << idname
                      << "::available_at_dealership: " << xmlfile.GetData() << std::endl;*/
      }
      else if (element == "price")
         price_ = atoi(xmlfile.GetData());
      else if (element == "sleeperprice")
         sleeperprice_ = atoi(xmlfile.GetData());
      /*else
         std::cerr << "Unknown element for vehicle type " << idname << ": " << element
                   << std::endl;*/
   }

   if (len(color_) == 0)
      color_.push_back("Translucent"); //Default.

   //xmlfile.OutOfElem();
}
コード例 #21
0
ファイル: db_leos.cpp プロジェクト: Fluffiest/splayer
void db_leos::GetResults(window_config *wcfg, std::vector<lyric_data>* results, tstring title, tstring artist, tstring album)
{

  title = ReplaceString(_T("&"), _T("and"), title);
  artist = ReplaceString(_T("&"), _T("and"), artist);
  title = ReplaceString(_T("pt."), _T("part"), title);
  artist = ReplaceString(_T("pt."), _T("part"), artist);

  tstring out;

  out = _T("api_search.php?auth=foo_uie_lyrics2&artist=");
  out += CURLEncode::Encode(artist);
  out += _T("&songtitle=");
  out += CURLEncode::Encode(title);

  tstring remoteText;

  if (!ReadInternetText(remoteText, _T("FOO_UIE_LYRICS2"), _T("api.leoslyrics.com"), 80, out, _T(""), false, wcfg->cfg_timeout, wcfg))
    return ;

  CMarkup xml;

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

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

    while (xml.FindChildElem(_T("result")))
    {
      xml.IntoElem();

      if (!_wcsicmp(_T("true"), xml.GetAttrib(_T("exactMatch")).c_str()))
      {
        tstring hid = xml.GetAttrib(_T("hid"));

        if (!hid.empty())
        {

          lyric_data newData(wcfg);
          newData.SourceType = ST_INTERNET;
          newData.IsLoaded = false;
          newData.IsTimestamped = false;
          newData.matchArtist = _T("");
          newData.matchAlbum = _T("");
          newData.matchTitle = title;
          newData.db = this;
          newData.OnlineService = LD_LEOS;
          newData.Quality = Q_MEDIUM;
          newData.Source = _T("http://api.leoslyrics.com/api_lyrics.php?auth=foo_uie_lyrics2&hid=");
          newData.Source += hid;

          results->push_back(newData);
        }
      }

      xml.OutOfElem();
    }

    xml.OutOfElem();
  }

}