]>
Commit | Line | Data |
---|---|---|
b37bf2e1 A |
1 | // -*- c-basic-offset: 2 -*- |
2 | /* | |
3 | * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) | |
4 | * Copyright (C) 2007 Apple Inc. All rights reserved. | |
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 Street, Fifth Floor, Boston, MA 02110-1301 USA | |
19 | * | |
20 | */ | |
21 | ||
22 | #ifndef KJS_REGEXP_H | |
23 | #define KJS_REGEXP_H | |
24 | ||
25 | #include "ustring.h" | |
26 | #include <pcre/pcre.h> | |
27 | #include <sys/types.h> | |
28 | #include <wtf/OwnArrayPtr.h> | |
29 | #include <wtf/RefCounted.h> | |
30 | ||
31 | namespace KJS { | |
32 | ||
33 | class RegExp : public RefCounted<RegExp> { | |
34 | private: | |
35 | enum { | |
36 | Global = 1, | |
37 | IgnoreCase = 2, | |
38 | Multiline = 4 | |
39 | }; | |
40 | ||
41 | public: | |
42 | RegExp(const UString& pattern); | |
43 | RegExp(const UString& pattern, const UString& flags); | |
44 | ~RegExp(); | |
45 | ||
46 | bool global() const { return m_flagBits & Global; } | |
47 | bool ignoreCase() const { return m_flagBits & IgnoreCase; } | |
48 | bool multiline() const { return m_flagBits & Multiline; } | |
49 | ||
50 | const UString& pattern() const { return m_pattern; } | |
51 | const UString& flags() const { return m_flags; } | |
52 | ||
53 | bool isValid() const { return !m_constructionError; } | |
54 | const char* errorMessage() const { return m_constructionError; } | |
55 | ||
56 | int match(const UString&, int offset, OwnArrayPtr<int>* ovector = 0); | |
57 | unsigned numSubpatterns() const { return m_numSubpatterns; } | |
58 | ||
59 | private: | |
60 | void compile(); | |
61 | ||
62 | // Data supplied by caller. | |
63 | UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this. | |
64 | UString m_flags; // FIXME: Just decompile m_regExp instead of storing this. | |
65 | int m_flagBits; | |
66 | ||
67 | // Data supplied by PCRE. | |
68 | JSRegExp* m_regExp; | |
69 | const char* m_constructionError; | |
70 | unsigned m_numSubpatterns; | |
71 | }; | |
72 | ||
73 | } // namespace | |
74 | ||
75 | #endif |