本文整理汇总了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;
}
示例2: EscapeXMLName
std::string
EscapeXMLName(std::string strOut)
{
std::string strEscapedOut=strOut;
StringReplace(strEscapedOut, "<", "<");
StringReplace(strEscapedOut, ">", ">");
return strEscapedOut;
}
示例3: encoding_html
UnicodeString encoding_html(UnicodeString str)
{
str = StringReplace(str, "&", "&", TReplaceFlags() << rfReplaceAll);
str = StringReplace(str, "<", "<", TReplaceFlags() << rfReplaceAll);
str = StringReplace(str, ">", ">", TReplaceFlags() << rfReplaceAll);
str = StringReplace(str, "\r\n", "\n", TReplaceFlags() << rfReplaceAll);
str = StringReplace(str, "\r", "", TReplaceFlags() << rfReplaceAll);
return str;
}
示例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);
}
示例5: ExecuteGetText
static void ExecuteGetText(CefRefPtr<CefFrame> frame)
{
std::string text = frame->GetText();
text = StringReplace(text, "<", "<");
text = StringReplace(text, ">", ">");
std::stringstream ss;
ss << "<html><body>Text:" << "<pre>" << text
<< "</pre></body></html>";
frame->LoadString(ss.str(), "http://tests/gettext");
}
示例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 ) ;
}
}
}
示例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();
}
}
示例8: ExecuteGetSource
static void ExecuteGetSource(CefRefPtr<CefFrame> frame)
{
// Retrieve the current page source and display.
std::string source = frame->GetSource();
source = StringReplace(source, "<", "<");
source = StringReplace(source, ">", ">");
std::stringstream ss;
ss << "<html><body>Source:" << "<pre>" << source
<< "</pre></body></html>";
frame->LoadString(ss.str(), "http://tests/getsource");
}
示例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
}
示例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;
}
示例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, "<", "<");
source = StringReplace(source, ">", ">");
std::stringstream ss;
ss << "<html><body>Source:<pre>" << source << "</pre></body></html>";
browser_->GetMainFrame()->LoadString(ss.str(), "http://tests/getsource");
}
private:
示例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);
}
示例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;
}
示例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;
}
示例15: OnStateChange
virtual void OnStateChange(CefRefPtr<CefWebURLRequest> requester,
RequestState state)
{
REQUIRE_UI_THREAD();
if (state == WUR_STATE_DONE) {
buffer_ = StringReplace(buffer_, "<", "<");
buffer_ = StringReplace(buffer_, ">", ">");
std::stringstream ss;
ss << "<html><body>Source:<pre>" << buffer_ << "</pre></body></html>";
browser_->GetMainFrame()->LoadString(ss.str(),
"http://tests/weburlrequest");
}
}