1
/***************************************************************
2
* Name: TextFileSearcherText
3
* Purpose: TextFileSearcherText is used to search text files
5
* Author: Jerome ANTOINE
7
* Copyright: Jerome ANTOINE
9
**************************************************************/
11
#include "TextFileSearcherText.h"
14
TextFileSearcherText::TextFileSearcherText(const wxString& searchText, bool matchCase, bool matchWordBegin,
16
:TextFileSearcher(searchText, matchCase, matchWordBegin, matchWord)
18
if ( matchCase == false )
20
m_SearchText.LowerCase();
25
bool TextFileSearcherText::MatchLine(wxString line)
28
if ( m_MatchCase == false )
32
int pos = line.Find(m_SearchText.c_str());
34
while ( (match == false) && (pos >= 0) )
36
char c = ' '; // c is either the preceeding char or a virtual char
37
// that matches systematically the required conditions
38
match = true; // pos > 0 => expr found => Matches. Let's test start word
39
// and whole words conditions.
40
if ( (m_MatchWordBegin == true) || (m_MatchWord == true) )
44
c = line.GetChar(pos - 1);
46
//match = (__iscsym(c) == 0);
47
match = !(isalnum(c) || ( c == '_' ));
50
if ( (match == true) && (m_MatchWord == true) )
53
if ( (pos + m_SearchText.Length()) < line.Length() )
55
c = line.GetChar(pos + m_SearchText.Length());
57
match = !(isalnum(c) || ( c == '_' ));
60
nextPos = line.Mid(pos+1).Find(m_SearchText.c_str());