Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

regexp.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2005 The ClanLib Team
00004 **
00005 **  This software is provided 'as-is', without any express or implied
00006 **  warranty.  In no event will the authors be held liable for any damages
00007 **  arising from the use of this software.
00008 **
00009 **  Permission is granted to anyone to use this software for any purpose,
00010 **  including commercial applications, and to alter it and redistribute it
00011 **  freely, subject to the following restrictions:
00012 **
00013 **  1. The origin of this software must not be misrepresented; you must not
00014 **     claim that you wrote the original software. If you use this software
00015 **     in a product, an acknowledgment in the product documentation would be
00016 **     appreciated but is not required.
00017 **  2. Altered source versions must be plainly marked as such, and must not be
00018 **     misrepresented as being the original software.
00019 **  3. This notice may not be removed or altered from any source distribution.
00020 **
00021 **  Note: Some of the libraries ClanLib link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00029 #ifndef header_regexp
00030 #define header_regexp
00031 
00032 #include "regexp_match.h"
00033 #include <pcre.h>
00034 
00035 class CL_RegExp
00036 {
00038 public:
00039         CL_RegExp(const char *expression, int compile_flags = 0, bool study = false);
00040         
00041         CL_RegExp(const CL_StringA &expression, int compile_flags = 0, bool study = false);
00042         
00043         ~CL_RegExp();
00044 
00046 public:
00047         enum CompileFlags
00048         {
00049                 compile_anchored         = 1,
00050                 compile_auto_callout     = 2,
00051                 compile_caseless         = 4,
00052                 compile_dollar_endonly   = 8,
00053                 compile_dot_all          = 16,
00054                 compile_extended         = 32,
00055                 compile_extra            = 64,
00056                 compile_multi_line       = 128,
00057                 compile_no_auto_capture  = 256,
00058                 compile_ungreedy         = 512,
00059                 compile_utf8             = 1024,
00060                 compile_no_utf8_check    = 2048
00061         };
00062 
00063         enum SearchFlags
00064         {
00065                 search_anchored      = 1,
00066                 search_not_bol       = 2,
00067                 search_not_eol       = 4,
00068                 search_not_empty     = 8,
00069                 search_no_utf8_check = 16,
00070                 search_partial       = 32
00071         };
00072         
00073         int get_string_number(const char *name) const;
00074         
00075         int get_string_number(const CL_StringA &name) const;
00076 
00078 public:
00079         //: Match regular expression against a given subject string.
00080         CL_RegExpMatch search(
00081                 const char *subject,
00082                 int length,
00083                 int start_offset = 0,
00084                 int search_flags = 0) const;
00085         
00086         CL_RegExpMatch search(
00087                 const CL_StringA &subject,
00088                 int start_offset = 0,
00089                 int search_flags = 0) const;
00090         
00091         void search(
00092                 const char *subject,
00093                 int length,
00094                 int start_offset,
00095                 int search_flags,
00096                 CL_RegExpMatch &result) const;
00097 
00098         void search(
00099                 const CL_StringA &subject,
00100                 int length,
00101                 int start_offset,
00102                 int search_flags,
00103                 CL_RegExpMatch &result) const;
00104 
00106 private:
00107         void compile(const char *expression, int compile_flags, bool study);
00108 
00109         pcre *code;
00110         
00111         pcre_extra *extra;
00112 };
00113 
00114 #endif

Generated on Sat Feb 19 22:51:16 2005 for npcore by  doxygen 1.4.1