Ejemplo n.º 1
0
/**
 *	获取阴影的路径,不可消除和可以消除的用同一个阴影
 *	拼接方法是在最后面加_shadow.
 *	例如:test.png
 *	变成:test_shadow.png
 *	实际上(cocos2dx方面):test_shadow-ipadhd.png
 */
string ResourcePathManager::getShadowPath(string path)
{
    string p = path;
    //replace_all_distinct(p,"_no.png",".png"); // 不在让不可消除的也用这个图片了,每一个都用不同的图片
    replace_all_distinct(p,".png","_shadow.png");
    return p;
}
Ejemplo n.º 2
0
string DataUtils::changeWordStrToJson(string str)
{
	std::string::size_type pos = str.find("[{", 0);
	str = str.replace(0, pos+1, "{");
	pos = str.find("}]", 0);
	std::string::size_type lastPos = pos;
	str = str.replace(lastPos, str.length() - lastPos, "}");
	str = replace_all_distinct(str, "\r\n", "");
	return str;
}
Ejemplo n.º 3
0
void text_convert_to(HWND hdlgP, int id)
{
    HWND hctl = GetDlgItem(hdlgP, IDC_ET_INTEGRATE_TEXT);
    int len = Edit_GetTextLength(hctl);
    tmalloc_free_lock lock(len + 1);
    Edit_GetText(hctl, lock.buf, lock.len);
    std::string str(ansi_2_utf8(lock.buf));

    std::stringstream err;
    try {
        help::parse_text(str);

    } catch (game::error& e) {
        err << e.message;

    } catch (utils::invalid_utf8_exception&) {
        err << _("Encounter unknown format character!");
    }
    if (!err.str().empty()) {
        err << "\n\n";
        err << _("Exist grammar error, don't execute converting!");
        MessageBox(NULL, utf8_2_ansi(err.str().c_str()), "Error", MB_OK | MB_ICONWARNING);
        return;
    }

    if (id == IDM_CONVERT_NORMAL) {
        // \\n\r\n to \r\n
        replace_all_distinct(str, null_str, "\\n\r\n", "\r\n");
    } else if (id == IDM_CONVERT_POEDIT) {
        // \r\n to \\n\r\n
        replace_all_distinct(str, "\\n", "\r\n", "\\n\r\n");
    } else {
        return;
    }
    Edit_SetText(GetDlgItem(hdlgP, IDC_ET_INTEGRATE_TEXT), utf8_2_ansi(str));
}
Ejemplo n.º 4
0
//str: GloudGame#10_0_1_132#9627#MAGICBOX
DeviceData::DataVector DeviceData::splitString(std::string str)
{
	DeviceData::DataVector deviceData;
	if (!str.empty())
	{
		std::vector<std::string> result = split(str, "#");
		if (result.size() == 4 && result[JMDNS_STRING::GLOUG_TAG].compare("GloudGame") == 0)
		{
			deviceData.gloudTag = result[JMDNS_STRING::GLOUG_TAG];
			deviceData.ip = replace_all_distinct(result[JMDNS_STRING::IP], "_", ".");
			deviceData.port = result[JMDNS_STRING::PORT];
			deviceData.name = result[JMDNS_STRING::DEVICE_NAME];
		}
	}
	return deviceData;
}
Ejemplo n.º 5
0
bool CSplitInfo::BeLangDif(string strName)
{
	string strReal = strName;
	int pos = strName.rfind("/");
	if (pos != -1)
	{
		strReal = strName.substr(pos+1,strName.length()-pos-1);
	}
	string strLuaCfgExtend = CSplitInfo::GetInst()->GetLuaCfgExtend();
	replace_all_distinct(strReal,strLuaCfgExtend,".txt",0);
	map<string,map<ESaveInfor,string> >::iterator iter = m_mapFileSaveInfo.begin();
	for (;iter != m_mapFileSaveInfo.end();++iter)
	{
		string strLang = iter->second[eSIF_LangName];
		if (strLang == strReal)
		{
			return true;
		}
	}
	return false;
}
Ejemplo n.º 6
0
bool GameMediator::loadGameTextFile()
{
	bool bRet = false;
	do
	{
		tinyxml2::XMLDocument document;
		string filename;
		switch (m_languageType)
		{
		case LanguageType::CHINESE:
			filename = FileUtils::getInstance()->fullPathForFilename("config/GameText_Chinese.xml");
			break;
		case LanguageType::ENGLISH:
			filename = FileUtils::getInstance()->fullPathForFilename("config/GameText_English.xml");
			break;
		default:
			filename = FileUtils::getInstance()->fullPathForFilename("config/GameText_English.xml");
			break;
		}

        document.LoadFile(filename.c_str());
		XMLElement* root = document.RootElement();
		CC_BREAK_IF(!root);

		for (XMLElement* surface1 = root->FirstChildElement("Text"); surface1 != NULL;
		surface1 = surface1->NextSiblingElement("Text"))
		{
            string str = string(surface1->GetText());
            string oldStr = "\\n";
            string newStr = "\n";
			m_mGameText.insert(pair<string, string>(surface1->Attribute("id"), replace_all_distinct(str, oldStr, newStr)));
		}

		bRet = true;
	} while (false);
	return bRet;
}
Ejemplo n.º 7
0
CHZDLReport::CHZDLReport(TTime starttime, TTime endtime, WContainerWidget *parent):
	WTable(parent)
{
	m_starttime = starttime;
	m_endtime = endtime;

	//生成xml文件的名字
	szXSLReportName = "HZDL";
	szXSLReportName += starttime.Format();
	szXSLReportName += endtime.Format();
	replace_all_distinct(szXSLReportName, ":", "");
	replace_all_distinct(szXSLReportName, " ", "");
	replace_all_distinct(szXSLReportName, ".", "");
	replace_all_distinct(szXSLReportName, "-", "");
	replace_all_distinct(szXSLReportName, "\\", "");
	replace_all_distinct(szXSLReportName, "/", "");
	szXSLReportName += ".xls";

	initForm();
}
Ejemplo n.º 8
0
Archivo: Database.cpp Proyecto: wkcn/HR
void Database::Execute(string com){
	size_t tail = com.size()-1;
	if (tail != 0 && isBlank(com[tail]))--tail;
	com = com.substr(0,tail+1);//删去末尾空格
	size_t poi = 0;//读取字符串的指针
	string ex = NextStr(com,poi,' ');//输入的指令操作名

	if (IgnoreLU(ex,"sort")){
		vector<string> vs;
		StrSplit(com,vs,' ');
		comparer.clear();
		for (size_t i = 1;i<vs.size();++i){
			char c = vs[i][vs[i].size()-1];
			bool has = false;
			bool z = 0;
			if (c == '-'){
				z = 1;
				has = true;
			}else if (c == '+')has=true;
			string s = vs[i].substr(0,vs[i].size()-size_t(has));
			//cout << s<<"--"<<vs[i]<<endl;
			if (IgnoreLU(s,"id"))comparer.push(ID,z);
			else if (IgnoreLU(s,"name"))comparer.push(NAME,z);
			else if (IgnoreLU(s,"kind"))comparer.push(KIND,z);
			else if (IgnoreLU(s,"age"))comparer.push(AGE,z);
			else if (IgnoreLU(s,"state"))comparer.push(STATE,z);
			else if (IgnoreLU(s,"sales"))comparer.push(SALES,z);
			else if (IgnoreLU(s,"events"))comparer.push(EVENTS,z);
		}
		cout << "当前排序优先级别为" << endl;
		comparer.show();
		Show();
	}else if (IgnoreLU(ex,"update") || IgnoreLU(ex,"set")){
		size_t wi = com.rfind("where");
		if (wi == string::npos){
			cout << "请填写过滤条件,过滤器的使用方法在帮助文档里。" << endl;
		}else{
			Exp* oldFilter = viewFilter;
			string oldName = filterName;
			try{
				if (com[poi] == '*'){
					filterName = "*";
					viewFilter = 0;
				}else{
					string condition = com.substr(wi+5);
					viewFilter = Build(condition);
					filterName = condition; 
				}
			}catch(const char *s){
				cout << s << endl;
			}

			Show();
			
			vector<Staff *> vs;
			GetStaffList(vs,viewFilter);

			string choice;
			while(true){
				cout << "是否要对这些数据进行操作?yes:是,no:否" << endl;
				cin >> choice;
				if (IgnoreLU(choice,"yes") || choice == "是"){
					SVM vm;
					SBuild bu;
					streamx ss;
					//srand(size_t(time(0)));
					bu.SetStream(ss);
					JumpSpace(com,poi);
					string temp = com.substr(poi,wi - poi);//使用SLang的语法糖 #展开
					string sl;
					for(auto &c:temp){
						if (c != ' ')sl+=c;
					}

					//Macro展开
					
					replace_all_distinct(sl,"=active","=0");
					replace_all_distinct(sl,"=resign","=1");
					replace_all_distinct(sl,"=leave","=2");
					replace_all_distinct(sl,"job=","kind=");
					

					replace_all_distinct(sl,"=salesmanager","=3");
					replace_all_distinct(sl,"=manager","=2");
					replace_all_distinct(sl,"=salesman","=1");
					//cout << sl << endl;
					

					ss << "#" << sl;
					//cout << "Slang"<<sl<<endl;
					SExp *e = bu.Build();//操作生成

					for (auto &ps:vs){
						vm.SetVar("id",ps->GetID());
						vm.SetVar("kind",int(ps->GetKind()));
						vm.SetVar("age",ps->GetAge());
						vm.SetVar("state",ps->GetState());
						vm.SetVar("manager_id",-1);
						if (ps->GetKind() == SALESMAN){
							SalesMan *psm = dynamic_cast<SalesMan*>(ps);
							vm.SetVar("manager_id",psm->GetManagerID());
						}
						vm.SetVar("sales",ps->GetAchievement().sales);
						vm.SetVar("events",ps->GetAchievement().events);

						vm.Eval(e);

						int id = vm.GetVar("id");
						int kind = vm.GetVar("kind");
						int age = vm.GetVar("age");
						int state = vm.GetVar("state");
						int manager_id = vm.GetVar("manager_id");
						int sales = vm.GetVar("sales");
						int events = vm.GetVar("events");

						if (age < 200 && state <= 2 && kind <= 3 && kind>=1){
							ps -> ChangeAge(age);
							ps -> ChangeState(STAFF_STATE(state));
							if (ps -> GetKind() == SALESMAN){
								SalesMan *p = dynamic_cast<SalesMan*>(ps);
								p -> SetManagerID(manager_id);
								p -> SetSales(sales);
							}else{
								Manager *p = dynamic_cast<Manager*>(ps);
								p -> SetEvents(events);
							}
							//太麻烦,不做批量更改id了
							//牵连太大
							
							if (ps -> GetKind() != kind){
								//更改kind
								if (ps -> GetKind() == SALESMAN){
									SalesMan *p = dynamic_cast<SalesMan*>(ps);
									slaves[p -> GetManagerID()].erase(p -> GetID());
								}
								Staff *o;
								SalesMan *sa;
								Manager *ma;
								SalesManager *sam;
								switch(kind){
									case STAFF://forbid warning
									case SALESMAN:
										sa = new SalesMan(ps->GetID(),ps->GetName(),ps->GetAge(),ps->GetState());
										sa -> SetSales(sales);
										sa -> SetManagerID(manager_id);
										o = dynamic_cast<Staff*>(sa);break;
									case MANAGER:
										ma = new Manager(ps->GetID(),ps->GetName(),ps->GetAge(),ps->GetState());
										ma -> SetEvents(events);
										o = dynamic_cast<Staff*>(ma);break;
									case SALESMANAGER:
										sam = new SalesManager(ps->GetID(),ps->GetName(),ps->GetAge(),ps->GetState());
										sam -> SetEvents(events);
										o = dynamic_cast<Staff*>(sam);break;

								}
								int oid = ps->GetID();
								o -> ChangeID(oid);
								o -> ChangeName(ps->GetName());
								o -> ChangeAge(ps->GetAge());
								o -> ChangeState(ps->GetState());
								delete staffs[oid];
								staffs[oid] = o;
								Update();
							}
							/*
							if (ps -> GetID() != id && staffs.count(id)==0){
								int oid = ps -> GetID();
								//更新存储列表和从属关系
								staffs[id] = staffs[oid];
								staffs.erase(oid);
								slaves[id] = slaves[oid];
								slaves.erase(oid);
								Update();//低效率解决方案
							}*/
						}else{
							cout << "员工:" << ps->GetName() << "(" << ps->GetID() << ")更新数据时出现错误" << endl;
						}

					}

					cout << "更新操作完毕" << endl;
					filterName = oldName;
					viewFilter = oldFilter;
					changed = true;
					Update();
					Show();
					break;

				}else{
					if (IgnoreLU(choice,"no") || choice == "否"){
						cout << "已取消操作" <<endl;
						filterName = oldName;
						viewFilter = oldFilter;
						break;
					}else{
					}
				}
			}

		}
	}else if (IgnoreLU(ex,"filter") || ex == "f"){
Ejemplo n.º 9
0
void CChineseWordStatistic::DoStatistic( string& strFileName )
{
	int32 nCount = 0;
	int nPos = strFileName.rfind("/");
	string strRealFileName = strFileName;
	if (nPos != -1)
	{
		strRealFileName = strFileName.substr(nPos + 1, strFileName.length() - nPos - 1);
	}
	string strLuaCfgExtend = CSplitInfo::GetInst()->GetLuaCfgExtend();
	replace_all_distinct(strRealFileName, strLuaCfgExtend, ".txt", 0);
	strRealFileName = "F:/WordCount/" + strRealFileName;
	ofstream ofsWordCount(strRealFileName.c_str());

	int nPos1 = -1;
	nPos1 = strFileName.find("langsrc/");
	nPos1 += strlen("langsrc/");
	int nPos2 = -1;
	if (nPos1 != -1)
	{
		nPos2 = strFileName.find("/", nPos1 + 1);
	}
	string strDirName = strFileName.substr(nPos1, nPos2 - nPos1);
	s_mapWordCount2.insert(make_pair(strDirName, hash_set<string>()));
	s_mapWordCount3.insert(make_pair(strDirName, hash_set<string>()));
	
	string strTotalWordTxtFileName1 = "F:/WordCount1/" + strDirName + "1.txt";
	string strTotalWordTxtFileName2 = "F:/WordCount1/" + strDirName + "2.txt";
	string strTotalWordTxtFileName3 = "F:/WordCount1/" + strDirName + "3.txt";
	
	if (s_hmapOfstream1.find(strDirName) == s_hmapOfstream1.end())
	{
		s_hmapOfstream1.insert(make_pair(strDirName, new ofstream(strTotalWordTxtFileName1.c_str())));
	}
	if (s_hmapOfstream2.find(strDirName) == s_hmapOfstream2.end())
	{
		s_hmapOfstream2.insert(make_pair(strDirName, new ofstream(strTotalWordTxtFileName2.c_str())));
	}
	if (s_hmapOfstream3.find(strDirName) == s_hmapOfstream3.end())
	{
		s_hmapOfstream3.insert(make_pair(strDirName, new ofstream(strTotalWordTxtFileName3.c_str())));
	}

	COriFileOperate oriFile(strFileName);
	//map<EFieldType,VecElementCol> mapSourceFileData;
	//ReadFileToMap(strFileName, mapSourceFileData);
	//VecElementCol& vecElementCol = mapSourceFileData[eFT_BotBegin];
	int nRowNum = (int)oriFile.GetRowCount();
	int nColNum = 0;
	if (nRowNum)
	{
		nColNum = (int)oriFile.GetColCountByRow(0);
	}
	string strContent;
	for (int nRow = 0; nRow < nRowNum; nRow++)
	{
		strContent = oriFile.GetDataByRowCol(nRow,0);
		for (int nCol = 1; nCol < nColNum; nCol++)
		{
			if (!oriFile.BeNumber(nRow,nCol))
			{
				strContent = oriFile.GetDataByRowCol(nRow,nCol);
				string strTemp = "";

				bool nFlag = false;
				for (int i = 0; i < (int)strContent.length(); i++)
				{
					if (strContent[i] > 128 || strContent[i] < 0)
					{
						nFlag = true;
						//break;
						s_nCount++;
						i++;
					}
				}
				if (nFlag)
				{
					string strContentCopy = strContent.substr(1, strContent.length() - 2);
					*(s_hmapOfstream1[strDirName]) << strContentCopy ;
					s_ofsWordCount1 << strContentCopy;

					if (strContentCopy.length() >= 12)
					{
						s_mapWordCount2[strDirName].insert(strContentCopy);
						s_hsetWordCount2.insert(strContentCopy);
					}
					else
					{
						*(s_hmapOfstream2[strDirName]) << strContentCopy;
						s_ofsWordCount2 << strContentCopy;
					}

					s_mapWordCount3[strDirName].insert(strContentCopy);
					s_hsetWordCount3.insert(strContentCopy);
				}
			}
		}
	}
}
Ejemplo n.º 10
0
void CChineseWordStatistic::FolderCompare(string& strOne,string& strAnother)
{
	m_vecTemp.clear();
	wstring wstrOne = gbk_to_utf16(strOne);
	wstring wstrAnother = gbk_to_utf16(strAnother);
	FileTreeWalk(wstrOne.c_str(), RecordFilelist, NULL);
	m_vecCompareOne = m_vecTemp;
	m_vecTemp.clear();
	FileTreeWalk(wstrAnother.c_str(), RecordFilelist, NULL);
	m_vecCompareAnother = m_vecTemp;
	vector<pair<string,int> > vecResult;
	vector<string> vecCommon;
	vector<string> vecOneExist;
	vector<string> vecAnotherExist;
	for (int i=0;i<(int)m_vecCompareOne.size();++i)
	{
		string strFile = m_vecCompareOne[i];
		replace_all_distinct(strFile,strOne,strAnother,0);
		ifstream inFile(strFile.c_str());
		if (!inFile)
		{
			vecOneExist.push_back(m_vecCompareOne[i]);
		}
		else
		{
			string strTemp = strFile;
			replace_all_distinct(strTemp,strAnother,"",0);
			vecCommon.push_back(strTemp);
			vector<string>::iterator iter;
			iter = find(m_vecCompareAnother.begin(),m_vecCompareAnother.end(),strFile);
			m_vecCompareAnother.erase(iter);
		}
		inFile.close();
	}
	int resultOne = 0;
	int resultTwo = 0;
	int resultThree = 0;
	vecAnotherExist = m_vecCompareAnother;
	ofstream out("compareResult.txt");
	out<<strOne<<"路径存在,而"<<strAnother<<"不存在文件统计信息"<<endl;
	for (int i=0;i<(int)vecOneExist.size();++i)
	{
		int staticOne,staticTwo;
		StaticsLanaguage(vecOneExist[i],staticOne,staticTwo);
		out<<vecOneExist[i]<<"带标点符号字数为="<<staticOne<<" 不带标点符号字数为="<<staticTwo<<endl;
		resultOne += staticOne;
	}
	out<<"文件路径未变化,前后文字变化统计信息"<<endl;
	for (int i=0;i<(int)vecCommon.size();++i)
	{
		string strFile = vecCommon[i];
		string strOld = strOne + strFile;
		string strNew = strAnother + strFile;
		int oldStaticOne,oldStaticAno;
		int newStaticOne,newStaticAno;
		StaticsLanaguage(strOld,oldStaticOne,oldStaticAno);
		StaticsLanaguage(strNew,newStaticOne,newStaticAno);
		out<<strFile<<"\t上次发送字数信息:"<<"带标点符号字数为="<<oldStaticOne<<" 不带标点符号字数为="<<oldStaticAno<<endl
			<<"\t新版本字数信息:"<<"带标点符号字数为="<<newStaticOne<<" 不带标点符号字数为="<<newStaticAno<<endl
			<<"\t相差字数="<<newStaticOne-oldStaticOne<<endl;
		resultTwo +=newStaticOne-oldStaticOne;
	}
	out<<"新增加文件文字统计信息"<<endl;
	for (int i=0;i<(int)vecAnotherExist.size();++i)
	{
		int staticOne,staticTwo;
		StaticsLanaguage(vecAnotherExist[i],staticOne,staticTwo);
		out<<vecAnotherExist[i]<<"带标点符号字数为="<<staticOne<<" 不带标点符号字数为="<<staticTwo<<endl;
		resultThree += staticOne;
	}
	out<<endl<<endl;
	out<<"新版本下不存在的文件,但发给老外时存在,文字共:"<<resultOne<<endl;
	out<<"新老版本相同文件,总字数增加="<<resultTwo<<endl;
	out<<"新增加的文件,总字数="<<resultThree;
	out.close();
}
Ejemplo n.º 11
0
bool CConfig::Load()
{

    const char* pFileName;
    pFileName = SERVER_CONFIG_FILE;
    if (NULL == pFileName)
    {
        return false;
    }

    ifstream fin(pFileName);
    if (!fin.is_open())
    {
        return false;
    }

    string strLine;
    string strSection;
    string strName;
    string strValue;
    string::size_type begin = 0;
    string::size_type end = 0;

    while (!fin.eof())
    {
        strLine.clear();
        begin = end = 0;

        getline(fin, strLine, '\n');
        if (strLine.empty() || strLine[0] == '\r' || strLine[0] == '\n' || strLine[0] == '#')
        {
            continue;
        }

        if (strLine[0] == '[')
        {
            end = strLine.find_first_of("]", begin);
            if (string::npos != end)
            {
                strSection = strLine.substr(begin+1, end-1);
            }
            continue;
        }

        if (!Parse(strLine, strName, strValue))
        {
            continue;
        }


        if ("COMMON" == strSection)
        {
            if ("email_address" == strName)
            {
                m_strEmailAddress = strValue;
                m_strEmailAddress = replace_all_distinct(m_strEmailAddress, "/", " ");
//                printf("m_strEmailAddress:%s\r\n", m_strEmailAddress.c_str());
            }
            else if("log_level" == strName){
                m_wLogLevel = atoi(strValue.c_str());
            }
        }
        else if ("WEB_SERVER_INFO" == strSection)
        {
            if ("svr_port" == strName)
            {
                m_wWebSvrPort = atoi(strValue.c_str());
            }
            else if("web_ip" == strName)
            {
                m_dwWebIp = ntohl(inet_addr(strValue.c_str()));
            }
            else if ("web_port" == strName)
            {
                m_wWebPort = atoi(strValue.c_str());
            }
            else if ("http_api_head" == strName)
            {
                m_strHttpApiHead = strValue;
            }
            else if ("http_api_url" == strName)
            {
                m_strHttpApiUrl = strValue;
//                printf("m_strHttpApiUrl:%s\r\n", strValue.c_str());
            }
        }
    }

    fin.close();
    return true;
}