1 | // -*- c-basic-offset: 2 -*-
|
---|
2 | /*
|
---|
3 | * This file is part of the KDE libraries
|
---|
4 | * Copyright (C) 1999-2000 Harri Porten ([email protected])
|
---|
5 | *
|
---|
6 | * This library is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the GNU Lesser General Public
|
---|
8 | * License as published by the Free Software Foundation; either
|
---|
9 | * version 2 of the License, or (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This library is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
14 | * Lesser General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU Lesser General Public
|
---|
17 | * License along with this library; if not, write to the Free Software
|
---|
18 | * Foundation, Inc., 51 Franklin Steet, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
19 | *
|
---|
20 | */
|
---|
21 |
|
---|
22 | #ifndef _KJS_REGEXP_H_
|
---|
23 | #define _KJS_REGEXP_H_
|
---|
24 |
|
---|
25 | #include <sys/types.h>
|
---|
26 |
|
---|
27 | #include "config.h"
|
---|
28 |
|
---|
29 | #ifdef HAVE_PCREPOSIX
|
---|
30 | #include <pcre.h>
|
---|
31 | #else // POSIX regex - not so good...
|
---|
32 | extern "C" { // bug with some libc5 distributions
|
---|
33 | #include <regex.h>
|
---|
34 | }
|
---|
35 | #endif //HAVE_PCREPOSIX
|
---|
36 |
|
---|
37 | #include "ustring.h"
|
---|
38 |
|
---|
39 | namespace KJS {
|
---|
40 |
|
---|
41 | class RegExp {
|
---|
42 | public:
|
---|
43 | enum { None = 0, Global = 1, IgnoreCase = 2, Multiline = 4 };
|
---|
44 |
|
---|
45 | RegExp(const UString &pattern, int flags = None);
|
---|
46 | ~RegExp();
|
---|
47 |
|
---|
48 | int flags() const { return _flags; }
|
---|
49 |
|
---|
50 | UString match(const UString &s, int i, int *pos = 0, int **ovector = 0);
|
---|
51 | unsigned subPatterns() const { return _numSubPatterns; }
|
---|
52 |
|
---|
53 | private:
|
---|
54 | #ifdef HAVE_PCREPOSIX
|
---|
55 | pcre *_regex;
|
---|
56 | #else
|
---|
57 | regex_t _regex;
|
---|
58 | #endif
|
---|
59 | int _flags;
|
---|
60 | unsigned _numSubPatterns;
|
---|
61 |
|
---|
62 | RegExp(const RegExp &);
|
---|
63 | RegExp &operator=(const RegExp &);
|
---|
64 | };
|
---|
65 |
|
---|
66 | } // namespace
|
---|
67 |
|
---|
68 | #endif
|
---|