Click here to Skip to main content
11,482,402 members (73,043 online)
Click here to Skip to main content
Add your own
alternative version

Fast regular expressions

, 29 Oct 2000 289.6K 4.5K 102
Compiles a regular expression into a fast automaton.
// ErrListView.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "MainFrm.h"
#include "ErrListView.h"
#include "RexSearchDoc.h"
#include "RexSearchView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CErrListView

IMPLEMENT_DYNCREATE(CErrListView, CListView)

CErrListView::CErrListView():m_bIsInitialized(false)
{
}

CErrListView::~CErrListView()
{
}
void    CErrListView::Init()
{
    GetListCtrl().DeleteAllItems();
    GetListCtrl().Invalidate();
    GetListCtrl().UpdateWindow();
}
void  CErrListView::PresentSearch(const CSearchResult& rResult,int nPieceNo)
{
	if( nPieceNo==0){
		GetListCtrl().DeleteAllItems();
	}
	int nItems= GetListCtrl().GetItemCount();
    char buf[32];
    for(int i=0;i<rResult.vecSearchInfo.size();i++){
        GetListCtrl().InsertItem(nItems+i,rResult.vecSearchInfo[i].strPathname);
        GetListCtrl().SetItemText(nItems+i,1,rResult.vecSearchInfo[i].strFilename);
        GetListCtrl().SetItemText(nItems+i,2,itoa(rResult.vecSearchInfo[i].nFilePosTokenBeg,buf,10));
        GetListCtrl().SetItemText(nItems+i,3,itoa(rResult.vecSearchInfo[i].nLen,buf,10));
        GetListCtrl().SetItemText(nItems+i,4,rResult.vecSearchInfo[i].strLine);
    }
}



BEGIN_MESSAGE_MAP(CErrListView, CListView)
	//{{AFX_MSG_MAP(CErrListView)
	ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnItemchanged)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Zeichnung CErrListView 

void CErrListView::OnDraw(CDC* pDC)
{
	CDocument* pDoc = GetDocument();
	// ZU ERLEDIGEN: Code zum Zeichnen hier einf�gen
}

/////////////////////////////////////////////////////////////////////////////
// Diagnose CErrListView

#ifdef _DEBUG
void CErrListView::AssertValid() const
{
	CListView::AssertValid();
}

void CErrListView::Dump(CDumpContext& dc) const
{
	CListView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f�r Nachrichten CErrListView 

void CErrListView::OnInitialUpdate() 
{
	CListView::OnInitialUpdate();
    if(!m_bIsInitialized){
        m_bIsInitialized= true;
        GetListCtrl().ModifyStyle(0,LVS_REPORT|LVS_SINGLESEL|LVS_SHOWSELALWAYS);
		GetListCtrl().SetExtendedStyle(GetListCtrl().GetExtendedStyle()|LVS_EX_FULLROWSELECT );
        GetListCtrl().InsertColumn(0,"Path",LVCFMT_LEFT,50);
        GetListCtrl().InsertColumn(1,"File",LVCFMT_LEFT,100);
        GetListCtrl().InsertColumn(2,"Position",LVCFMT_LEFT,50);
        GetListCtrl().InsertColumn(3,"Length",LVCFMT_LEFT,30);
        GetListCtrl().InsertColumn(4,"Line",LVCFMT_LEFT,500);
        CMainFrame::RegisterSearchPresenter(this);
    }
}

void CErrListView::OnItemchanged(NMHDR* pNMHDR, LRESULT* pResult) 
{
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
    if( pNMListView->uChanged&LVIF_STATE ){
        if( pNMListView->uNewState&LVIS_SELECTED ){
            CString strPath= GetListCtrl().GetItemText(pNMListView->iItem,0);
            long lPos= atol(GetListCtrl().GetItemText(pNMListView->iItem,2));
            int  nLen= atoi(GetListCtrl().GetItemText(pNMListView->iItem,3));
            CMainFrame::GetEditPane()->ShowFile(strPath,lPos,nLen);
        }
    }
	*pResult = 0;
}

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.

License

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

Share

About the Author

Martin Holzherr

Switzerland Switzerland
No Biography provided

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