1 | /*
|
---|
2 | * Copyright (C) 1999-2000 Harri Porten ([email protected])
|
---|
3 | * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
|
---|
4 | *
|
---|
5 | * This library is free software; you can redistribute it and/or
|
---|
6 | * modify it under the terms of the GNU Lesser General Public
|
---|
7 | * License as published by the Free Software Foundation; either
|
---|
8 | * version 2 of the License, or (at your option) any later version.
|
---|
9 | *
|
---|
10 | * This library is distributed in the hope that it will be useful,
|
---|
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
13 | * Lesser General Public License for more details.
|
---|
14 | *
|
---|
15 | * You should have received a copy of the GNU Lesser General Public
|
---|
16 | * License along with this library; if not, write to the Free Software
|
---|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
---|
18 | *
|
---|
19 | */
|
---|
20 |
|
---|
21 | #ifndef KJS_REGEXP_H
|
---|
22 | #define KJS_REGEXP_H
|
---|
23 |
|
---|
24 | #include "ustring.h"
|
---|
25 | #include <wtf/Forward.h>
|
---|
26 | #include <wtf/RefCounted.h>
|
---|
27 |
|
---|
28 | struct JSRegExp;
|
---|
29 |
|
---|
30 | namespace JSC {
|
---|
31 |
|
---|
32 | class JSGlobalData;
|
---|
33 |
|
---|
34 | class RegExp : public RefCounted<RegExp> {
|
---|
35 | public:
|
---|
36 | static PassRefPtr<RegExp> create(JSGlobalData*, const UString& pattern);
|
---|
37 | static PassRefPtr<RegExp> create(JSGlobalData*, const UString& pattern, const UString& flags);
|
---|
38 | ~RegExp();
|
---|
39 |
|
---|
40 | bool global() const { return m_flagBits & Global; }
|
---|
41 | bool ignoreCase() const { return m_flagBits & IgnoreCase; }
|
---|
42 | bool multiline() const { return m_flagBits & Multiline; }
|
---|
43 |
|
---|
44 | const UString& pattern() const { return m_pattern; }
|
---|
45 | const UString& flags() const { return m_flags; }
|
---|
46 |
|
---|
47 | bool isValid() const { return !m_constructionError; }
|
---|
48 | const char* errorMessage() const { return m_constructionError; }
|
---|
49 |
|
---|
50 | int match(const UString&, int offset, OwnArrayPtr<int>* ovector = 0);
|
---|
51 | unsigned numSubpatterns() const { return m_numSubpatterns; }
|
---|
52 |
|
---|
53 | private:
|
---|
54 | RegExp(JSGlobalData*, const UString& pattern);
|
---|
55 | RegExp(JSGlobalData*, const UString& pattern, const UString& flags);
|
---|
56 |
|
---|
57 | void compile();
|
---|
58 |
|
---|
59 | enum FlagBits { Global = 1, IgnoreCase = 2, Multiline = 4 };
|
---|
60 |
|
---|
61 | UString m_pattern; // FIXME: Just decompile m_regExp instead of storing this.
|
---|
62 | UString m_flags; // FIXME: Just decompile m_regExp instead of storing this.
|
---|
63 | int m_flagBits;
|
---|
64 | JSRegExp* m_regExp;
|
---|
65 | const char* m_constructionError;
|
---|
66 | unsigned m_numSubpatterns;
|
---|
67 |
|
---|
68 | #if ENABLE(WREC)
|
---|
69 | // Called as a WRECFunction
|
---|
70 | void* m_wrecFunction;
|
---|
71 | #endif
|
---|
72 | };
|
---|
73 |
|
---|
74 | } // namespace JSC
|
---|
75 |
|
---|
76 | #endif // KJS_REGEXP_H
|
---|