RegExp/regexp.h

Go to the documentation of this file.
00001 /*
00002 **  ClanLib SDK
00003 **  Copyright (c) 1997-2011 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 may link to may have additional
00022 **  requirements or restrictions.
00023 **
00024 **  File Author(s):
00025 **
00026 **    Magnus Norddahl
00027 */
00028 
00031 
00032 #pragma once
00033 
00034 #include "../Core/System/sharedptr.h"
00035 #include "api_regexp.h"
00036 #include "regexp_match.h"
00037 
00038 class CL_RegExp_Impl;
00039 
00043 class CL_API_REGEXP CL_RegExp
00044 {
00047 
00048 public:
00049 
00055         CL_RegExp(const char *expression, int compile_flags = 0, bool study = false);
00056 
00062         CL_RegExp(const CL_StringRef8 &expression, int compile_flags = 0, bool study = false);
00063 
00064         ~CL_RegExp();
00065 
00069 
00070 public:
00071         enum CompileFlags
00072         {
00073                 compile_anchored         = 1,
00074                 compile_auto_callout     = 2,
00075                 compile_caseless         = 4,
00076                 compile_dollar_endonly   = 8,
00077                 compile_dot_all          = 16,
00078                 compile_extended         = 32,
00079                 compile_extra            = 64,
00080                 compile_multi_line       = 128,
00081                 compile_no_auto_capture  = 256,
00082                 compile_ungreedy         = 512,
00083                 compile_utf8             = 1024,
00084                 compile_no_utf8_check    = 2048
00085         };
00086 
00087         enum SearchFlags
00088         {
00089                 search_anchored      = 1,
00090                 search_not_bol       = 2,
00091                 search_not_eol       = 4,
00092                 search_not_empty     = 8,
00093                 search_no_utf8_check = 16,
00094                 search_partial       = 32
00095         };
00096 
00102         int get_string_number(const char *name) const;
00103 
00109         int get_string_number(const CL_StringRef8 &name) const;
00110 
00114 
00115 public:
00117         CL_RegExpMatch search(
00118                 const char *subject,
00119                 int length,
00120                 int start_offset = 0,
00121                 int search_flags = 0) const;
00122 
00123         CL_RegExpMatch search(
00124                 const CL_StringRef8 &subject,
00125                 int start_offset = 0,
00126                 int search_flags = 0) const;
00127 
00128         void search(
00129                 const char *subject,
00130                 int length,
00131                 int start_offset,
00132                 int search_flags,
00133                 CL_RegExpMatch &result) const;
00134 
00135         void search(
00136                 const CL_StringRef8 &subject,
00137                 int start_offset,
00138                 int search_flags,
00139                 CL_RegExpMatch &result) const;
00140 
00144 
00145 private:
00146         CL_SharedPtr<CL_RegExp_Impl> impl;
00148 };
00149