Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../usr/include
File: pcrecpp.h
// Copyright (c) 2005, Google Inc.
[0] Fix | Delete
// All rights reserved.
[1] Fix | Delete
//
[2] Fix | Delete
// Redistribution and use in source and binary forms, with or without
[3] Fix | Delete
// modification, are permitted provided that the following conditions are
[4] Fix | Delete
// met:
[5] Fix | Delete
//
[6] Fix | Delete
// * Redistributions of source code must retain the above copyright
[7] Fix | Delete
// notice, this list of conditions and the following disclaimer.
[8] Fix | Delete
// * Redistributions in binary form must reproduce the above
[9] Fix | Delete
// copyright notice, this list of conditions and the following disclaimer
[10] Fix | Delete
// in the documentation and/or other materials provided with the
[11] Fix | Delete
// distribution.
[12] Fix | Delete
// * Neither the name of Google Inc. nor the names of its
[13] Fix | Delete
// contributors may be used to endorse or promote products derived from
[14] Fix | Delete
// this software without specific prior written permission.
[15] Fix | Delete
//
[16] Fix | Delete
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
[17] Fix | Delete
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
[18] Fix | Delete
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
[19] Fix | Delete
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
[20] Fix | Delete
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
[21] Fix | Delete
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
[22] Fix | Delete
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
[23] Fix | Delete
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
[24] Fix | Delete
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
[25] Fix | Delete
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
[26] Fix | Delete
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
[27] Fix | Delete
//
[28] Fix | Delete
// Author: Sanjay Ghemawat
[29] Fix | Delete
// Support for PCRE_XXX modifiers added by Giuseppe Maxia, July 2005
[30] Fix | Delete
[31] Fix | Delete
#ifndef _PCRECPP_H
[32] Fix | Delete
#define _PCRECPP_H
[33] Fix | Delete
[34] Fix | Delete
// C++ interface to the pcre regular-expression library. RE supports
[35] Fix | Delete
// Perl-style regular expressions (with extensions like \d, \w, \s,
[36] Fix | Delete
// ...).
[37] Fix | Delete
//
[38] Fix | Delete
// -----------------------------------------------------------------------
[39] Fix | Delete
// REGEXP SYNTAX:
[40] Fix | Delete
//
[41] Fix | Delete
// This module is part of the pcre library and hence supports its syntax
[42] Fix | Delete
// for regular expressions.
[43] Fix | Delete
//
[44] Fix | Delete
// The syntax is pretty similar to Perl's. For those not familiar
[45] Fix | Delete
// with Perl's regular expressions, here are some examples of the most
[46] Fix | Delete
// commonly used extensions:
[47] Fix | Delete
//
[48] Fix | Delete
// "hello (\\w+) world" -- \w matches a "word" character
[49] Fix | Delete
// "version (\\d+)" -- \d matches a digit
[50] Fix | Delete
// "hello\\s+world" -- \s matches any whitespace character
[51] Fix | Delete
// "\\b(\\w+)\\b" -- \b matches empty string at a word boundary
[52] Fix | Delete
// "(?i)hello" -- (?i) turns on case-insensitive matching
[53] Fix | Delete
// "/\\*(.*?)\\*/" -- .*? matches . minimum no. of times possible
[54] Fix | Delete
//
[55] Fix | Delete
// -----------------------------------------------------------------------
[56] Fix | Delete
// MATCHING INTERFACE:
[57] Fix | Delete
//
[58] Fix | Delete
// The "FullMatch" operation checks that supplied text matches a
[59] Fix | Delete
// supplied pattern exactly.
[60] Fix | Delete
//
[61] Fix | Delete
// Example: successful match
[62] Fix | Delete
// pcrecpp::RE re("h.*o");
[63] Fix | Delete
// re.FullMatch("hello");
[64] Fix | Delete
//
[65] Fix | Delete
// Example: unsuccessful match (requires full match):
[66] Fix | Delete
// pcrecpp::RE re("e");
[67] Fix | Delete
// !re.FullMatch("hello");
[68] Fix | Delete
//
[69] Fix | Delete
// Example: creating a temporary RE object:
[70] Fix | Delete
// pcrecpp::RE("h.*o").FullMatch("hello");
[71] Fix | Delete
//
[72] Fix | Delete
// You can pass in a "const char*" or a "string" for "text". The
[73] Fix | Delete
// examples below tend to use a const char*.
[74] Fix | Delete
//
[75] Fix | Delete
// You can, as in the different examples above, store the RE object
[76] Fix | Delete
// explicitly in a variable or use a temporary RE object. The
[77] Fix | Delete
// examples below use one mode or the other arbitrarily. Either
[78] Fix | Delete
// could correctly be used for any of these examples.
[79] Fix | Delete
//
[80] Fix | Delete
// -----------------------------------------------------------------------
[81] Fix | Delete
// MATCHING WITH SUB-STRING EXTRACTION:
[82] Fix | Delete
//
[83] Fix | Delete
// You can supply extra pointer arguments to extract matched subpieces.
[84] Fix | Delete
//
[85] Fix | Delete
// Example: extracts "ruby" into "s" and 1234 into "i"
[86] Fix | Delete
// int i;
[87] Fix | Delete
// string s;
[88] Fix | Delete
// pcrecpp::RE re("(\\w+):(\\d+)");
[89] Fix | Delete
// re.FullMatch("ruby:1234", &s, &i);
[90] Fix | Delete
//
[91] Fix | Delete
// Example: does not try to extract any extra sub-patterns
[92] Fix | Delete
// re.FullMatch("ruby:1234", &s);
[93] Fix | Delete
//
[94] Fix | Delete
// Example: does not try to extract into NULL
[95] Fix | Delete
// re.FullMatch("ruby:1234", NULL, &i);
[96] Fix | Delete
//
[97] Fix | Delete
// Example: integer overflow causes failure
[98] Fix | Delete
// !re.FullMatch("ruby:1234567891234", NULL, &i);
[99] Fix | Delete
//
[100] Fix | Delete
// Example: fails because there aren't enough sub-patterns:
[101] Fix | Delete
// !pcrecpp::RE("\\w+:\\d+").FullMatch("ruby:1234", &s);
[102] Fix | Delete
//
[103] Fix | Delete
// Example: fails because string cannot be stored in integer
[104] Fix | Delete
// !pcrecpp::RE("(.*)").FullMatch("ruby", &i);
[105] Fix | Delete
//
[106] Fix | Delete
// The provided pointer arguments can be pointers to any scalar numeric
[107] Fix | Delete
// type, or one of
[108] Fix | Delete
// string (matched piece is copied to string)
[109] Fix | Delete
// StringPiece (StringPiece is mutated to point to matched piece)
[110] Fix | Delete
// T (where "bool T::ParseFrom(const char*, int)" exists)
[111] Fix | Delete
// NULL (the corresponding matched sub-pattern is not copied)
[112] Fix | Delete
//
[113] Fix | Delete
// CAVEAT: An optional sub-pattern that does not exist in the matched
[114] Fix | Delete
// string is assigned the empty string. Therefore, the following will
[115] Fix | Delete
// return false (because the empty string is not a valid number):
[116] Fix | Delete
// int number;
[117] Fix | Delete
// pcrecpp::RE::FullMatch("abc", "[a-z]+(\\d+)?", &number);
[118] Fix | Delete
//
[119] Fix | Delete
// -----------------------------------------------------------------------
[120] Fix | Delete
// DO_MATCH
[121] Fix | Delete
//
[122] Fix | Delete
// The matching interface supports at most 16 arguments per call.
[123] Fix | Delete
// If you need more, consider using the more general interface
[124] Fix | Delete
// pcrecpp::RE::DoMatch(). See pcrecpp.h for the signature for DoMatch.
[125] Fix | Delete
//
[126] Fix | Delete
// -----------------------------------------------------------------------
[127] Fix | Delete
// PARTIAL MATCHES
[128] Fix | Delete
//
[129] Fix | Delete
// You can use the "PartialMatch" operation when you want the pattern
[130] Fix | Delete
// to match any substring of the text.
[131] Fix | Delete
//
[132] Fix | Delete
// Example: simple search for a string:
[133] Fix | Delete
// pcrecpp::RE("ell").PartialMatch("hello");
[134] Fix | Delete
//
[135] Fix | Delete
// Example: find first number in a string:
[136] Fix | Delete
// int number;
[137] Fix | Delete
// pcrecpp::RE re("(\\d+)");
[138] Fix | Delete
// re.PartialMatch("x*100 + 20", &number);
[139] Fix | Delete
// assert(number == 100);
[140] Fix | Delete
//
[141] Fix | Delete
// -----------------------------------------------------------------------
[142] Fix | Delete
// UTF-8 AND THE MATCHING INTERFACE:
[143] Fix | Delete
//
[144] Fix | Delete
// By default, pattern and text are plain text, one byte per character.
[145] Fix | Delete
// The UTF8 flag, passed to the constructor, causes both pattern
[146] Fix | Delete
// and string to be treated as UTF-8 text, still a byte stream but
[147] Fix | Delete
// potentially multiple bytes per character. In practice, the text
[148] Fix | Delete
// is likelier to be UTF-8 than the pattern, but the match returned
[149] Fix | Delete
// may depend on the UTF8 flag, so always use it when matching
[150] Fix | Delete
// UTF8 text. E.g., "." will match one byte normally but with UTF8
[151] Fix | Delete
// set may match up to three bytes of a multi-byte character.
[152] Fix | Delete
//
[153] Fix | Delete
// Example:
[154] Fix | Delete
// pcrecpp::RE_Options options;
[155] Fix | Delete
// options.set_utf8();
[156] Fix | Delete
// pcrecpp::RE re(utf8_pattern, options);
[157] Fix | Delete
// re.FullMatch(utf8_string);
[158] Fix | Delete
//
[159] Fix | Delete
// Example: using the convenience function UTF8():
[160] Fix | Delete
// pcrecpp::RE re(utf8_pattern, pcrecpp::UTF8());
[161] Fix | Delete
// re.FullMatch(utf8_string);
[162] Fix | Delete
//
[163] Fix | Delete
// NOTE: The UTF8 option is ignored if pcre was not configured with the
[164] Fix | Delete
// --enable-utf8 flag.
[165] Fix | Delete
//
[166] Fix | Delete
// -----------------------------------------------------------------------
[167] Fix | Delete
// PASSING MODIFIERS TO THE REGULAR EXPRESSION ENGINE
[168] Fix | Delete
//
[169] Fix | Delete
// PCRE defines some modifiers to change the behavior of the regular
[170] Fix | Delete
// expression engine.
[171] Fix | Delete
// The C++ wrapper defines an auxiliary class, RE_Options, as a vehicle
[172] Fix | Delete
// to pass such modifiers to a RE class.
[173] Fix | Delete
//
[174] Fix | Delete
// Currently, the following modifiers are supported
[175] Fix | Delete
//
[176] Fix | Delete
// modifier description Perl corresponding
[177] Fix | Delete
//
[178] Fix | Delete
// PCRE_CASELESS case insensitive match /i
[179] Fix | Delete
// PCRE_MULTILINE multiple lines match /m
[180] Fix | Delete
// PCRE_DOTALL dot matches newlines /s
[181] Fix | Delete
// PCRE_DOLLAR_ENDONLY $ matches only at end N/A
[182] Fix | Delete
// PCRE_EXTRA strict escape parsing N/A
[183] Fix | Delete
// PCRE_EXTENDED ignore whitespaces /x
[184] Fix | Delete
// PCRE_UTF8 handles UTF8 chars built-in
[185] Fix | Delete
// PCRE_UNGREEDY reverses * and *? N/A
[186] Fix | Delete
// PCRE_NO_AUTO_CAPTURE disables matching parens N/A (*)
[187] Fix | Delete
//
[188] Fix | Delete
// (For a full account on how each modifier works, please check the
[189] Fix | Delete
// PCRE API reference manual).
[190] Fix | Delete
//
[191] Fix | Delete
// (*) Both Perl and PCRE allow non matching parentheses by means of the
[192] Fix | Delete
// "?:" modifier within the pattern itself. e.g. (?:ab|cd) does not
[193] Fix | Delete
// capture, while (ab|cd) does.
[194] Fix | Delete
//
[195] Fix | Delete
// For each modifier, there are two member functions whose name is made
[196] Fix | Delete
// out of the modifier in lowercase, without the "PCRE_" prefix. For
[197] Fix | Delete
// instance, PCRE_CASELESS is handled by
[198] Fix | Delete
// bool caseless(),
[199] Fix | Delete
// which returns true if the modifier is set, and
[200] Fix | Delete
// RE_Options & set_caseless(bool),
[201] Fix | Delete
// which sets or unsets the modifier.
[202] Fix | Delete
//
[203] Fix | Delete
// Moreover, PCRE_EXTRA_MATCH_LIMIT can be accessed through the
[204] Fix | Delete
// set_match_limit() and match_limit() member functions.
[205] Fix | Delete
// Setting match_limit to a non-zero value will limit the executation of
[206] Fix | Delete
// pcre to keep it from doing bad things like blowing the stack or taking
[207] Fix | Delete
// an eternity to return a result. A value of 5000 is good enough to stop
[208] Fix | Delete
// stack blowup in a 2MB thread stack. Setting match_limit to zero will
[209] Fix | Delete
// disable match limiting. Alternately, you can set match_limit_recursion()
[210] Fix | Delete
// which uses PCRE_EXTRA_MATCH_LIMIT_RECURSION to limit how much pcre
[211] Fix | Delete
// recurses. match_limit() caps the number of matches pcre does;
[212] Fix | Delete
// match_limit_recrusion() caps the depth of recursion.
[213] Fix | Delete
//
[214] Fix | Delete
// Normally, to pass one or more modifiers to a RE class, you declare
[215] Fix | Delete
// a RE_Options object, set the appropriate options, and pass this
[216] Fix | Delete
// object to a RE constructor. Example:
[217] Fix | Delete
//
[218] Fix | Delete
// RE_options opt;
[219] Fix | Delete
// opt.set_caseless(true);
[220] Fix | Delete
//
[221] Fix | Delete
// if (RE("HELLO", opt).PartialMatch("hello world")) ...
[222] Fix | Delete
//
[223] Fix | Delete
// RE_options has two constructors. The default constructor takes no
[224] Fix | Delete
// arguments and creates a set of flags that are off by default.
[225] Fix | Delete
//
[226] Fix | Delete
// The optional parameter 'option_flags' is to facilitate transfer
[227] Fix | Delete
// of legacy code from C programs. This lets you do
[228] Fix | Delete
// RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
[229] Fix | Delete
//
[230] Fix | Delete
// But new code is better off doing
[231] Fix | Delete
// RE(pattern,
[232] Fix | Delete
// RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
[233] Fix | Delete
// (See below)
[234] Fix | Delete
//
[235] Fix | Delete
// If you are going to pass one of the most used modifiers, there are some
[236] Fix | Delete
// convenience functions that return a RE_Options class with the
[237] Fix | Delete
// appropriate modifier already set:
[238] Fix | Delete
// CASELESS(), UTF8(), MULTILINE(), DOTALL(), EXTENDED()
[239] Fix | Delete
//
[240] Fix | Delete
// If you need to set several options at once, and you don't want to go
[241] Fix | Delete
// through the pains of declaring a RE_Options object and setting several
[242] Fix | Delete
// options, there is a parallel method that give you such ability on the
[243] Fix | Delete
// fly. You can concatenate several set_xxxxx member functions, since each
[244] Fix | Delete
// of them returns a reference to its class object. e.g.: to pass
[245] Fix | Delete
// PCRE_CASELESS, PCRE_EXTENDED, and PCRE_MULTILINE to a RE with one
[246] Fix | Delete
// statement, you may write
[247] Fix | Delete
//
[248] Fix | Delete
// RE(" ^ xyz \\s+ .* blah$", RE_Options()
[249] Fix | Delete
// .set_caseless(true)
[250] Fix | Delete
// .set_extended(true)
[251] Fix | Delete
// .set_multiline(true)).PartialMatch(sometext);
[252] Fix | Delete
//
[253] Fix | Delete
// -----------------------------------------------------------------------
[254] Fix | Delete
// SCANNING TEXT INCREMENTALLY
[255] Fix | Delete
//
[256] Fix | Delete
// The "Consume" operation may be useful if you want to repeatedly
[257] Fix | Delete
// match regular expressions at the front of a string and skip over
[258] Fix | Delete
// them as they match. This requires use of the "StringPiece" type,
[259] Fix | Delete
// which represents a sub-range of a real string. Like RE, StringPiece
[260] Fix | Delete
// is defined in the pcrecpp namespace.
[261] Fix | Delete
//
[262] Fix | Delete
// Example: read lines of the form "var = value" from a string.
[263] Fix | Delete
// string contents = ...; // Fill string somehow
[264] Fix | Delete
// pcrecpp::StringPiece input(contents); // Wrap in a StringPiece
[265] Fix | Delete
//
[266] Fix | Delete
// string var;
[267] Fix | Delete
// int value;
[268] Fix | Delete
// pcrecpp::RE re("(\\w+) = (\\d+)\n");
[269] Fix | Delete
// while (re.Consume(&input, &var, &value)) {
[270] Fix | Delete
// ...;
[271] Fix | Delete
// }
[272] Fix | Delete
//
[273] Fix | Delete
// Each successful call to "Consume" will set "var/value", and also
[274] Fix | Delete
// advance "input" so it points past the matched text.
[275] Fix | Delete
//
[276] Fix | Delete
// The "FindAndConsume" operation is similar to "Consume" but does not
[277] Fix | Delete
// anchor your match at the beginning of the string. For example, you
[278] Fix | Delete
// could extract all words from a string by repeatedly calling
[279] Fix | Delete
// pcrecpp::RE("(\\w+)").FindAndConsume(&input, &word)
[280] Fix | Delete
//
[281] Fix | Delete
// -----------------------------------------------------------------------
[282] Fix | Delete
// PARSING HEX/OCTAL/C-RADIX NUMBERS
[283] Fix | Delete
//
[284] Fix | Delete
// By default, if you pass a pointer to a numeric value, the
[285] Fix | Delete
// corresponding text is interpreted as a base-10 number. You can
[286] Fix | Delete
// instead wrap the pointer with a call to one of the operators Hex(),
[287] Fix | Delete
// Octal(), or CRadix() to interpret the text in another base. The
[288] Fix | Delete
// CRadix operator interprets C-style "0" (base-8) and "0x" (base-16)
[289] Fix | Delete
// prefixes, but defaults to base-10.
[290] Fix | Delete
//
[291] Fix | Delete
// Example:
[292] Fix | Delete
// int a, b, c, d;
[293] Fix | Delete
// pcrecpp::RE re("(.*) (.*) (.*) (.*)");
[294] Fix | Delete
// re.FullMatch("100 40 0100 0x40",
[295] Fix | Delete
// pcrecpp::Octal(&a), pcrecpp::Hex(&b),
[296] Fix | Delete
// pcrecpp::CRadix(&c), pcrecpp::CRadix(&d));
[297] Fix | Delete
// will leave 64 in a, b, c, and d.
[298] Fix | Delete
//
[299] Fix | Delete
// -----------------------------------------------------------------------
[300] Fix | Delete
// REPLACING PARTS OF STRINGS
[301] Fix | Delete
//
[302] Fix | Delete
// You can replace the first match of "pattern" in "str" with
[303] Fix | Delete
// "rewrite". Within "rewrite", backslash-escaped digits (\1 to \9)
[304] Fix | Delete
// can be used to insert text matching corresponding parenthesized
[305] Fix | Delete
// group from the pattern. \0 in "rewrite" refers to the entire
[306] Fix | Delete
// matching text. E.g.,
[307] Fix | Delete
//
[308] Fix | Delete
// string s = "yabba dabba doo";
[309] Fix | Delete
// pcrecpp::RE("b+").Replace("d", &s);
[310] Fix | Delete
//
[311] Fix | Delete
// will leave "s" containing "yada dabba doo". The result is true if
[312] Fix | Delete
// the pattern matches and a replacement occurs, or false otherwise.
[313] Fix | Delete
//
[314] Fix | Delete
// GlobalReplace() is like Replace(), except that it replaces all
[315] Fix | Delete
// occurrences of the pattern in the string with the rewrite.
[316] Fix | Delete
// Replacements are not subject to re-matching. E.g.,
[317] Fix | Delete
//
[318] Fix | Delete
// string s = "yabba dabba doo";
[319] Fix | Delete
// pcrecpp::RE("b+").GlobalReplace("d", &s);
[320] Fix | Delete
//
[321] Fix | Delete
// will leave "s" containing "yada dada doo". It returns the number
[322] Fix | Delete
// of replacements made.
[323] Fix | Delete
//
[324] Fix | Delete
// Extract() is like Replace(), except that if the pattern matches,
[325] Fix | Delete
// "rewrite" is copied into "out" (an additional argument) with
[326] Fix | Delete
// substitutions. The non-matching portions of "text" are ignored.
[327] Fix | Delete
// Returns true iff a match occurred and the extraction happened
[328] Fix | Delete
// successfully. If no match occurs, the string is left unaffected.
[329] Fix | Delete
[330] Fix | Delete
[331] Fix | Delete
#include <string>
[332] Fix | Delete
#include <pcre.h>
[333] Fix | Delete
#include <pcrecpparg.h> // defines the Arg class
[334] Fix | Delete
// This isn't technically needed here, but we include it
[335] Fix | Delete
// anyway so folks who include pcrecpp.h don't have to.
[336] Fix | Delete
#include <pcre_stringpiece.h>
[337] Fix | Delete
[338] Fix | Delete
namespace pcrecpp {
[339] Fix | Delete
[340] Fix | Delete
#define PCRE_SET_OR_CLEAR(b, o) \
[341] Fix | Delete
if (b) all_options_ |= (o); else all_options_ &= ~(o); \
[342] Fix | Delete
return *this
[343] Fix | Delete
[344] Fix | Delete
#define PCRE_IS_SET(o) \
[345] Fix | Delete
(all_options_ & o) == o
[346] Fix | Delete
[347] Fix | Delete
/***** Compiling regular expressions: the RE class *****/
[348] Fix | Delete
[349] Fix | Delete
// RE_Options allow you to set options to be passed along to pcre,
[350] Fix | Delete
// along with other options we put on top of pcre.
[351] Fix | Delete
// Only 9 modifiers, plus match_limit and match_limit_recursion,
[352] Fix | Delete
// are supported now.
[353] Fix | Delete
class PCRECPP_EXP_DEFN RE_Options {
[354] Fix | Delete
public:
[355] Fix | Delete
// constructor
[356] Fix | Delete
RE_Options() : match_limit_(0), match_limit_recursion_(0), all_options_(0) {}
[357] Fix | Delete
[358] Fix | Delete
// alternative constructor.
[359] Fix | Delete
// To facilitate transfer of legacy code from C programs
[360] Fix | Delete
//
[361] Fix | Delete
// This lets you do
[362] Fix | Delete
// RE(pattern, RE_Options(PCRE_CASELESS|PCRE_MULTILINE)).PartialMatch(str);
[363] Fix | Delete
// But new code is better off doing
[364] Fix | Delete
// RE(pattern,
[365] Fix | Delete
// RE_Options().set_caseless(true).set_multiline(true)).PartialMatch(str);
[366] Fix | Delete
RE_Options(int option_flags) : match_limit_(0), match_limit_recursion_(0),
[367] Fix | Delete
all_options_(option_flags) {}
[368] Fix | Delete
// we're fine with the default destructor, copy constructor, etc.
[369] Fix | Delete
[370] Fix | Delete
// accessors and mutators
[371] Fix | Delete
int match_limit() const { return match_limit_; };
[372] Fix | Delete
RE_Options &set_match_limit(int limit) {
[373] Fix | Delete
match_limit_ = limit;
[374] Fix | Delete
return *this;
[375] Fix | Delete
}
[376] Fix | Delete
[377] Fix | Delete
int match_limit_recursion() const { return match_limit_recursion_; };
[378] Fix | Delete
RE_Options &set_match_limit_recursion(int limit) {
[379] Fix | Delete
match_limit_recursion_ = limit;
[380] Fix | Delete
return *this;
[381] Fix | Delete
}
[382] Fix | Delete
[383] Fix | Delete
bool caseless() const {
[384] Fix | Delete
return PCRE_IS_SET(PCRE_CASELESS);
[385] Fix | Delete
}
[386] Fix | Delete
RE_Options &set_caseless(bool x) {
[387] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_CASELESS);
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
bool multiline() const {
[391] Fix | Delete
return PCRE_IS_SET(PCRE_MULTILINE);
[392] Fix | Delete
}
[393] Fix | Delete
RE_Options &set_multiline(bool x) {
[394] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_MULTILINE);
[395] Fix | Delete
}
[396] Fix | Delete
[397] Fix | Delete
bool dotall() const {
[398] Fix | Delete
return PCRE_IS_SET(PCRE_DOTALL);
[399] Fix | Delete
}
[400] Fix | Delete
RE_Options &set_dotall(bool x) {
[401] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_DOTALL);
[402] Fix | Delete
}
[403] Fix | Delete
[404] Fix | Delete
bool extended() const {
[405] Fix | Delete
return PCRE_IS_SET(PCRE_EXTENDED);
[406] Fix | Delete
}
[407] Fix | Delete
RE_Options &set_extended(bool x) {
[408] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_EXTENDED);
[409] Fix | Delete
}
[410] Fix | Delete
[411] Fix | Delete
bool dollar_endonly() const {
[412] Fix | Delete
return PCRE_IS_SET(PCRE_DOLLAR_ENDONLY);
[413] Fix | Delete
}
[414] Fix | Delete
RE_Options &set_dollar_endonly(bool x) {
[415] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_DOLLAR_ENDONLY);
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
bool extra() const {
[419] Fix | Delete
return PCRE_IS_SET(PCRE_EXTRA);
[420] Fix | Delete
}
[421] Fix | Delete
RE_Options &set_extra(bool x) {
[422] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_EXTRA);
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
bool ungreedy() const {
[426] Fix | Delete
return PCRE_IS_SET(PCRE_UNGREEDY);
[427] Fix | Delete
}
[428] Fix | Delete
RE_Options &set_ungreedy(bool x) {
[429] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_UNGREEDY);
[430] Fix | Delete
}
[431] Fix | Delete
[432] Fix | Delete
bool utf8() const {
[433] Fix | Delete
return PCRE_IS_SET(PCRE_UTF8);
[434] Fix | Delete
}
[435] Fix | Delete
RE_Options &set_utf8(bool x) {
[436] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_UTF8);
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
bool no_auto_capture() const {
[440] Fix | Delete
return PCRE_IS_SET(PCRE_NO_AUTO_CAPTURE);
[441] Fix | Delete
}
[442] Fix | Delete
RE_Options &set_no_auto_capture(bool x) {
[443] Fix | Delete
PCRE_SET_OR_CLEAR(x, PCRE_NO_AUTO_CAPTURE);
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
RE_Options &set_all_options(int opt) {
[447] Fix | Delete
all_options_ = opt;
[448] Fix | Delete
return *this;
[449] Fix | Delete
}
[450] Fix | Delete
int all_options() const {
[451] Fix | Delete
return all_options_ ;
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
// TODO: add other pcre flags
[455] Fix | Delete
[456] Fix | Delete
private:
[457] Fix | Delete
int match_limit_;
[458] Fix | Delete
int match_limit_recursion_;
[459] Fix | Delete
int all_options_;
[460] Fix | Delete
};
[461] Fix | Delete
[462] Fix | Delete
// These functions return some common RE_Options
[463] Fix | Delete
static inline RE_Options UTF8() {
[464] Fix | Delete
return RE_Options().set_utf8(true);
[465] Fix | Delete
}
[466] Fix | Delete
[467] Fix | Delete
static inline RE_Options CASELESS() {
[468] Fix | Delete
return RE_Options().set_caseless(true);
[469] Fix | Delete
}
[470] Fix | Delete
static inline RE_Options MULTILINE() {
[471] Fix | Delete
return RE_Options().set_multiline(true);
[472] Fix | Delete
}
[473] Fix | Delete
[474] Fix | Delete
static inline RE_Options DOTALL() {
[475] Fix | Delete
return RE_Options().set_dotall(true);
[476] Fix | Delete
}
[477] Fix | Delete
[478] Fix | Delete
static inline RE_Options EXTENDED() {
[479] Fix | Delete
return RE_Options().set_extended(true);
[480] Fix | Delete
}
[481] Fix | Delete
[482] Fix | Delete
// Interface for regular expression matching. Also corresponds to a
[483] Fix | Delete
// pre-compiled regular expression. An "RE" object is safe for
[484] Fix | Delete
// concurrent use by multiple threads.
[485] Fix | Delete
class PCRECPP_EXP_DEFN RE {
[486] Fix | Delete
public:
[487] Fix | Delete
// We provide implicit conversions from strings so that users can
[488] Fix | Delete
// pass in a string or a "const char*" wherever an "RE" is expected.
[489] Fix | Delete
RE(const string& pat) { Init(pat, NULL); }
[490] Fix | Delete
RE(const string& pat, const RE_Options& option) { Init(pat, &option); }
[491] Fix | Delete
RE(const char* pat) { Init(pat, NULL); }
[492] Fix | Delete
RE(const char* pat, const RE_Options& option) { Init(pat, &option); }
[493] Fix | Delete
RE(const unsigned char* pat) {
[494] Fix | Delete
Init(reinterpret_cast<const char*>(pat), NULL);
[495] Fix | Delete
}
[496] Fix | Delete
RE(const unsigned char* pat, const RE_Options& option) {
[497] Fix | Delete
Init(reinterpret_cast<const char*>(pat), &option);
[498] Fix | Delete
}
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function