コード例 #1
0
ファイル: LuaCore.cpp プロジェクト: hunbernd/Lua4RS
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
0
ファイル: translationmanager.cpp プロジェクト: koo5/manaplus
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
0
ファイル: mydebug.hpp プロジェクト: rata/DLOG
    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
0
ファイル: SingleResultItem.cpp プロジェクト: blaze3j/DocHunt
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, "<", "&lt;");
    replaceAll(&thisTitle, ">", "&gt;");
  }
  replaceAll(&outputString, "{%ResTitle%}", thisTitle);

  // ResSummary
  findAndReplace(&outputString, "summary", "{%ResSummary%}");

  // ResScore
  findAndReplace(&outputString, "score", "{%ResScore%}");

  // ResOrigUrl
  findAndReplace(&outputString, "origURL", "{%ResOrigURL%}");

  return outputString;
}
コード例 #5
0
ファイル: functions.cpp プロジェクト: BackupTheBerlios/yace3
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
0
ファイル: POFile.cpp プロジェクト: binarycrusader/dunelegacy
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
0
ファイル: iteminfo.cpp プロジェクト: nashley/ManaPlus
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
0
ファイル: JSONFormatter.cpp プロジェクト: Noctem/gecko-dev
/**
 * 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
0
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
0
ファイル: Runtime.cpp プロジェクト: 253056965/cocos2d-x-lite
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
0
ファイル: mydebug.hpp プロジェクト: rata/DLOG
    void print_to_file(const char * userfile, int lineno, const char* tag,
                       T *obj, ADDON addon) {
        std::string msg;
        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 << BROWN(addon.getString()) << NBSP
              << BOLD(" Data : <br>") << objS << EDIV;
        (*OS).flush();
    }
コード例 #12
0
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;
}
コード例 #13
0
ファイル: MainUI.cpp プロジェクト: yamajun/lumina
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);
  }
}
コード例 #14
0
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;
}
コード例 #15
0
ファイル: Util.cpp プロジェクト: emersonmoretto/IMDB
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;

}
コード例 #16
0
ファイル: exception.cpp プロジェクト: Said-Nuri/easyXml
	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";
		}
	}
コード例 #17
0
ファイル: Browser.hpp プロジェクト: venam/alpapap
///===============Init the emails from the links already fetched====================///
void Browser::emails_class::init(links_class links)
{
    //clear all the emails in the page before adding the new ones
    all_emails.clear();

    //loop through the links to see if there's contact informations
    for(int i=0; i<links.size(); i++)
    {
        //search for the word : "mailto:"
        if(word_in(links[i].url(), "mailto:"))
        {
            std::string fake_temp_shit = links[i].url();
            replaceAll(fake_temp_shit,"mailto:","");
            all_emails.push_back(fake_temp_shit);
        }
    }
}
コード例 #18
0
ファイル: SearchContext.cpp プロジェクト: lihaven/frisk
void convertWildcard(std::string &regex)
{
    // Pretty terrible and crazy stuff.
    replaceAll(regex, "[", "\\[");
    replaceAll(regex, "]", "\\]");
    replaceAll(regex, "\\", "\\\\");
    replaceAll(regex, ".", "\\.");
    replaceAll(regex, "*", ".*");
    replaceAll(regex, "?", ".?");
    regex.insert(0, "^");
    regex.append("$");
}
コード例 #19
0
ファイル: functions.cpp プロジェクト: BackupTheBerlios/yace3
void sendAll(const string& what, bool raw)
{
    string tosend;
    if(raw)
        tosend = what;
    else
        tosend = replace(yace->sql().getString("stdsend"), "%STUFF%", replaceAll(what));

    set<string> all = yace->users().getAllUsers();
    set<string>::iterator it = all.begin();
    for(; it != all.end(); ++it) {
        user* t = yace->users().getUser(*it);
        if(t == NULL)
            continue;
        t->send(tosend);
        t->DecRef();
    }
}
コード例 #20
0
ファイル: test28.c プロジェクト: Titech1214097/libreplace
int main(void){
  
  char *str;
  char *regex = "(ab[^c]|a[^b]|[^a])+$";
  char *replacement = "[\\0]";
  regex_t reg;
  str = (char *)malloc(sizeof(char)*55);
  strcpy(str,"aaabbbcabcabb");

  regcomp(&reg,regex,REG_EXTENDED);
  replaceAll(str,reg,replacement);

  printf("%s\n",str);

  free(str);
  regfree(&reg);
  return 0;
}
コード例 #21
0
ファイル: test32.c プロジェクト: Titech1214097/libreplace
int main(void){
  
  char *str;
  char *regex = "aい▽えo";
  char *replacement = "aiueo";
  regex_t reg;
  str = (char *)malloc(sizeof(char)*55);
  strcpy(str,"abい▽えaい▽えo");

  regcomp(&reg,regex,REG_EXTENDED);
  replaceAll(str,reg,replacement);

  printf("%s\n",str);

  free(str);
  regfree(&reg);
  return 0;
}
コード例 #22
0
ファイル: test_parser.cpp プロジェクト: DerPapst/hhvm
bool TestParser::SameCode(std::string code1, std::string code2) {
  replaceAll(code1, "\n", "");
  replaceAll(code2, "\n", "");

  replaceAll(code1, "{{}}", "{}");
  replaceAll(code2, "{{}}", "{}");
  replaceAll(code1, "else {}", "");
  replaceAll(code2, "else {}", "");
  strip_empty_block(code1);
  strip_empty_block(code2);

  return code1 == code2;
}
コード例 #23
0
ファイル: Exceptions.cpp プロジェクト: Northrend/pytorch
std::string processErrorMsg(std::string str) {

  // Translate Aten types to their respective pytorch ones
  std::vector<std::pair<std::string, std::string>> changes {
    {"SparseCUDAByteType", "torch.cuda.sparse.ByteTensor"},
    {"SparseCUDACharType", "torch.cuda.sparse.CharTensor"},
    {"SparseCUDADoubleType", "torch.cuda.sparse.DoubleTensor"},
    {"SparseCUDAFloatType", "torch.cuda.sparse.FloatTensor"},
    {"SparseCUDAIntType", "torch.cuda.sparse.IntTensor"},
    {"SparseCUDALongType", "torch.cuda.sparse.LongTensor"},
    {"SparseCUDAShortType", "torch.cuda.sparse.ShortTensor"},
    {"SparseCUDAHalfType", "torch.cuda.sparse.HalfTensor"},
    {"SparseCPUByteType", "torch.sparse.ByteTensor"},
    {"SparseCPUCharType", "torch.sparse.CharTensor"},
    {"SparseCPUDoubleType", "torch.sparse.DoubleTensor"},
    {"SparseCPUFloatType", "torch.sparse.FloatTensor"},
    {"SparseCPUIntType", "torch.sparse.IntTensor"},
    {"SparseCPULongType", "torch.sparse.LongTensor"},
    {"SparseCPUShortType", "torch.sparse.ShortTensor"},
    {"SparseCPUHalfType", "torch.sparse.HalfTensor"},
    {"CUDAByteType", "torch.cuda.ByteTensor"},
    {"CUDACharType", "torch.cuda.CharTensor"},
    {"CUDADoubleType", "torch.cuda.DoubleTensor"},
    {"CUDAFloatType", "torch.cuda.FloatTensor"},
    {"CUDAIntType", "torch.cuda.IntTensor"},
    {"CUDALongType", "torch.cuda.LongTensor"},
    {"CUDAShortType", "torch.cuda.ShortTensor"},
    {"CUDAHalfType", "torch.cuda.HalfTensor"},
    {"CPUByteType", "torch.ByteTensor"},
    {"CPUCharType", "torch.CharTensor"},
    {"CPUDoubleType", "torch.DoubleTensor"},
    {"CPUFloatType", "torch.FloatTensor"},
    {"CPUIntType", "torch.IntTensor"},
    {"CPULongType", "torch.LongTensor"},
    {"CPUShortType", "torch.ShortTensor"},
    {"CPUHalfType", "torch.HalfTensor"},
  };

  for (const auto & it : changes) {
    replaceAll(str, it.first, it.second);
  }

  return str;
}
コード例 #24
0
FindReplaceForm::FindReplaceForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::FindReplaceForm), textEdit(0)
{
    ui->setupUi(this);

    ui->errorLabel->setText("");

    connect(ui->textToFind, SIGNAL(textChanged(QString)), this, SLOT(textToFindChanged()));
    connect(ui->textToFind, SIGNAL(textChanged(QString)), this, SLOT(validateRegExp(QString)));

    connect(ui->regexCheckBox, SIGNAL(toggled(bool)), this, SLOT(regexpSelected(bool)));

    connect(ui->findButton, SIGNAL(clicked()), this, SLOT(find()));
    connect(ui->closeButton, SIGNAL(clicked()), parent, SLOT(close()));

    connect(ui->replaceButton, SIGNAL(clicked()), this, SLOT(replace()));
    connect(ui->replaceAllButton, SIGNAL(clicked()), this, SLOT(replaceAll()));
}
コード例 #25
0
ファイル: test20.c プロジェクト: Titech1214097/libreplace
int main(void){
  
  char *str;
  char *regex = "\\s(one|two|three|four|five)\\s";
  char *replacement = " N ";
  regex_t reg;
  str = (char *)malloc(sizeof(char)*55);
  strcpy(str,"aone four twoa");

  regcomp(&reg,regex,REG_EXTENDED);
  replaceAll(str,reg,replacement);


  printf("%s\n",str);

  free(str);
  regfree(&reg);
  return 0;
}
コード例 #26
0
ファイル: test2.c プロジェクト: Titech1214097/libreplace
int main(void){
  
  char *str;
  char *regex = "_([^_]+)_";
  char *replacement = "<em>\\1</em>";
  regex_t reg;
  str = (char *)malloc(sizeof(char)*55);
  strcpy(str,"_Ruby_ is _cool_.");

  regcomp(&reg,regex,REG_EXTENDED);
  replaceAll(str,reg,replacement);


  printf("%s\n",str);

  free(str);
  regfree(&reg);
  return 0;
}
コード例 #27
0
ファイル: test11.c プロジェクト: Titech1214097/libreplace
int main(void) {

    char *str;
    char *regex = ".*\n";
    char *replacement = ">\\0";
    regex_t reg;
    str = (char *)malloc(sizeof(char)*55);
    strcpy(str,"abc\ndef\nghijk\nlmn\n");

    regcomp(&reg,regex,REG_EXTENDED|REG_NEWLINE);
    replaceAll(str,reg,replacement);


    printf("%s\n",str);

    free(str);
    regfree(&reg);
    return 0;
}
コード例 #28
0
ファイル: katesearch.cpp プロジェクト: Fat-Zer/tdelibs
void KateSearch::replaceAll()
{
  doc()->editStart ();

  while( doSearch(  s_pattern ) )
    replaceOne();

  doc()->editEnd ();

  if( !s.flags.finished ) {
    if( askContinue() ) {
      wrapSearch();
      replaceAll();
    }
  } else {
    KMessageBox::information( view(),
        i18n("%n replacement made.","%n replacements made.",replaces),
        i18n("Replace") );
  }
}
コード例 #29
0
ファイル: test6.c プロジェクト: Titech1214097/libreplace
int main(void){
  
  char *str;
  char *regex = "abc";
  char *replacement = "[\\0]";
  regex_t reg;
  str = (char *)malloc(sizeof(char)*55);
  strcpy(str,"Abc-ABC-AbC-abc");


  regcomp(&reg,regex,REG_EXTENDED|REG_ICASE);
  replaceAll(str,reg,replacement);


  printf("%s\n",str);

  free(str);
  regfree(&reg);
  return 0;
}
コード例 #30
0
string& common::trim(string &str)
{
	for (int i=0; i < (int)str.length(); ++i)
	{
		if ((str[ i] == '\n') || (str[ i] == '\t') || (str[ i] == ' '))
			str[ i] = '$';
		else
			break;
	}

	for (int i=str.length()-1; i >= 0; --i)
	{
		if ((str[ i] == '\n') || (str[ i] == '\t') || (str[ i] == ' '))
			str[ i] = '$';
		else
			break;
	}

	replaceAll(str, "$", "");
	return str;
}