summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-reader/CRegExp.h
blob: 661e300ebe119034a8ccb21f2419d55e0d3f48b1 (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
#include "config.h"
#include "hash.h"
#include "Queue.h"
#include <qstring.h>

typedef hashtable<tchar,unsigned int>::iterator iter;

#define WORD_SIZE	32

class CRegExpFilt
{
  CQueue<tchar> m_outQueue;
  hashtable<tchar,unsigned int> CV;
  unsigned int bit[WORD_SIZE];
  unsigned int R;
  unsigned int bit_0, endpos;
  unsigned int patlength;
  unsigned int keep, len;
  unsigned int replace, cur;
  void regchar(tchar, bool);
  void prepreprocessing(const QString& pat, bool insens);
  unsigned int preprocessing(const QString& pat, bool insens);
  tchar word[WORD_SIZE];
  unsigned int lfcnt[WORD_SIZE];
  tchar escapedchar(tchar c);
  int islower(tchar c)
    {
      return (('a' <= c) && (c <= 'z'));
    }
  tchar upper(tchar c)
    {
      return (tchar)(islower(c) ? (c - 'a' + 'A') : c);
    }
  int isupper(tchar c)
    {
      return (('A' <= c) && (c <= 'Z'));
    }
  tchar lower(tchar c)
    {
      return (tchar)(isupper(c) ? (c + 'a' - 'A') : c);
    }
 public:
  CRegExpFilt(const QString& pat, bool insens);
  ~CRegExpFilt();
  bool addch(tchar);
  void restart();
  unsigned int matchlength()
    { return patlength; }
  bool empty();
  tchar pop();
};