19
19
class TextFileSearcher
22
enum eFileSearcherReturn
30
/** BuildTextFileSearcher
31
* Builds a TextFileSearcherRegEx or a TextFileSearcherText pointer depending on regEx
32
* @return TextFileSearcher* : NULL if failure (regular expression syntax for example)
34
// We don't use ThreadSearchFindData to limit coupling
35
static TextFileSearcher* BuildTextFileSearcher(const wxString& searchText,
43
virtual ~TextFileSearcher() {};
45
/** Return true if line matches search text.
46
* This method must be implemented in derived classes to allows using
47
* different search strategies (at least simple text and regular expressions).
48
* @param line : the text line to match.
49
* @return true if line matches search text.
51
virtual bool MatchLine(wxString line) = 0;
53
/** Return true if object is OK.
54
* Exists to test validity of the object, mainly for reg ex syntax errors.
55
* @param pErrorMessage : error message if object is not valid. May be NULL
56
* if it is not necessary to get it.
57
* @return true if object is Ok, ie usable.
59
virtual bool IsOk(wxString* pErrorMessage = NULL);
61
/** Return true if Line matches search text.
62
* This method must be implemented in derived classes to allows using
63
* different search strategies (at least simple text and regular expressions use.
64
* @param filePath : file path in which we look for m_SearchText
65
* @param foundLines : array that stores a list of line number and line text
66
* @return true if success (error can only come from bad reg ex or file open
69
eFileSearcherReturn FindInFile(const wxString& filePath, wxArrayString &foundLines);
22
enum eFileSearcherReturn
30
/** BuildTextFileSearcher
31
* Builds a TextFileSearcherRegEx or a TextFileSearcherText pointer depending on regEx
32
* @return TextFileSearcher* : NULL if failure (regular expression syntax for example)
34
// We don't use ThreadSearchFindData to limit coupling
35
static TextFileSearcher* BuildTextFileSearcher(const wxString& searchText,
43
virtual ~TextFileSearcher() {};
45
/** Return true if line matches search text.
46
* This method must be implemented in derived classes to allows using
47
* different search strategies (at least simple text and regular expressions).
48
* @param line : the text line to match.
49
* @return true if line matches search text.
51
virtual bool MatchLine(wxString line) = 0;
53
/** Return true if object is OK.
54
* Exists to test validity of the object, mainly for reg ex syntax errors.
55
* @param pErrorMessage : error message if object is not valid. May be NULL
56
* if it is not necessary to get it.
57
* @return true if object is Ok, ie usable.
59
virtual bool IsOk(wxString* pErrorMessage = NULL);
61
/** Return true if Line matches search text.
62
* This method must be implemented in derived classes to allows using
63
* different search strategies (at least simple text and regular expressions use.
64
* @param filePath : file path in which we look for m_SearchText
65
* @param foundLines : array that stores a list of line number and line text
66
* @return true if success (error can only come from bad reg ex or file open
69
eFileSearcherReturn FindInFile(const wxString& filePath, wxArrayString &foundLines);
73
// We don't use ThreadSearchFindData to limit coupling
74
TextFileSearcher(const wxString& searchText, bool matchCase, bool matchWordBegin, bool matchWord):
75
m_SearchText(searchText),
76
m_MatchCase(matchCase),
77
m_MatchWordBegin(matchWordBegin),
78
m_MatchWord(matchWord)
73
// We don't use ThreadSearchFindData to limit coupling
74
TextFileSearcher(const wxString& searchText, bool matchCase, bool matchWordBegin, bool matchWord):
75
m_SearchText(searchText),
76
m_MatchCase(matchCase),
77
m_MatchWordBegin(matchWordBegin),
78
m_MatchWord(matchWord)
81
wxString m_SearchText;
83
bool m_MatchWordBegin;
85
wxTextFile m_TextFile;
81
wxString m_SearchText;
83
bool m_MatchWordBegin;
85
wxTextFile m_TextFile;
88
88
#endif // TEXT_FILE_SEARCHER_H