Exemplo n.º 1
0
std::string ReplayBuilder::escapeString(std::string s) {
  findReplace(s, ':', "\\\\:");
  findReplace(s, '\'', "\\'");
  findReplace(s, '\n', "\\n");
  findReplace(s, '\r', "\\n");
  return s;
}
Exemplo n.º 2
0
std::string ReplayBuilder::escapeHtml(std::string s) {
  findReplace(s, '&', "&");
  findReplace(s, '<', "&lt;");
  findReplace(s, '>', "&gt;");
  findReplace(s, '"', "&quot;");
  findReplace(s, '\'', "&#039;");
  return s;
}
Exemplo n.º 3
0
Arquivo: ggg.cpp Projeto: pvrs12/junk
void build_huffman_map(std::map<char,std::string>& c, tree* root, int path=0){
	if(root->left != nullptr){
		std::cout<<"going left"<<std::endl;
		build_huffman_map(c,root->left,(path | 0) << 1);
	} 
	if(root->c != '\0'){
		findReplace(p,"0","g");
		findReplace(p,"1","G");
		c[root->c] = p;
	}
	if(root->right !=nullptr){
		std::cout<<"going right"<<std::endl;
		build_huffman_map(c,root->right, (path | 1) << 1);
	}
}
Exemplo n.º 4
0
void decryptText(FILE *fp) {
    FILE *keyFileP = fopen("key","r");
    char text[6000] = {0};
    char newText[6000] = {0};
    int key[100] = {0};
    readFile(fp,text);
    readkey("keyTwo",key);
    printf("%s \n","finding char...");
    int pos = 0;
    while(text[pos] != EOF)
    {
        int ch = text[pos];
        int newChar = findReplace(ch,key);
        if(newChar == 26) {
            newText[pos] = 32;
        }
        else if((ch < 123) && (ch > 96) || ch == 32) {
            newText[pos] = newChar+97;
        }
        else {
            newText[pos] = newChar;
        }
        pos++;
    }
    printf("%s\n",newText);
}
Exemplo n.º 5
0
 void nextPermutation(vector<int> &num) {
     // Start typing your C/C++ solution below
     // DO NOT write int main() function
     if (num.size()==1) {
         return;
     }
     int x, y;
     findReplace( num, x, y);
     if (x==-1 && y==-1) {
         swap(num, 0, num.size()-1);
         
     }
     else {
         swap(num, x, y);
     }
     sort(num.begin()+x+1, num.end());
 }
Exemplo n.º 6
0
void EditorWidget::findReplace(QString str_find, QString str_replace, bool r_next, bool r_all)
{
	bool isFind = false;
	QString str_select = "";
	if (r_next)
		isFind = findFirst(str_find, false);

	if (m_initialPag == RichTextIndex) {
		str_select = editor_rich_text->textCursor().selectedText();
		if (!str_select.isEmpty() && str_select == str_find)
			editor_rich_text->insertHtml( str_replace );
	} else {
		str_select = editor_plain_text->textCursor().selectedText();
		if (!str_select.isEmpty() && str_select == str_find)
			editor_plain_text->insertPlainText( str_replace );
	}

	if (r_all && isFind)
		findReplace(str_find, str_replace, true, true);
}
Exemplo n.º 7
0
//Simple function that calls both findErase and eraseDoubleSpaces.
void cleanupString(char *Str){
	findErase(Str, '\n');
    findReplace(Str, ",", ", ");
	eraseDoubleSpaces(Str);
}
Exemplo n.º 8
0
void MainWindow::createActions() {
    mNewFileAction = new QAction(QIcon(":/images/new.png"), tr("&New"), this);
    mNewFileAction->setShortcut(QKeySequence::New);
    mNewFileAction->setStatusTip(tr("Open a new file"));
    connect(mNewFileAction, SIGNAL(triggered()), this, SLOT(newBlankPage()));

    mOpenFileAction = new QAction(QIcon(":/images/open.png"), tr("&Open"), this);
    mOpenFileAction->setShortcut(QKeySequence::Open);
    mOpenFileAction->setStatusTip(tr("Open file"));
    connect(mOpenFileAction, SIGNAL(triggered()), this, SLOT(openPage()));

    mSaveFileAction = new QAction(QIcon(":/images/save.png"), tr("&Save"), this);
    mSaveFileAction->setShortcut(QKeySequence::Save);
    mSaveFileAction->setStatusTip(tr("Save file"));
    connect(mSaveFileAction, SIGNAL(triggered()), this, SLOT(saveTab()));

    mSaveAsFileAction = new QAction(QIcon(":/images/saveAs.png"), tr("Save &As"), this);
    mSaveAsFileAction->setShortcut(QKeySequence::SaveAs);
    mSaveAsFileAction->setStatusTip(tr("Save file as"));
    connect(mSaveAsFileAction, SIGNAL(triggered()), this, SLOT(savePageAs()));

    mExitAction = new QAction(tr("&Exit"), this);
    mExitAction->setShortcut(QKeySequence::Quit);
    mExitAction->setStatusTip(tr("Exit the application"));
    connect(mExitAction, SIGNAL(triggered()), this, SLOT(close()));

    /* Project Actions */
    mNewProjectAction = new QAction(tr("New Project"), this);
    mNewFileAction->setStatusTip(tr("Creates a new Project"));
    connect(mNewProjectAction, SIGNAL(triggered()), this, SLOT(newProject()));

    mOpenProjectAction = new QAction(tr("Open Project"), this);
    mOpenProjectAction->setStatusTip(tr("Open an existing project"));

    mSaveProjectAction = new QAction(tr("Save Project"), this);
    mSaveProjectAction->setStatusTip(tr("Save current project"));

    mSaveProjectAsAction = new QAction(tr("Save Project As"), this);
    mSaveProjectAsAction->setStatusTip(tr("Save current project as"));

    mShowProjectViewAction = new QAction(tr("Show Project View"), this);
    mShowProjectViewAction->setStatusTip(tr("Show Project Settings and Properties"));
    connect(mShowProjectViewAction, SIGNAL(triggered()), this, SLOT(showProjectView()));

    mShowTransistionDiagramAction = new QAction(tr("Show Transistion Diagram"), this);
    mShowTransistionDiagramAction->setStatusTip(tr("Show the Projects Transistion Diagram"));
    connect(mShowTransistionDiagramAction, SIGNAL(triggered()), this, SLOT(showTransistionDiagram()));

    mGenerateHOLAction = new QAction(tr("Generate HOL"), this);
    mGenerateHOLAction->setStatusTip(tr("Generate all the HOL files for the project"));

    mGenerateHaskellAction = new QAction(tr("Generate Haskell"), this);
    mGenerateHaskellAction->setStatusTip(tr("Generate all the Haskell files for the project"));

    mGenerateDocAction = new QAction(tr("Generate Documentation"), this);
    mGenerateDocAction->setStatusTip(tr("Generate Documentation for project"));

    mCloseProjectAction = new QAction(tr("Close project"), this);
    mCloseProjectAction->setStatusTip(tr("Closes the current project"));

    /* Edit Actions */

    mUndoAction = new QAction(tr("&Undo"), this);
    mUndoAction->setShortcut(QKeySequence::Undo);
    mUndoAction->setStatusTip(tr("Undo"));
    connect(mUndoAction, SIGNAL(triggered()), this, SLOT(undo()));

    mRedoAction = new QAction(tr("&Redo"), this);
    mRedoAction->setShortcut(QKeySequence::Redo);
    mRedoAction->setStatusTip(tr("Redo"));
    connect(mRedoAction, SIGNAL(triggered()), this, SLOT(redo()));

    mCutAction = new QAction(tr("&Cut"), this);
    mCutAction->setShortcut(QKeySequence::Cut);
    mCutAction->setStatusTip(tr("Cut"));
    connect(mCutAction, SIGNAL(triggered()), this, SLOT(cut()));

    mCopyAction = new QAction(tr("&Copy"), this);
    mCopyAction->setShortcut(QKeySequence::Copy);
    mCopyAction->setStatusTip(tr("Copy"));
    connect(mCopyAction, SIGNAL(triggered()), this, SLOT(copy()));

    mPasteAction = new QAction(tr("&Paste"), this);
    mPasteAction->setShortcut(QKeySequence::Paste);
    mPasteAction->setStatusTip(tr("Paste"));
    connect(mPasteAction, SIGNAL(triggered()), this, SLOT(paste()));

    mSelectAllAction = new QAction(tr("Select &All"), this);
    mSelectAllAction->setShortcut(QKeySequence::SelectAll);
    mSelectAllAction->setStatusTip(tr("Select All"));
    connect(mSelectAllAction, SIGNAL(triggered()), this, SLOT(selectAll()));

    mFindReplaceAction = new QAction(tr("&Find/Replace"), this);
    mFindReplaceAction->setShortcut(QKeySequence::Find);
    mFindReplaceAction->setStatusTip(tr("Find/Replace"));
    connect(mSelectAllAction, SIGNAL(triggered()), this, SLOT(findReplace()));

    /* HOL Menu Actions */
    mHOLRestartAction = new QAction(tr("Restart HOL"), this);
    mHOLRestartAction->setStatusTip(tr("Restart the HOL buffer"));
    connect(mHOLRestartAction, SIGNAL(triggered()), mHOLWidget, SLOT(restart()));

    mHOLSendRegionToAction = new QAction(tr("Send Region to HOL"), this);
    mHOLSendRegionToAction->setStatusTip(tr("Sends the highlighted region to the HOL buffer"));
    //connect

    mHOLRunHolmakeAction = new QAction(tr("Run Holmake"), this);
    mHOLRunHolmakeAction->setStatusTip(tr("Runs Holamake in current directory"));
    connect(mHOLRunHolmakeAction, SIGNAL(triggered()), this, SLOT(runHolmake()));

    mHOLShowTypesAction = new QAction(tr("Show Types"), this);
    mHOLShowTypesAction->setStatusTip(tr("Show Types"));
    connect(mHOLShowTypesAction, SIGNAL(triggered()), mHOLWidget, SLOT(showTypes()));

    mHOLShowTypesVerboseAction = new QAction(tr("Show Types Verbosely"), this);
    mHOLShowTypesVerboseAction->setStatusTip(tr("Show Types Verbosely"));
    connect(mHOLShowTypesVerboseAction, SIGNAL(triggered()), mHOLWidget, SLOT(showTypesVerbose()));

    mHOLShowNumericalTypesAction = new QAction(tr("Show Numerical Types"), this);
    mHOLShowNumericalTypesAction->setStatusTip(tr("Show Numerical Types"));
    connect(mHOLShowNumericalTypesAction, SIGNAL(triggered()), mHOLWidget, SLOT(showNumericalTypes()));

    mHOLShowAssumptionsAction = new QAction(tr("Show Assumptions"), this);
    mHOLShowAssumptionsAction->setStatusTip(tr("Show Assumptions"));
    connect(mHOLShowAssumptionsAction, SIGNAL(triggered()), mHOLWidget, SLOT(showAssumptions()));

    /* Help Menu Actions */
    mHOLDocumentationAction = new QAction(tr("HOL Documentation"), this);
    mHOLDocumentationAction->setStatusTip(tr("Show HOL Documentation"));

    mAboutAction = new QAction(tr("About"), this);
    mAboutAction->setStatusTip(tr("About"));

    /* Transistion Diagram Actions */
    mAddStateAction = new QAction(tr("Add State"), this);
    mAddStateAction->setStatusTip("Add a new State to the Transistion Diagram");

    mDeleteStateAction = new QAction(tr("Remove State"), this);
    mDeleteStateAction->setStatusTip("Remove state from Transistion Diagram");

    mMakeLinkAction = new QAction(tr("Connect States"), this);
    mMakeLinkAction->setStatusTip("Connect two states");

    mDeleteLinkAction = new QAction(tr("Remove Link"), this);
    mDeleteLinkAction->setStatusTip("Remove the Link between two States");

    mStatePropertiesAction = new QAction(tr("State Properties"), this);
    mStatePropertiesAction->setStatusTip("Display the Properties of the State");

    mZoomInAction = new QAction(tr("Zoom In"), this);
    mZoomInAction->setStatusTip("Zoom In on the Diagrams");

    mZoomOutAction = new QAction(tr("Zoom Out"), this);
    mZoomOutAction->setStatusTip("Zoom Out on the Diagram");
}
Exemplo n.º 9
0
void EditorWidget::btnReplaceAll_clicked()
{
	findReplace(txt_find->text(), txt_replace->text(), true, true);
}