本文整理汇总了C++中replaceAll函数的典型用法代码示例。如果您正苦于以下问题:C++ replaceAll函数的具体用法?C++ replaceAll怎么用?C++ replaceAll使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了replaceAll函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mtx
void LuaCore::runLuaByEvent(LuaContainer* container, const LuaEvent& event)
{
{
RsStackMutex mtx(_mutex); /******* LOCKED MUTEX *****/
// clear old parameter
luaL_dostring(L, "args = nil");
// set parameter
lua_newtable(L);
int top = lua_gettop(L);
QStringList keys = event.dataParm->allKeys();
for(QStringList::ConstIterator it = keys.begin(); it != keys.end(); it++)
{
QString key = *it;
QString type = key.mid(0, 3);
//std::cout << "[Lua] runByEvent adding type " << type.toStdString() << " key is " << key.toStdString() << std::endl;
if(!(type == "str" || type == "int" || type == "u32" || type != "u64"))
continue;
QString name = key.mid(3);
QVariant value = event.dataParm->value(key);
//std::cout << "[Lua] runByEvent adding " << name.toStdString() << " with " << value.toString().toStdString() << std::endl;
lua_pushfstring(L, name.toStdString().c_str());
if(type == "str") {
// PANIC: unprotected error in call to Lua API (invalid option '%1' to 'lua_pushfstring')
///TODO proper fix
std::string s = value.toString().toStdString();
replaceAll(s, "%", "");
lua_pushfstring(L, s.c_str());
}
else if(type == "int")
lua_pushinteger(L, value.toInt());
else if(type == "u32")
lua_pushinteger(L, value.toUInt());
else if(type == "u64")
lua_pushinteger(L, value.toULongLong());
lua_settable(L, top);
}
lua_setglobal(L, "args");
}
emit appendLog(QObject::tr("triggered script: ") + container->getName());
runLuaByString(container->getCode());
}
示例2: while
bool TranslationManager::translateFile(const std::string &fileName,
PoDict *const dict,
StringVect &lines)
{
if (!dict || fileName.empty())
return false;
int contentsLength;
const ResourceManager *const resman = ResourceManager::getInstance();
char *fileContents = static_cast<char*>(
resman->loadFile(fileName, contentsLength));
if (!fileContents)
{
logger->log("Couldn't load file: %s", fileName.c_str());
return false;
}
std::string str = std::string(fileContents, contentsLength);
size_t oldPos1 = std::string::npos;
size_t pos1;
while ((pos1 = str.find("<<")) != std::string::npos)
{
if (pos1 == oldPos1)
break; // detected infinite loop
const size_t pos2 = str.find(">>", pos1 + 2);
if (pos2 == std::string::npos)
break;
const std::string key = str.substr(pos1 + 2, pos2 - pos1 - 2);
const std::string key2 = "<<" + str.substr(
pos1 + 2, pos2 - pos1 - 2) + ">>";
const std::string val = dict->getStr(key);
// logger->log("key:" + key);
replaceAll(str, key2, val);
oldPos1 = pos1;
}
std::istringstream iss(str);
std::string line;
while (getline(iss, line))
lines.push_back(line);
free(fileContents);
return true;
}
示例3: print_to_file
void print_to_file(const char * userfile, int lineno, const char* tag,
T &obj) {
std::string msg;
//llvm::errs()<<"I am called in line no"<<__LINE__;
llvm::raw_string_ostream Msg(msg);
Msg << obj;
std::string objS = Msg.str();
replaceAll(objS, "\n", mendl);
tagset.insert(tag);
(*OS) << DIV(tag) << BOLD("<br>Tag : ") << RED(tag) << NBSP << CALLINFO
<< NBSP << BOLD(" Data : <br>") << objS << EDIV;
(*OS).flush();
}
示例4: findAndReplace
string SingleResultItem::toString() {
string outputString=thisTemplate;
// ResCachedURL
string cachedURL="{$appPath}?d={$datasource}&i={$resID}";
findAndReplace(&cachedURL, "scriptname", "{$appPath}");
findAndReplace(&cachedURL, "datasource", "{$datasource}");
findAndReplace(&cachedURL, "id", "{$resID}");
replaceAll(&outputString, "{%ResCachedURL%}", cachedURL);
// ResURL
// if the URL is "" or missing, use the cached URL
string URLStringToUse=cachedURL;
if (variables.get("URL")) {
URLStringToUse=variables.get("URL");
if (URLStringToUse=="") {
// see if we have an original URL set at least...
URLStringToUse=variables.get("origURL");
if (URLStringToUse=="") {
// still nothing? default to the cache.
URLStringToUse=cachedURL;
}
} else {
// insert anything from the root add path... (only if not cached)
URLStringToUse.insert(0, CGIConfiguration::getInstance().getRootAddPath());
// ensure http:// is not included if it already exists...
if ((URLStringToUse.find("http://")!=0) && (URLStringToUse.find("HTTP://")!=0)) {
URLStringToUse="http://" + URLStringToUse;
}
}
}
// check the URL - change any %7E's to ~'s -
replaceAll(&URLStringToUse, "/%7E", "/~");
replaceAll(&outputString, "{%ResURL%}", URLStringToUse);
// ResTitle
string thisTitle="(no title)";
if (variables.get("title")) {
thisTitle=variables.get("title");
replaceAll(&thisTitle, "<", "<");
replaceAll(&thisTitle, ">", ">");
}
replaceAll(&outputString, "{%ResTitle%}", thisTitle);
// ResSummary
findAndReplace(&outputString, "summary", "{%ResSummary%}");
// ResScore
findAndReplace(&outputString, "score", "{%ResScore%}");
// ResOrigUrl
findAndReplace(&outputString, "origURL", "{%ResOrigURL%}");
return outputString;
}
示例5: sendUser
void sendUser(const string& who, const string& what, bool raw)
{
string tosend;
if(raw)
tosend = what;
else
tosend = replace(yace->sql().getString("stdsend"), "%STUFF%", replaceAll(what));
user* u = yace->users().getUser(who);
if(u == NULL)
return;
u->send(tosend);
u->DecRef();
}
示例6: unescapeString
static std::string unescapeString(std::string str) {
std::map<std::string, std::string> replacementMap;
replacementMap["\\0"] = "\0";
replacementMap["\\n"] = "\n";
replacementMap["\\r"] = "\r";
replacementMap["\\t"] = "\t";
replacementMap["\\a"] = "\a";
replacementMap["\\b"] = "\b";
replacementMap["\\?"] = "\?";
replacementMap["\\\\"] = "\\";
replacementMap["\\\""] = "\"";
replacementMap["\\\'"] = "\'";
return replaceAll(str, replacementMap);
}
示例7: replaceAll
const std::string ItemInfo::replaceColors(std::string str,
const unsigned char color) const
{
std::string name;
if (mColors && !mColorList.empty())
{
const std::map <int, ColorDB::ItemColor>::const_iterator
it = mColors->find(color);
if (it == mColors->end())
name = "unknown";
else
name = it->second.name;
}
else
{
name = "unknown";
}
str = replaceAll(str, "%color%", name);
if (!name.empty())
name[0] = static_cast<signed char>(toupper(name[0]));
return replaceAll(str, "%Color%", name);
}
示例8: replaceAll
/**
* Hacky escaping logic with the goal of not upsetting the much more thorough
* rust JSON parsing library that actually understands UTF-8. Double-quote
* and (escaping) backslash are escaped, as is tab (\t), with newlines (\r\n
* and \n) normalized to escaped \n.
*
* Additionally, everything that's not printable ASCII is simply erased. The
* motivating file is media/openmax_il/il112/OMX_Other.h#93 which has a
* corrupted apostrophe as <92> in there. The better course of action would
* be a validating UTF-8 parse that discards corrupt/non-printable characters.
* Since this is motivated by a commenting proof-of-concept and builds are
* already slow, I'm punting on that.
*/
std::string JSONFormatter::escape(std::string Input) {
bool NeedsEscape = false;
for (char C : Input) {
if (C == '\\' || C == '"' || C < 32 || C > 126) {
NeedsEscape = true;
break;
}
}
if (!NeedsEscape) {
return Input;
}
std::string Cur = Input;
Cur = replaceAll(Cur, "\\", "\\\\");
Cur = replaceAll(Cur, "\"", "\\\"");
Cur = replaceAll(Cur, "\t", "\\t");
Cur = replaceAll(Cur, "\r\n", "\\n");
Cur = replaceAll(Cur, "\n", "\\n");
Cur.erase(std::remove_if(Cur.begin(), Cur.end(),
[](char C){ return C < 32 || C > 126; }),
Cur.end());
return Cur;
}
示例9: EditorWidget
EditorWidgetQSci::EditorWidgetQSci(QWidget *parent) : EditorWidget(parent)
{
m_widget = new QWidget(parent);
QVBoxLayout *l = new QVBoxLayout(m_widget);
m_editor = new QsciScintilla(m_widget);
m_editor->setMarginLineNumbers(QsciScintilla::NumberMargin, true);
m_editor->setMarginWidth(QsciScintilla::NumberMargin, "12322");
m_editor->setBraceMatching(QsciScintilla::SloppyBraceMatch);
m_editor->setAutoCompletionSource(QsciScintilla::AcsAll);
m_editor->setAutoCompletionThreshold(3);
m_editor->setAutoIndent(true);
m_editor->setIndentationsUseTabs(false);
m_editor->setIndentationWidth(4);
m_editor->setUtf8(true);
m_editor->setEolMode(QsciScintilla::EolUnix);
m_search_widget = new QWidget(m_widget);
m_search_ui = new Ui::QSciSearchBar;
m_search_ui->setupUi(m_search_widget);
l->addWidget(m_editor, 1);
l->addWidget(m_search_widget);
m_search_widget->setVisible(false);
setSearchBarReplaceVisible(false);
m_canUndo = false;
m_canRedo = false;
QShortcut *find_s = new QShortcut(QKeySequence("Ctrl+F"), m_widget);
QShortcut *replace_s = new QShortcut(QKeySequence("Ctrl+R"), m_widget);
QShortcut *find_esc_s = new QShortcut(QKeySequence("Esc"), m_widget);
connect(m_editor, SIGNAL(modificationChanged(bool)), SLOT(modified(bool)));
connect(m_editor, SIGNAL(textChanged()), SLOT(checkUndoRedo()));
connect(m_search_ui->expandBtn, SIGNAL(clicked(bool)), SLOT(setSearchBarReplaceVisible(bool)));
connect(m_search_ui->closeBtn, SIGNAL(clicked()), SLOT(hideSearch()));
connect(find_esc_s, SIGNAL(activated()), SLOT(hideSearch()));
connect(find_s, SIGNAL(activated()), SLOT(showSearch()));
connect(replace_s, SIGNAL(activated()), SLOT(showReplace()));
connect(m_search_ui->nextBtn, SIGNAL(clicked()), SLOT(findNext()));
connect(m_search_ui->prevBtn, SIGNAL(clicked()), SLOT(findPrev()));
connect(m_search_ui->findEdit, SIGNAL(textEdited(QString)), SLOT(findNext()));
connect(m_search_ui->replaceBtn, SIGNAL(clicked()), SLOT(replace()));
connect(m_search_ui->replaceAllBtn, SIGNAL(clicked()), SLOT(replaceAll()));
connect(m_search_ui->findEdit, SIGNAL(returnPressed()), SLOT(findNext()));
}
示例10: wcslen
void RuntimeEngine::setProjectPath(const std::string &workPath)
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
vector<std::string> searchPathArray = FileUtils::getInstance()->getSearchPaths();
if (workPath.empty())
{
std::string appPath = std::string("");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
TCHAR szAppDir[MAX_PATH] = { 0 };
if (GetModuleFileName(NULL, szAppDir, MAX_PATH))
{
int nEnd = 0;
for (int i = 0; szAppDir[i]; i++)
{
if (szAppDir[i] == '\\')
nEnd = i;
}
szAppDir[nEnd] = 0;
int iLen = 2 * wcslen(szAppDir);
char* chRtn = new char[iLen + 1];
wcstombs(chRtn, szAppDir, iLen + 1);
std::string strPath = chRtn;
delete[] chRtn;
chRtn = NULL;
char fuldir[MAX_PATH] = { 0 };
_fullpath(fuldir, strPath.c_str(), MAX_PATH);
appPath = fuldir;
}
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
appPath.append("/../../../");
#endif
appPath = replaceAll(appPath, "\\", "/");
g_projectPath = appPath;
}
else
{
g_projectPath = workPath;
}
// add project's root directory to search path
searchPathArray.insert(searchPathArray.begin(), g_projectPath);
// add writable path to search path
searchPathArray.insert(searchPathArray.begin(), FileServer::getShareInstance()->getWritePath());
FileUtils::getInstance()->setSearchPaths(searchPathArray);
#endif
}
示例11: replaceAll
char *nameParse( char *inNameString ) {
char found;
char *name = replaceAll( inNameString, "_", " ", &found );
delete [] inNameString;
if( strcmp( name, "You" ) == 0 ) {
delete [] name;
name = stringDuplicate( translate( "nameYou" ) );
}
return name;
}
示例12: QMainWindow
MainUI::MainUI() : QMainWindow(), ui(new Ui::MainUI){
ui->setupUi(this);
settings = new QSettings("lumina-desktop","lumina-textedit");
Custom_Syntax::SetupDefaultColors(settings); //pre-load any color settings as needed
colorDLG = new ColorDialog(settings, this);
this->setWindowTitle(tr("Text Editor"));
ui->tabWidget->clear();
closeFindS = new QShortcut(QKeySequence(Qt::Key_Escape), this);
connect(closeFindS, SIGNAL(activated()), this, SLOT(closeFindReplace()) );
ui->groupReplace->setVisible(false);
//Update the menu of available syntax highlighting modes
QStringList smodes = Custom_Syntax::availableRules();
for(int i=0; i<smodes.length(); i++){
ui->menuSyntax_Highlighting->addAction(smodes[i]);
}
ui->actionLine_Numbers->setChecked( settings->value("showLineNumbers",true).toBool() );
ui->actionWrap_Lines->setChecked( settings->value("wrapLines",true).toBool() );
//Setup any connections
connect(ui->actionClose, SIGNAL(triggered()), this, SLOT(close()) );
connect(ui->actionNew_File, SIGNAL(triggered()), this, SLOT(NewFile()) );
connect(ui->actionOpen_File, SIGNAL(triggered()), this, SLOT(OpenFile()) );
connect(ui->actionClose_File, SIGNAL(triggered()), this, SLOT(CloseFile()) );
connect(ui->actionSave_File, SIGNAL(triggered()), this, SLOT(SaveFile()) );
connect(ui->actionSave_File_As, SIGNAL(triggered()), this, SLOT(SaveFileAs()) );
connect(ui->menuSyntax_Highlighting, SIGNAL(triggered(QAction*)), this, SLOT(UpdateHighlighting(QAction*)) );
connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(tabChanged()) );
connect(ui->tabWidget, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosed(int)) );
connect(ui->actionLine_Numbers, SIGNAL(toggled(bool)), this, SLOT(showLineNumbers(bool)) );
connect(ui->actionWrap_Lines, SIGNAL(toggled(bool)), this, SLOT(wrapLines(bool)) );
connect(ui->actionCustomize_Colors, SIGNAL(triggered()), this, SLOT(ModifyColors()) );
connect(ui->actionFind, SIGNAL(triggered()), this, SLOT(openFind()) );
connect(ui->actionReplace, SIGNAL(triggered()), this, SLOT(openReplace()) );
connect(ui->tool_find_next, SIGNAL(clicked()), this, SLOT(findNext()) );
connect(ui->tool_find_prev, SIGNAL(clicked()), this, SLOT(findPrev()) );
connect(ui->tool_replace, SIGNAL(clicked()), this, SLOT(replaceOne()) );
connect(ui->tool_replace_all, SIGNAL(clicked()), this, SLOT(replaceAll()) );
connect(ui->line_find, SIGNAL(returnPressed()), this, SLOT(findNext()) );
connect(ui->line_replace, SIGNAL(returnPressed()), this, SLOT(replaceOne()) );
connect(colorDLG, SIGNAL(colorsChanged()), this, SLOT(UpdateHighlighting()) );
updateIcons();
//Now load the initial size of the window
QSize lastSize = settings->value("lastSize",QSize()).toSize();
if(lastSize.width() > this->sizeHint().width() && lastSize.height() > this->sizeHint().height() ){
this->resize(lastSize);
}
}
示例13: processLogicParams
const std::string CHTMLTemplate::getHTMLData(const std::map<std::string, std::string> *params) const
{
std::string tmpTemlateData = templateData;
for(auto it = params->begin(); it != params->end(); ++it)
{
const std::string param = it->first;
std::string value = it->second;
if(param.substr(0,3) == "{is")
{
tmpTemlateData = processLogicParams(tmpTemlateData ,param, value == "true");
continue;
}
tmpTemlateData = replaceAll(tmpTemlateData, param, value);
}
return tmpTemlateData;
}
示例14: replaceAll
string Util::clearAccent(string texto) {
if(texto.empty())
return "";
string sAcento = "aaaaaeeeeiiiiooooouuuuAAAAAEEEEIIIOOOOOUUUUcCnN";
string cAcento = "àáâãäèéêëìíîïòóôõöùúûüÀÁÂÃÄÈÉÊËÌÍÎÒÓÔÕÖÙÚÛÜçÇñÑ";
for(int i=0,j=0; i < cAcento.size()/2 ; i++ , j=j+2) {
string to = sAcento.substr(i,1);
string from = cAcento.substr(j,2);
//cout << texto << " " << from << " "<< to << " i:" << itoa(i,10) <<endl;
texto = replaceAll(texto,from,to);
}
return texto;
}
示例15: message_
EasyXmlException::EasyXmlException(const std::string& message, int errorCode, uint lineNumber) :
message_(message),
errorCode_(errorCode),
lineNumber_(lineNumber)
{
// If a line number was specified...
if (lineNumber_ > 0)
{
// convert "lineNumber" to a string.
std::ostringstream ss;
ss << lineNumber_;
replaceAll(message_, "%d", ss.str());
message_ += "\n";
}
}