Skip to content
Skip to link menu
Trinity API Reference
Trinity API Reference
kjs
kjs
kjs
regexp.h
1
// -*- c-basic-offset: 2 -*-
2
/*
3
* This file is part of the KDE libraries
4
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
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 <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
RegExp(
const
UString &p,
int
f = None);
45
~RegExp();
46
int
flags()
const
{
return
flgs; }
47
UString pattern()
const
{
return
pat; }
48
bool
isValid()
const
{
return
valid; }
49
UString match(
const
UString &s,
int
i,
int
*pos = 0,
int
**ovector = 0);
50
// test is unused. The JS spec says that RegExp.test should use
51
// RegExp.exec, so it has to store $1 etc.
52
// bool test(const UString &s, int i = -1);
53
unsigned
int
subPatterns()
const
{
return
nrSubPatterns; }
54
55
//These methods should be called around the match of the same string..
56
void
prepareMatch(
const
UString &s);
57
void
doneMatch();
58
private
:
59
const
UString pat;
60
int
flgs : 8;
61
bool
m_notEmpty;
62
bool
valid;
63
64
// Cached encoding info...
65
char
* buffer;
66
int
* originalPos;
67
int
bufferSize;
68
69
void
prepareUtf8 (
const
UString& s);
70
void
prepareASCII (
const
UString& s);
71
#ifndef NDEBUG
72
UString originalS;
// the original string, used for sanity-checking
73
#endif
74
75
#ifndef HAVE_PCREPOSIX
76
regex_t preg;
77
#else
78
pcre *pcregex;
79
80
enum
UTF8SupportState {
81
Unknown,
82
Supported,
83
Unsupported
84
};
85
86
#ifdef PCRE_CONFIG_UTF8
87
static
UTF8SupportState utf8Support;
88
#endif
89
#endif
90
unsigned
int
nrSubPatterns;
91
92
RegExp();
93
};
94
95
}
// namespace
96
97
#endif
kjs
Skip menu "kjs"
Main Page
Class Hierarchy
Alphabetical List
Class List
File List
Class Members
Related Pages
kjs
Skip menu "kjs"
arts
dcop
dnssd
interfaces
interface
library
kspeech
ktexteditor
kabc
kate
kcmshell
kdecore
kded
kdefx
kdeprint
kdesu
kdeui
kdoctools
khtml
kimgio
kinit
kio
bookmarks
httpfilter
kfile
kio
kioexec
kpasswdserver
kssl
kioslave
http
kjs
kmdi
kmdi
knewstuff
kparts
krandr
kresources
kspell2
kunittest
kutils
kwallet
libkmid
libkscreensaver