Click here to Skip to main content
12,997,179 members (72,279 online)
Click here to Skip to main content


103 bookmarked
Posted 29 Oct 2000

Fast regular expressions

, 29 Oct 2000
Compiles a regular expression into a fast automaton.
#pragma once
#include "RexInterface.h"

struct SSearchInfo{
	SSearchInfo(CString strPathname,CString strFilename,
                        int nFilePosTokenBeg=0,int nLen=0,CString strLine="")
    CString  strFilename;
    CString  strPathname;
    CString  strLine;
    int nFilePosTokenBeg;
    int nLen;

class CSearchResult{
    vector< SSearchInfo > vecSearchInfo;

class CSearchPresenter{
    virtual void  Init()=0;
    virtual void  PresentSearch(const CSearchResult& rResult,int nPieceNo)=0;
class CFileProcessor{
    virtual REXI_DefErr   AddRegDefinition(const char* pcszName,const char* pcszRegExp)=0;
    virtual REXI_DefErr   SetRegExpression(const char* pcszExpr)=0;
    virtual void    ProcessFile(CSearchResult& pResult,
        const char* pcszPathName,const char* pcszFileName,
        bool bLinewise,bool bAtMostOneMatchPerLine)=0;
class CSearchBar: public CDialogBar{
    void RegisterSearchPresenter(CSearchPresenter* pSearchPresenter)
    void RegisterFileProcessor(CFileProcessor* pFileProcessor);
    void DoDataExchange(CDataExchange* pDX);
    void ShowDialog();
    void Serialize(CArchive& ar);
    static bool FindInThisFile(const char* pcszPathName,const char* pcszFileName,void* pThis);
    bool SetRegexp(CString strRegexp);
    void Resize(int cx,int cy);
    CComboBox   m_cmbSearch;
    CComboBox   m_cmbDir;
    CComboBox   m_cmbWildCards;
    CString     m_strBrowseDir;
    CButton     m_btnReghelp;
	CButton		m_btnSearch;
    CButton     m_btnDirBrowse;
    CProgressCtrl   m_progress;
    CStatic     m_static;
    void NotifyPresenters(const CSearchResult& result);
    void NotifyProcessors(const char* pcszPathName,
                                  const char* pcszFileName,CSearchResult& result);
    void        DoMessageLoop();
    BOOL        PumpMessage();
    bool        m_bQuit;
    vector<CSearchPresenter*>   m_vecSearchPresenters;
    vector<CFileProcessor*>     m_vecFileProcessors;
    CSearchPresenter*   m_pSearchPresenter;
    CSearchResult       m_searchResult;
    DWORD               m_dwCmbSelection;
    int                 m_nPieceNo;
    bool                m_bEnableSearch;
    bool                m_bCanceled;
    int                 m_nOccurences;
    bool CheckSearchEnableThis  (CWnd& rWnd);
    void InsertAtCaretPos       (const char* pcszToInsert,int nPos);
    void CmbContentSerialize    (CComboBox& rCmb,CArchive& ar);
    void InsertIntoCmbList      (CComboBox& rCmb,CString strToInsert);
    vector< pair<CString,CString> > m_vecDefs;
    void OnCancelSearch();
    afx_msg void OnUpdateSearch(CCmdUI* pCmdUI);
    afx_msg void OnUpdateButtonDirBrowse(CCmdUI* pCmdUI);
    afx_msg void OnUpdateButtonDef(CCmdUI* pCmdUI);
    afx_msg void OnUpdateCancel(CCmdUI* pCmdUI);
	afx_msg void OnButtonDirBrowse();
	afx_msg void OnButtonReghelp();
    afx_msg void OnUpdateButtonReghelp(CCmdUI* pCmdUI);
	afx_msg void OnSearch();
	afx_msg void OnContextmenuCharacterinrange();
	afx_msg void OnContextmenuCharacternotinrange();
	afx_msg void OnContextmenuGroup();
	afx_msg void OnContextmenuOr();
	afx_msg void OnButtonDef();

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Martin Holzherr
Switzerland Switzerland
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170622.1 | Last Updated 30 Oct 2000
Article Copyright 2000 by Martin Holzherr
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid