• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • kjs
 

kjs

  • kjs
regexp.h
1/*
2 * This file is part of the KDE libraries
3 * Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
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 <stdint.h>
25#include <sys/types.h>
26
27#include "config.h"
28
29#ifdef HAVE_PCRE2POSIX
30#define PCRE2_CODE_UNIT_WIDTH 8
31#include <pcre2.h>
32typedef PCRE2_UCHAR8 buftype_t;
33#else // POSIX regex - not so good...
34extern "C" { // bug with some libc5 distributions
35#include <regex.h>
36typedef char buftype_t;
37}
38#endif
39
40#include "ustring.h"
41
42namespace KJS {
43
44 class RegExp {
45 public:
46 enum { None = 0, Global = 1, IgnoreCase = 2, Multiline = 4 };
47 RegExp(const UString &p, int f = None);
48 ~RegExp();
49 int flags() const { return flgs; }
50 UString pattern() const { return pat; }
51 bool isValid() const { return valid; }
52 UString match(const UString &s, int i, int *pos = 0, int **ovector = 0);
53 // test is unused. The JS spec says that RegExp.test should use
54 // RegExp.exec, so it has to store $1 etc.
55 // bool test(const UString &s, int i = -1);
56 unsigned int subPatterns() const { return nrSubPatterns; }
57
58 //These methods should be called around the match of the same string..
59 void prepareMatch(const UString &s);
60 void doneMatch();
61 private:
62 const UString pat;
63 int flgs : 8;
64 bool m_notEmpty;
65 bool valid;
66
67 // Cached encoding info...
68 buftype_t *buffer;
69 int* originalPos;
70 int bufferSize;
71
72 void prepareUtf8 (const UString& s);
73 void prepareASCII (const UString& s);
74#ifndef NDEBUG
75 UString originalS; // the original string, used for sanity-checking
76#endif
77
78#ifndef HAVE_PCRE2POSIX
79 regex_t preg;
80#else
81 pcre2_code *pcregex;
82 pcre2_match_data *match_data;
83
84 enum UTF8SupportState {
85 Unknown,
86 Supported,
87 Unsupported
88 };
89 static UTF8SupportState utf8Support;
90#endif
91 uint32_t nrSubPatterns;
92
93 RegExp();
94 };
95
96} // namespace
97
98#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
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for kjs by doxygen 1.9.4
This website is maintained by Timothy Pearson.