Ejemplo n.º 1
0
string CKeyAutoBinder::ConvertBooleanSymbols(const string& text) const
{
	string newText = text;
	newText = StringReplace(newText, "&&", " and ");
	newText = StringReplace(newText, "||", " or ");
	newText = StringReplace(newText, "!",  " not ");
	return newText;
}
Ejemplo n.º 2
0
std::string
EscapeXMLName(std::string strOut)
{
	std::string strEscapedOut=strOut;
	StringReplace(strEscapedOut, "<", "&lt;");
	StringReplace(strEscapedOut, ">", "&gt;");
	return strEscapedOut;
}
Ejemplo n.º 3
0
UnicodeString encoding_html(UnicodeString str)
{
  str = StringReplace(str, "&", "&amp;", TReplaceFlags() << rfReplaceAll);
  str = StringReplace(str, "<", "&lt;", TReplaceFlags() << rfReplaceAll);
  str = StringReplace(str, ">", "&gt;", TReplaceFlags() << rfReplaceAll);
  str = StringReplace(str, "\r\n", "\n", TReplaceFlags() << rfReplaceAll);
  str = StringReplace(str, "\r", "", TReplaceFlags() << rfReplaceAll);
  return str;
}
Ejemplo n.º 4
0
String			GetFileNameByDate(String name, String ext)
{
	String curTime = Now();
    TReplaceFlags   flag;
    flag << rfReplaceAll;
	curTime = StringReplace(curTime, "/", "_", flag);
	curTime = StringReplace(curTime, ":", "_", flag);
	curTime = StringReplace(curTime, " ", "_", flag);
	return	FormatStr("%s_%s.%s", name, curTime, ext);
}
Ejemplo n.º 5
0
static void ExecuteGetText(CefRefPtr<CefFrame> frame)
{
  std::string text = frame->GetText();
  text = StringReplace(text, "<", "&lt;");
  text = StringReplace(text, ">", "&gt;");
  std::stringstream ss;
  ss << "<html><body>Text:" << "<pre>" << text
      << "</pre></body></html>";
  frame->LoadString(ss.str(), "http://tests/gettext");
}
Ejemplo n.º 6
0
char * zuluCryptGetLoopDeviceAddress( const char * device )
{
	char * z = NULL ;
	const char * e ;

	string_t st = StringVoid ;
	string_t xt = StringVoid ;

	int i ;
	int r ;

	z = zuluCryptLoopDeviceAddress_1( device ) ;

	if( z == NULL ){
		return NULL ;
	}else{
		st = String( "" ) ;

		for( i = 0 ; i < 255 ; i++ ){

			StringReplace( st,"/sys/block/loop" ) ;
			StringAppendInt( st,i ) ;

			xt = StringGetFromVirtualFile( StringAppend( st,"/loop/backing_file" ) ) ;

			e = StringRemoveRight( xt,1 ) ;
			r = StringsAreEqual( e,z ) ;

			StringDelete( &xt ) ;

			if( r ){

				StringReplace( st,"/dev/loop" ) ;
				e = StringAppendInt( st,i ) ;

				if( StringsAreNotEqual( device,e ) ){

					break ;
				}
			}else{
				StringReset( st ) ;
			}
		}

		StringFree( z ) ;

		if( StringIsEmpty( st ) ){

			StringDelete( &st ) ;
			return NULL ;
		}else{
			return StringDeleteHandle( &st ) ;
		}
	}
}
Ejemplo n.º 7
0
BuildingInfo::BuildingInfo(const Castle & c, building_t b) : castle(c), building(b), area(0, 0, 135, 57), bcond(ALLOW_BUILD)
{
    if(IsDwelling()) building = castle.GetActualDwelling(b);

    building = castle.isBuild(b) ? castle.GetUpgradeBuilding(b) : b;

    if(BUILD_TAVERN == building && Race::NECR == castle.GetRace())
	building = Settings::Get().PriceLoyaltyVersion() ? BUILD_SHRINE : BUILD_TAVERN;

    bcond = castle.CheckBuyBuilding(building);

    // generate description
    if(BUILD_DISABLE == bcond)
	description = GetConditionDescription();
    else
    if(IsDwelling())
    {
	description = _("The %{building} produces %{monster}.");
        StringReplace(description, "%{building}", Castle::GetStringBuilding(building, castle.GetRace()));
        StringReplace(description, "%{monster}", StringLower(Monster(castle.GetRace(), building).GetMultiName()));
    }
    else
    	description = Castle::GetDescriptionBuilding(building, castle.GetRace());

    switch(building)
    {
	case BUILD_WELL:
    	    StringReplace(description, "%{count}", Castle::GetGrownWell());
	    break;

	case BUILD_WEL2:
    	    StringReplace(description, "%{count}", Castle::GetGrownWel2());
	    break;

	case BUILD_CASTLE:
	case BUILD_STATUE:
	case BUILD_SPEC:
	{
	    const payment_t profit = ProfitConditions::FromBuilding(building, castle.GetRace());
	    StringReplace(description, "%{count}", profit.gold);
	    break;
	}

	default: break;
    }

    // fix area for capratin
    if(b == BUILD_CAPTAIN)
    {
	const Sprite & sprite = AGG::GetICN(ICN::Get4Captain(castle.GetRace()),
						(building & BUILD_CAPTAIN ? 1 : 0));
	area.w = sprite.w();
	area.h = sprite.h();
    }
}
Ejemplo n.º 8
0
static void ExecuteGetSource(CefRefPtr<CefFrame> frame)
{
  // Retrieve the current page source and display.
  std::string source = frame->GetSource();
  source = StringReplace(source, "<", "&lt;");
  source = StringReplace(source, ">", "&gt;");
  std::stringstream ss;
  ss << "<html><body>Source:" << "<pre>" << source
      << "</pre></body></html>";
  frame->LoadString(ss.str(), "http://tests/getsource");
}
Ejemplo n.º 9
0
std::string FileSystem::GetNormalizedPath(const std::string& path) {

	std::string normalizedPath = StringReplace(path, "\\", "/"); // convert to POSIX path separators

	normalizedPath = StringReplace(normalizedPath, "/./", "/");
	normalizedPath = spring::regex_replace(normalizedPath, spring::regex("[/]{2,}"), "/");
	normalizedPath = spring::regex_replace(normalizedPath, spring::regex("[^/]+[/][.]{2}"), "");
	normalizedPath = spring::regex_replace(normalizedPath, spring::regex("[/]{2,}"), "/");

	return normalizedPath; // maybe use FixSlashes here
}
Ejemplo n.º 10
0
HRESULT CVBoxMachine::Exec(const wchar_t* pszCommandLine, DWORD* ppid, HANDLE* phProcess)
{
	// Get from the InstallDir registry key
	CUniString strVBoxPath;
	RegGetString(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Oracle\\VirtualBox", L"InstallDir", strVBoxPath);

	// If that fails, assume program files...
	if (strVBoxPath.IsEmpty())
	{
		// Work out path to vbox
		GetSpecialFolderLocation(CSIDL_PROGRAM_FILES, L"Oracle\\VirtualBox", false, strVBoxPath);
	}

	// Remove trailing backslash
	RemoveTrailingBackslash(strVBoxPath.GetBuffer());

	CUniString str=StringReplace(pszCommandLine, L"{vboxdir}", strVBoxPath, true);
	str=StringReplace(str, L"{machinename}", m_strMachineName, true);

	// Setup startup info
	STARTUPINFO si;
	memset(&si, 0, sizeof(si));
	si.cb=sizeof(si);

	// Setup process info
	PROCESS_INFORMATION pi;
	memset(&pi, 0, sizeof(pi));

	// Create the process
	if (!CreateProcess(NULL, str.GetBuffer(), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
	{
		return HRESULT_FROM_WIN32(GetLastError());
	}


	// Close/return handles
	if (phProcess)
	{
		phProcess[0]=pi.hProcess;
	}
	else
	{
		CloseHandle(pi.hProcess);
	}
	CloseHandle(pi.hThread);

	// Return the process ID
	if (ppid)
	{
		ppid[0]=pi.dwProcessId;
	}

	return S_OK;
}
Ejemplo n.º 11
0
void RunGetSourceTest(CefRefPtr<CefBrowser> browser) {
  class Visitor : public CefStringVisitor {
   public:
    explicit Visitor(CefRefPtr<CefBrowser> browser) : browser_(browser) {}
    virtual void Visit(const CefString& string) OVERRIDE {
      std::string source = StringReplace(string, "<", "&lt;");
      source = StringReplace(source, ">", "&gt;");
      std::stringstream ss;
      ss << "<html><body>Source:<pre>" << source << "</pre></body></html>";
      browser_->GetMainFrame()->LoadString(ss.str(), "http://tests/getsource");
    }
   private:
Ejemplo n.º 12
0
void Battle::EagleEyeSkillAction(HeroBase & hero, const SpellStorage & spells, bool local)
{
    if(spells.empty() ||
	!hero.HaveSpellBook()) return;

    SpellStorage new_spells;
    new_spells.reserve(10);

    const Skill::Secondary eagleeye(Skill::Secondary::EAGLEEYE, hero.GetLevelSkill(Skill::Secondary::EAGLEEYE));

    // filter spells
    for(SpellStorage::const_iterator
	it = spells.begin(); it != spells.end(); ++it)
    {
	const Spell & sp = *it;
    	if(!hero.HaveSpell(sp))
	{
	    switch(eagleeye.Level())
	    {
		case Skill::Level::BASIC:
		    // 20%
		    if(3 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp);
		    break;
		case Skill::Level::ADVANCED:
		    // 30%
		    if(4 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp);
		    break;
		case Skill::Level::EXPERT:
		    // 40%
		    if(5 > sp.Level() && eagleeye.GetValues() >= Rand::Get(1, 100)) new_spells.push_back(sp);
		    break;
		default: break;
    	    }
	}
    }

    // add new spell
    for(SpellStorage::const_iterator
	it = new_spells.begin(); it != new_spells.end(); ++it)
    {
	const Spell & sp = *it;
	if(local)
	{
	    std::string msg = _("Through eagle-eyed observation, %{name} is able to learn the magic spell %{spell}.");
	    StringReplace(msg, "%{name}", hero.GetName());
	    StringReplace(msg, "%{spell}", sp.GetName());
	    Game::PlayPickupSound();
	    Dialog::SpellInfo("", msg, sp);
	}
    }

    hero.AppendSpellsToBook(new_spells, true);
}
Ejemplo n.º 13
0
static int infobox( const in_char * fn, HWND hWndParent ) {
	if ( fn && fn[0] != '\0' && self->cached_filename != std::wstring(fn) ) {
		try {
			std::ifstream s( fn, std::ios::binary );
			openmpt::module mod( s );
			libopenmpt::plugin::gui_show_file_info( hWndParent, TEXT(SHORT_TITLE), StringReplace( generate_infotext( fn, mod ), L"\n", L"\r\n" ) );
		} catch ( ... ) {
		}
	} else {
		libopenmpt::plugin::gui_show_file_info( hWndParent, TEXT(SHORT_TITLE), StringReplace( self->cached_infotext, L"\n", L"\r\n" ) );
	}
	return 0;
}
Ejemplo n.º 14
0
std::string Artifact::GetDescription(void) const
{
    u32 count = ExtraValue();
    std::string str = GetPluralDescription(*this, count);

    StringReplace(str, "%{name}", GetName());

    if(id == Artifact::SPELL_SCROLL)
        StringReplace(str, "%{spell}", Spell(ext).GetName());
    else
        StringReplace(str, "%{count}", count);

    return str;
}
Ejemplo n.º 15
0
    virtual void OnStateChange(CefRefPtr<CefWebURLRequest> requester, 
                               RequestState state)
    {
      REQUIRE_UI_THREAD();
      if (state == WUR_STATE_DONE) {
        buffer_ = StringReplace(buffer_, "<", "&lt;");
        buffer_ = StringReplace(buffer_, ">", "&gt;");
        std::stringstream ss;
        ss << "<html><body>Source:<pre>" << buffer_ << "</pre></body></html>";

        browser_->GetMainFrame()->LoadString(ss.str(),
            "http://tests/weburlrequest");
      }
    }
Ejemplo n.º 16
0
void doc2txt::convertPro(AnsiString WordFile,AnsiString PathPutTxt)
{
	TStringList* word=new TStringList;
	String filename = WordFile;
	Variant  vVarApp,vVarDoc,vVarParagraphs,vVarParagraph;
	AnsiString resolution = ExtractFileExt(filename);
	AnsiString str = StringReplace( ExtractFileName(filename),resolution,"",TReplaceFlags()<< rfReplaceAll << rfIgnoreCase);

	try
	{
		vVarApp=CreateOleObject("Word.Application");
	}
	catch(...)
	{
		MessageBox(0, "Не удачно получилось открыть Word", "Внимание", MB_OK);
		return;
	}

	vVarApp.OlePropertySet("Visible",false);
	vVarDoc = vVarApp.OlePropertyGet("Documents");
	vVarDoc.OleProcedure("Open", StringToOleStr(filename));
	vVarDoc = vVarDoc.OleFunction("Item",1);
	vVarDoc.OleProcedure("Activate");
	String s = vVarDoc.OlePropertyGet("Content").OlePropertyGet("Text");
	word->Add(s);
	word->SaveToFile( PathPutTxt + str +".txt" );
	vVarApp.OleProcedure("Quit");
	delete word;
}
Ejemplo n.º 17
0
char * zuluCryptGetALoopDeviceAssociatedWithAnImageFile( const char * path )
{
	int i ;
	string_t st = String( "" ) ;
	const char * e ;
	char * f ;

	for( i = 0 ; i < 255 ; i++ ){

		StringReplace( st,"/dev/loop" ) ;

		e = StringAppendInt( st,i ) ;

		f = zuluCryptLoopDeviceAddress_1( e ) ;

		if( StringsAreEqual( path,f ) ){

			StringFree( f ) ;

			return StringDeleteHandle( &st ) ;
		}else{
			StringFree( f ) ;
		}
	}

	StringDelete( &st ) ;
	return NULL ;
}
Ejemplo n.º 18
0
        // 注意: 没有使用CRT.
        bool SpawnDebuggerOnProcess(unsigned process_id)
        {
            wchar_t reg_value[1026];
            int len = arraysize(reg_value);
            if(RegReadString(HKEY_LOCAL_MACHINE,
                L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug",
                L"Debugger", reg_value, &len))
            {
                wchar_t command_line[1026];
                if(StringReplace(reg_value, process_id, command_line,
                    arraysize(command_line)))
                {
                    // 调试器存在也没关系, 只是附加到该进程会失败.
                    STARTUPINFO startup_info = { 0 };
                    startup_info.cb = sizeof(startup_info);
                    PROCESS_INFORMATION process_info = { 0 };

                    if(CreateProcess(NULL, command_line, NULL, NULL, FALSE, 0, NULL, NULL,
                        &startup_info, &process_info))
                    {
                        CloseHandle(process_info.hThread);
                        WaitForInputIdle(process_info.hProcess, 10000);
                        CloseHandle(process_info.hProcess);
                        return true;
                    }
                }
            }
            return false;
        }
Ejemplo n.º 19
0
void __fastcall TForm4::Button1Click(TObject *Sender)
{
AnsiString a_s = Form4->ADOQuery1->FieldByName("applicant_surname")->AsString;
AnsiString a_n = Form4->ADOQuery1->FieldByName("applicant_name")->AsString;
AnsiString a_p = Form4->ADOQuery1->FieldByName("applicant_patronymic")->AsString;

AnsiString csac = Trim(Form4->ADOQuery1->FieldByName("call_specialized_academic_council")->AsString);
//applicant_patronymic
AnsiString res_send = a_s+a_n+a_p+csac+"_1.csv";
res_send = StringReplace(res_send, " ", "_", TReplaceFlags()<<rfReplaceAll<<rfIgnoreCase);

Form4->SaveDialog1->FileName = res_send;

Form4->SaveDialog1->Title = "Save As";
if(Form4->ItemsFiles->Lines->Count > 0) {

        if (Form4->SaveDialog1->Execute()) {
                Form4->ItemsFiles->Lines->SaveToFile(SaveDialog1->FileName);
                Form4->ItemsFiles->Modified = false;
        }

} else {
 ShowMessage("Выберите диссертацию с таблицы!");
}

}
Ejemplo n.º 20
0
    void Shader::Init(const char *name, const Defines &defines, const Constants &constants)
    {
        string sn(name);
        sn += GetExtension();
        StringReplace(sn, "\\", "/");

        ifstream in(sn, ifstream::in);
        if(in)
        {
            stringstream strStream;
            strStream << in.rdbuf();
            string source(strStream.str());
            source.erase(source.find_last_of('}')+1, source.length());
            InsertDefines(source, defines);
            InsertConstants(source, constants);

            const string path = sn.substr(0, sn.find_last_of("/") + 1);
            ExpandIncludes(path, source);
            FindUniformBlocks(source);
            AddHeader(source);

            Init2(source.c_str(), name);
        }
        else {
            LOG(ERROR) << "[Shader::Init] No shader file found: " << sn;
        }
        in.close();
    }
Ejemplo n.º 21
0
void	Tree::ToPS(string target, double sizeX, double sizeY, double* mean, double* var, PolyNode* from)	{

	// tex output ?
	string texfile = target + ".tex";
	string appel = "cp " + auxpath + header + " " + texfile;
	system(appel.c_str());
	ofstream Tex_os(texfile.c_str(), IOS_APPEND);

	Tex_os << "\\begin{document}\n";
	Tex_os << "\\subsection*{" << StringReplace('_', " ", target) << "}\n\n";
	ToLatex(Tex_os, sizeX, sizeY, mean, var, from);
	Tex_os << "\\end{document}\n";
	Tex_os.close();

	string latex = "latex " + texfile + " > tmp";
	string dvips = "dvips -o " + target + ".ps " + target + " 2> tmp";
	string rm = "rm -f tmp";
	string rm2 = "rm -f " + target + ".aux";
	string rm3 = "rm -f " + target + ".log";
	string rm4 = "rm -f " + target + ".dvi";
	system(latex.c_str());
	system(dvips.c_str());
	system(rm.c_str());
	system(rm2.c_str());
	system(rm3.c_str());
	system(rm4.c_str());

}
Ejemplo n.º 22
0
static int open_loop_device_1( string_t * loop_device )
{
	string_t st = String( "" ) ;
	int i ;
	int fd ;
	const char * path ;
	struct loop_info64 l_info ;
	int r = 0 ;

	for( i = 0 ; i < 255 ; i++ ){

		StringReplace( st,"/dev/loop" ) ;
		path = StringAppendInt( st,i ) ;
		fd = open( path,O_RDONLY ) ;

		if( fd == -1 ){
			r = 0 ;
			break ;
		}
		if( ioctl( fd,LOOP_GET_STATUS64,&l_info ) != 0 ){

			if( errno == ENXIO) {
				*loop_device = StringCopy( st ) ;
				close( fd ) ;
				r = 1 ;
				break ;
			}
		}
		close( fd ) ;
	}
	StringDelete( &st ) ;
	return r ;
}
Ejemplo n.º 23
0
AnsiString _fastcall  TSaveObj::GetOrderby()
{
    //AnsiString tmp =FPrimaryKey[FPrimaryKey.Length-1];
    AnsiString tmp =FPrimaryKey[0];
    tmp = StringReplace(tmp, ';', ',', TReplaceFlags()<<rfReplaceAll);
    return tmp+" asc";
}
Ejemplo n.º 24
0
void Log::logToErrFile(const char* log)
{
	if(m_log_line==0 || m_err_log_file==NULL)
	{
		if(m_err_log_file)
			fclose(m_err_log_file);
		m_err_log_file=NULL;

		//日期变了,重设文件名
		char new_log_file_name[50] = {0};
		if(!IsDirExist("log"))
			MkDir("log");

		std::string log_time=StringReplace(StrTimeStamp(), ":", "_");
		sprintf_s(new_log_file_name, sizeof(new_log_file_name), "log\\error_%s.log", log_time.c_str());
		fopen_s(&m_err_log_file, new_log_file_name, "a");
		if(NULL==m_err_log_file)
			THROWNEXCEPT("create file:%s error.", new_log_file_name);
	}

	size_t count=strlen(log);
	size_t write_count=fwrite(log, sizeof(char), count, m_err_log_file);
	if(write_count!=count)
		THROWNEXCEPT("log to file error.");
}
Ejemplo n.º 25
0
//---------------------------------------------------------------------------
void __fastcall TForm1::FormKeyPress(TObject *Sender, char &Key)
{
if (Key == 32 && Timer1->Enabled )
        {
                Timer1->Enabled = false;
                Image2->Picture->LoadFromFile("pic\\"+MainPath  );
                AnsiString FileName=ExtractFileName(MainPath);
                AnsiString FileExt=ExtractFileExt(MainPath);
                TReplaceFlags   rf; 
                rf   <<   rfReplaceAll;
                FileName=StringReplace( FileName, FileExt, "",   rf   );
                ShowMessage("恭喜您抽中 "+FileName);
                ADOQuery1->SQL->Text = "delete from MainTable where path = '" + MainPath +"' AND id="+IntToStr(uid);
                ADOQuery1->ExecSQL() ;
                ADOQuery1->SQL->Text = "insert into SecondTable (path,id) values ('" + MainPath +"','"+ uid +"')";
                ADOQuery1->ExecSQL() ;

        }
else if (Key == 32 && Timer1->Enabled == false)
        {

        Timer1->Enabled = true;
        }

}
Ejemplo n.º 26
0
std::string BuildingInfo::GetConditionDescription(void) const
{
    std::string res;

    switch(bcond)
    {
	case NOT_TODAY:
	case NEED_CASTLE:
	    res = GetBuildConditionDescription(bcond);
	    break;

	case BUILD_DISABLE:
	    if(building == BUILD_SHIPYARD)
	    {
		res = _("Cannot build %{name} because castle is too far from water.");
		StringReplace(res, "%{name}", Castle::GetStringBuilding(BUILD_SHIPYARD, castle.GetRace()));
	    }
	    else
		res = "disable build.";
	    break;

	case LACK_RESOURCES:
	    res = _("Cannot afford %{name}");
    	    StringReplace(res, "%{name}", GetName());
	    break;

	case ALREADY_BUILT:
	    res = _("%{name} is already built");
	    StringReplace(res, "%{name}", GetName());
	    break;

	case REQUIRES_BUILD:
    	    res = _("Cannot build %{name}");
    	    StringReplace(res, "%{name}", GetName());
	    break;

	case ALLOW_BUILD:
    	    res = _("Build %{name}");
    	    StringReplace(res, "%{name}", GetName());
	    break;

	default: break;
    }

    return res;
}
Ejemplo n.º 27
0
//获取名称列表
vector<string>&implementsetting::GetNameList(string&& strBase)
{
    __nameList.clear();
    StringReplace(strBase," ","");
    __nameList = split(strBase,",");
    //引用就是对象的别名
    return dynamic_cast<vector<string>&>(__nameList);
}
Ejemplo n.º 28
0
void TextScanner::Replace( const string &thisStr, const string &thatStr )
{
	for (unsigned int i=0; i < m_lines.size(); i++)
	{
		StringReplace(thisStr, thatStr, m_lines[i]);
	}

}
Ejemplo n.º 29
0
void RedrawRatingInfo(TextSprite & sprite)
{
    sprite.Hide();
    std::string str(_("Rating %{rating}%"));
    StringReplace(str, "%{rating}", Game::GetRating());
    sprite.SetText(str);
    sprite.Show();
}
Ejemplo n.º 30
0
SIG_DESCRIPTOR *DescriptorFromPEiD(const char *Data)
{
	// This is identical to IDA, just replace '??' with '?'
	std::string newData(Data);
	StringReplace(newData, "??", "?");

	return DescriptorFromIDA(newData.c_str());
}