blob: 0aac4d565775b1ce8d2fef53e3447d0fd4510230 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/***************************************************************************
* tdeio-locate: KDE I/O Slave for the locate command *
* *
* Copyright (C) 2005 by Tobi Vollebregt *
* [email protected] *
* *
* Thanks to Google's Summer Of Code Program! *
* *
* Copyright (C) 2004 by Armin Straub *
* [email protected] *
* *
* This program was initially written by Michael Schuerig. *
* Although I have completely rewritten it, most ideas are adopted *
* from his original work. *
* *
* Copyright (C) 2002 by Michael Schuerig *
* [email protected] *
* *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#ifndef PATTERN_H
#define PATTERN_H
#include <tqregexp.h>
#include <tqstring.h>
#include <tqvaluelist.h>
/**
* Regular Expression adapted to the needs of tdeio-locate.
*/
class LocateRegExp
{
public:
/**
* Constructor
* @param pattern the pattern to start with
* @param ignoreCase specifies, if the search should be case sensitive
*/
LocateRegExp(const TQString& pattern, bool ignoreCase = false);
LocateRegExp();
virtual ~LocateRegExp();
/**
* Determines whether a file name is matching this regular expression.
* @param file the filename to match
*/
virtual bool isMatching(const TQString& file) const;
/**
* @return The position of the last match.
*/
virtual int getMatchPosition() const;
/**
* @return The length of the last match.
*/
virtual int getMatchedLength() const;
/**
* Set the pattern.
* @param pattern the pattern to search for. It may be prepended by an
* exclamation mark, to invert its meaning.
*/
virtual void setPattern(const TQString& pattern);
/**
* Get the pattern.
* @return search pattern
*/
virtual TQString getPattern() const;
private:
bool m_negated;
bool m_ignoreCase;
TQRegExp m_regExp;
TQString m_pattern;
};
/**
* List of regular expressions
*/
class LocateRegExpList: public TQValueList<LocateRegExp>
{
public:
virtual ~LocateRegExpList();
/**
* Converts a stringlist into a regexplist.
* @param list the stringlist to convert
*/
LocateRegExpList& operator = (const TQStringList& list);
/**
* Determines whether a file name is matching at least one regular
* expression in the list.
* @param file the filename to match
*/
virtual bool isMatchingOne(const TQString& file) const;
/**
* Determines whether a file name is matching all regular expressions
* in the list.
* @param file the filename to match
*/
virtual bool isMatchingAll(const TQString& file) const;
};
#endif
|