1 // -*- c-basic-offset: 2 -*-
3 * This file is part of the KDE libraries
4 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
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.
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.
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
22 #ifndef _KJS_REGEXP_H_
23 #define _KJS_REGEXP_H_
25 #include <sys/types.h>
33 #else // POSIX regex - not so good...
34 extern "C" { // bug with some libc5 distributions
37 #endif //HAVE_PCREPOSIX
45 enum { None
= 0, Global
= 1, IgnoreCase
= 2, Multiline
= 4 };
47 explicit RegExp(const UString
&pattern
, char flags
= None
);
50 char flags() const { return _flags
; }
51 bool isValid() const { return _valid
; }
53 UString
match(const UString
&s
, bool *error
, int i
, int *pos
= 0, int **ovector
= 0);
54 unsigned subPatterns() const { return _numSubPatterns
; }
55 UString
pattern() const { return _pat
; }
57 //These methods should be called around the match of the same string..
58 void prepareMatch(const UString
&s
);
70 unsigned _numSubPatterns
;
72 // Cached encoding info...
77 void prepareUtf8 (const UString
& s
);
78 void prepareASCII (const UString
& s
);
80 UString _originalS
; // the original string, used for sanity-checking
83 RegExp(const RegExp
&);
84 RegExp
&operator=(const RegExp
&);
86 enum UTF8SupportState
{
92 static UTF8SupportState utf8Support
;