kjs Library API Documentation

regexp.h

00001 // -*- c-basic-offset: 2 -*-
00002 /*
00003  *  This file is part of the KDE libraries
00004  *  Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
00005  *
00006  *  This library is free software; you can redistribute it and/or
00007  *  modify it under the terms of the GNU Lesser General Public
00008  *  License as published by the Free Software Foundation; either
00009  *  version 2 of the License, or (at your option) any later version.
00010  *
00011  *  This library is distributed in the hope that it will be useful,
00012  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  *  Lesser General Public License for more details.
00015  *
00016  *  You should have received a copy of the GNU Lesser General Public
00017  *  License along with this library; if not, write to the Free Software
00018  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  *  $Id: regexp.h,v 1.17.2.1 2003/05/17 11:19:25 mueller Exp $
00021  */
00022 
00023 #ifndef _KJS_REGEXP_H_
00024 #define _KJS_REGEXP_H_
00025 
00026 #include <sys/types.h>
00027 
00028 #include "config.h"
00029 
00030 #ifdef HAVE_PCRE
00031 #include <pcre.h>
00032 #else  // POSIX regex - not so good...
00033 extern "C" { // bug with some libc5 distributions
00034 #include <regex.h>
00035 }
00036 #endif //HAVE_PCRE
00037 
00038 #include "ustring.h"
00039 
00040 namespace KJS {
00041 
00042   class RegExp {
00043   public:
00044     enum { None = 0, Global = 1, IgnoreCase = 2, Multiline = 4 };
00045     RegExp(const UString &p, int f = None);
00046     ~RegExp();
00047     int flags() const { return flgs; }
00048     UString match(const UString &s, int i, int *pos = 0, int **ovector = 0);
00049     // test is unused. The JS spec says that RegExp.test should use
00050     // RegExp.exec, so it has to store $1 etc.
00051     // bool test(const UString &s, int i = -1);
00052     uint subPatterns() const { return nrSubPatterns; }
00053   private:
00054     const UString &pattern;
00055     int flgs;
00056     bool m_notEmpty;
00057 
00058 #ifndef HAVE_PCRE
00059     regex_t preg;
00060 #else
00061     pcre *pcregex;
00062 #endif
00063     uint nrSubPatterns;
00064 
00065     RegExp();
00066   };
00067 
00068 } // namespace
00069 
00070 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:18 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001