当前位置: 首页>>代码示例>>C++>>正文


C++ StringReplace函数代码示例

本文整理汇总了C++中StringReplace函数的典型用法代码示例。如果您正苦于以下问题:C++ StringReplace函数的具体用法?C++ StringReplace怎么用?C++ StringReplace使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StringReplace函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: StringReplace

string CKeyAutoBinder::ConvertBooleanSymbols(const string& text) const
{
	string newText = text;
	newText = StringReplace(newText, "&&", " and ");
	newText = StringReplace(newText, "||", " or ");
	newText = StringReplace(newText, "!",  " not ");
	return newText;
}
开发者ID:genxinzou,项目名称:svn-spring-archive,代码行数:8,代码来源:KeyAutoBinder.cpp

示例2: EscapeXMLName

std::string
EscapeXMLName(std::string strOut)
{
	std::string strEscapedOut=strOut;
	StringReplace(strEscapedOut, "<", "&lt;");
	StringReplace(strEscapedOut, ">", "&gt;");
	return strEscapedOut;
}
开发者ID:JohannKollmann,项目名称:blackstar-engine,代码行数:8,代码来源:SaveSystem.cpp

示例3: encoding_html

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;
}
开发者ID:sea-kg,项目名称:seakgChrysocyonParser,代码行数:9,代码来源:main.cpp

示例4: GetFileNameByDate

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);
}
开发者ID:KerwinMa,项目名称:eggxp_view,代码行数:10,代码来源:AuthServerListener.cpp

示例5: ExecuteGetText

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");
}
开发者ID:amate,项目名称:unChromium,代码行数:10,代码来源:cefclient.cpp

示例6: zuluCryptGetLoopDeviceAddress

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 ) ;
		}
	}
}
开发者ID:ParrotSec,项目名称:zulucrypt,代码行数:55,代码来源:create_loop_device.c

示例7: castle

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();
    }
}
开发者ID:gerstrong,项目名称:fheroes2plus,代码行数:55,代码来源:buildinginfo.cpp

示例8: ExecuteGetSource

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");
}
开发者ID:amate,项目名称:unChromium,代码行数:11,代码来源:cefclient.cpp

示例9: StringReplace

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
}
开发者ID:sprunk,项目名称:spring,代码行数:11,代码来源:FileSystem.cpp

示例10: RegGetString

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;
}
开发者ID:rollingthunder,项目名称:VBoxHeadlessTray,代码行数:54,代码来源:VBoxMachine.cpp

示例11: RunGetSourceTest

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:
开发者ID:ZackLin,项目名称:libcef,代码行数:12,代码来源:cefclient.cpp

示例12: eagleeye

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);
}
开发者ID:mastermind-,项目名称:free-heroes,代码行数:53,代码来源:battle_main.cpp

示例13: infobox

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;
}
开发者ID:Sappharad,项目名称:modizer,代码行数:13,代码来源:in_openmpt.cpp

示例14: ExtraValue

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;
}
开发者ID:mastermind-,项目名称:free-heroes,代码行数:14,代码来源:artifact.cpp

示例15: OnStateChange

    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");
      }
    }
开发者ID:amate,项目名称:unChromium,代码行数:14,代码来源:cefclient.cpp


注:本文中的StringReplace函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。