tools/qregularexpression.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2012 Giuseppe D'Angelo <dangelog@gmail.com>. -
4** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
5** Contact: http://www.qt-project.org/legal -
6** -
7** This file is part of the QtCore module of the Qt Toolkit. -
8** -
9** $QT_BEGIN_LICENSE:LGPL$ -
10** Commercial License Usage -
11** Licensees holding valid commercial Qt licenses may use this file in -
12** accordance with the commercial license agreement provided with the -
13** Software or, alternatively, in accordance with the terms contained in -
14** a written agreement between you and Digia. For licensing terms and -
15** conditions see http://qt.digia.com/licensing. For further information -
16** use the contact form at http://qt.digia.com/contact-us. -
17** -
18** GNU Lesser General Public License Usage -
19** Alternatively, this file may be used under the terms of the GNU Lesser -
20** General Public License version 2.1 as published by the Free Software -
21** Foundation and appearing in the file LICENSE.LGPL included in the -
22** packaging of this file. Please review the following information to -
23** ensure the GNU Lesser General Public License version 2.1 requirements -
24** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
25** -
26** In addition, as a special exception, Digia gives you certain additional -
27** rights. These rights are described in the Digia Qt LGPL Exception -
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
29** -
30** GNU General Public License Usage -
31** Alternatively, this file may be used under the terms of the GNU -
32** General Public License version 3.0 as published by the Free Software -
33** Foundation and appearing in the file LICENSE.GPL included in the -
34** packaging of this file. Please review the following information to -
35** ensure the GNU General Public License version 3.0 requirements will be -
36** met: http://www.gnu.org/copyleft/gpl.html. -
37** -
38** -
39** $QT_END_LICENSE$ -
40** -
41****************************************************************************/ -
42 -
43#include "qregularexpression.h" -
44 -
45#include <QtCore/qcoreapplication.h> -
46#include <QtCore/qmutex.h> -
47#include <QtCore/qvector.h> -
48#include <QtCore/qstringlist.h> -
49#include <QtCore/qdebug.h> -
50#include <QtCore/qthreadstorage.h> -
51#include <QtCore/qglobal.h> -
52 -
53#include <pcre.h> -
54 -
55QT_BEGIN_NAMESPACE -
56 -
57/*! -
58 \class QRegularExpression -
59 \inmodule QtCore -
60 \reentrant -
61 -
62 \brief The QRegularExpression class provides pattern matching using regular -
63 expressions. -
64 -
65 \since 5.0 -
66 -
67 \ingroup tools -
68 \ingroup shared -
69 -
70 \keyword regular expression -
71 -
72 Regular expressions, or \e{regexps}, are a very powerful tool to handle -
73 strings and texts. This is useful in many contexts, e.g., -
74 -
75 \table -
76 \row \li Validation -
77 \li A regexp can test whether a substring meets some criteria, -
78 e.g. is an integer or contains no whitespace. -
79 \row \li Searching -
80 \li A regexp provides more powerful pattern matching than -
81 simple substring matching, e.g., match one of the words -
82 \e{mail}, \e{letter} or \e{correspondence}, but none of the -
83 words \e{email}, \e{mailman}, \e{mailer}, \e{letterbox}, etc. -
84 \row \li Search and Replace -
85 \li A regexp can replace all occurrences of a substring with a -
86 different substring, e.g., replace all occurrences of \e{&} -
87 with \e{\&amp;} except where the \e{&} is already followed by -
88 an \e{amp;}. -
89 \row \li String Splitting -
90 \li A regexp can be used to identify where a string should be -
91 split apart, e.g. splitting tab-delimited strings. -
92 \endtable -
93 -
94 This document is by no means a complete reference to pattern matching using -
95 regular expressions, and the following parts will require the reader to -
96 have some basic knowledge about Perl-like regular expressions and their -
97 pattern syntax. -
98 -
99 Good references about regular expressions include: -
100 -
101 \list -
102 \li \e {Mastering Regular Expressions} (Third Edition) by Jeffrey E. F. -
103 Friedl, ISBN 0-596-52812-4; -
104 \li the \l{http://pcre.org/pcre.txt} {pcrepattern(3)} man page, describing -
105 the pattern syntax supported by PCRE (the reference implementation of -
106 Perl-compatible regular expressions); -
107 \li the \l{http://perldoc.perl.org/perlre.html} {Perl's regular expression -
108 documentation} and the \l{http://perldoc.perl.org/perlretut.html} {Perl's -
109 regular expression tutorial}. -
110 \endlist -
111 -
112 \tableofcontents -
113 -
114 \section1 Introduction -
115 -
116 QRegularExpression implements Perl-compatible regular expressions. It fully -
117 supports Unicode. For an overview of the regular expression syntax -
118 supported by QRegularExpression, please refer to the aforementioned -
119 pcrepattern(3) man page. A regular expression is made up of two things: a -
120 \b{pattern string} and a set of \b{pattern options} that change the -
121 meaning of the pattern string. -
122 -
123 You can set the pattern string by passing a string to the QRegularExpression -
124 constructor: -
125 -
126 \snippet code/src_corelib_tools_qregularexpression.cpp 0 -
127 -
128 This sets the pattern string to \c{a pattern}. You can also use the -
129 setPattern() function to set a pattern on an existing QRegularExpression -
130 object: -
131 -
132 \snippet code/src_corelib_tools_qregularexpression.cpp 1 -
133 -
134 Note that due to C++ literal strings rules, you must escape all backslashes -
135 inside the pattern string with another backslash: -
136 -
137 \snippet code/src_corelib_tools_qregularexpression.cpp 2 -
138 -
139 The pattern() function returns the pattern that is currently set for a -
140 QRegularExpression object: -
141 -
142 \snippet code/src_corelib_tools_qregularexpression.cpp 3 -
143 -
144 \section1 Pattern options -
145 -
146 The meaning of the pattern string can be modified by setting one or more -
147 \e{pattern options}. For instance, it is possible to set a pattern to match -
148 case insensitively by setting the QRegularExpression::CaseInsensitiveOption. -
149 -
150 You can set the options by passing them to the QRegularExpression -
151 constructor, as in: -
152 -
153 \snippet code/src_corelib_tools_qregularexpression.cpp 4 -
154 -
155 Alternatively, you can use the setPatternOptions() function on an existing -
156 QRegularExpressionObject: -
157 -
158 \snippet code/src_corelib_tools_qregularexpression.cpp 5 -
159 -
160 It is possible to get the pattern options currently set on a -
161 QRegularExpression object by using the patternOptions() function: -
162 -
163 \snippet code/src_corelib_tools_qregularexpression.cpp 6 -
164 -
165 Please refer to the QRegularExpression::PatternOption enum documentation for -
166 more information about each pattern option. -
167 -
168 \section1 Match type and match options -
169 -
170 The last two arguments of the match() and the globalMatch() functions set -
171 the match type and the match options. The match type is a value of the -
172 QRegularExpression::MatchType enum; the "traditional" matching algorithm is -
173 chosen by using the NormalMatch match type (the default). It is also -
174 possible to enable partial matching of the regular expression against a -
175 subject string: see the \l{partial matching} section for more details. -
176 -
177 The match options are a set of one or more QRegularExpression::MatchOption -
178 values. They change the way a specific match of a regular expression -
179 against a subject string is done. Please refer to the -
180 QRegularExpression::MatchOption enum documentation for more details. -
181 -
182 \target normal matching -
183 \section1 Normal matching -
184 -
185 In order to perform a match you can simply invoke the match() function -
186 passing a string to match against. We refer to this string as the -
187 \e{subject string}. The result of the match() function is a -
188 QRegularExpressionMatch object that can be used to inspect the results of -
189 the match. For instance: -
190 -
191 \snippet code/src_corelib_tools_qregularexpression.cpp 7 -
192 -
193 If a match is successful, the (implicit) capturing group number 0 can be -
194 used to retrieve the substring matched by the entire pattern (see also the -
195 section about \l{extracting captured substrings}): -
196 -
197 \snippet code/src_corelib_tools_qregularexpression.cpp 8 -
198 -
199 It's also possible to start a match at an arbitrary offset inside the -
200 subject string by passing the offset as an argument of the -
201 match() function. In the following example \c{"12 abc"} -
202 is not matched because the match is started at offset 1: -
203 -
204 \snippet code/src_corelib_tools_qregularexpression.cpp 9 -
205 -
206 \target extracting captured substrings -
207 \section2 Extracting captured substrings -
208 -
209 The QRegularExpressionMatch object contains also information about the -
210 substrings captured by the capturing groups in the pattern string. The -
211 \l{QRegularExpressionMatch::}{captured()} function will return the string -
212 captured by the n-th capturing group: -
213 -
214 \snippet code/src_corelib_tools_qregularexpression.cpp 10 -
215 -
216 Capturing groups in the pattern are numbered starting from 1, and the -
217 implicit capturing group 0 is used to capture the substring that matched -
218 the entire pattern. -
219 -
220 It's also possible to retrieve the starting and the ending offsets (inside -
221 the subject string) of each captured substring, by using the -
222 \l{QRegularExpressionMatch::}{capturedStart()} and the -
223 \l{QRegularExpressionMatch::}{capturedEnd()} functions: -
224 -
225 \snippet code/src_corelib_tools_qregularexpression.cpp 11 -
226 -
227 All of these functions have an overload taking a QString as a parameter -
228 in order to extract \e{named} captured substrings. For instance: -
229 -
230 \snippet code/src_corelib_tools_qregularexpression.cpp 12 -
231 -
232 \target global matching -
233 \section1 Global matching -
234 -
235 \e{Global matching} is useful to find all the occurrences of a given -
236 regular expression inside a subject string. Suppose that we want to extract -
237 all the words from a given string, where a word is a substring matching -
238 the pattern \c{\w+}. -
239 -
240 QRegularExpression::globalMatch returns a QRegularExpressionMatchIterator, -
241 which is a Java-like forward iterator that can be used to iterate over the -
242 results. For instance: -
243 -
244 \snippet code/src_corelib_tools_qregularexpression.cpp 13 -
245 -
246 Since it's a Java-like iterator, the QRegularExpressionMatchIterator will -
247 point immediately before the first result. Every result is returned as a -
248 QRegularExpressionMatch object. The -
249 \l{QRegularExpressionMatchIterator::}{hasNext()} function will return true -
250 if there's at least one more result, and -
251 \l{QRegularExpressionMatchIterator::}{next()} will return the next result -
252 and advance the iterator. Continuing from the previous example: -
253 -
254 \snippet code/src_corelib_tools_qregularexpression.cpp 14 -
255 -
256 You can also use \l{QRegularExpressionMatchIterator::}{peekNext()} to get -
257 the next result without advancing the iterator. -
258 -
259 It is possible to pass a starting offset and one or more match options to -
260 the globalMatch() function, exactly like normal matching with match(). -
261 -
262 \target partial matching -
263 \section1 Partial matching -
264 -
265 A \e{partial match} is obtained when the end of the subject string is -
266 reached, but more characters are needed to successfully complete the match. -
267 Note that a partial match is usually much more inefficient than a normal -
268 match because many optimizations of the matching algorithm cannot be -
269 employed. -
270 -
271 A partial match must be explicitly requested by specifying a match type of -
272 PartialPreferCompleteMatch or PartialPreferFirstMatch when calling -
273 QRegularExpression::match or QRegularExpression::globalMatch. If a partial -
274 match is found, then calling the \l{QRegularExpressionMatch::}{hasMatch()} -
275 function on the QRegularExpressionMatch object returned by match() will -
276 return \c{false}, but \l{QRegularExpressionMatch::}{hasPartialMatch()} will return -
277 \c{true}. -
278 -
279 When a partial match is found, no captured substrings are returned, and the -
280 (implicit) capturing group 0 corresponding to the whole match captures the -
281 partially matched substring of the subject string. -
282 -
283 Note that asking for a partial match can still lead to a complete match, if -
284 one is found; in this case, \l{QRegularExpressionMatch::}{hasMatch()} will -
285 return \c{true} and \l{QRegularExpressionMatch::}{hasPartialMatch()} -
286 \c{false}. It never happens that a QRegularExpressionMatch reports both a -
287 partial and a complete match. -
288 -
289 Partial matching is mainly useful in two scenarios: validating user input -
290 in real time and incremental/multi-segment matching. -
291 -
292 \target validating user input -
293 \section2 Validating user input -
294 -
295 Suppose that we would like the user to input a date in a specific -
296 format, for instance "MMM dd, yyyy". We can check the input validity with -
297 a pattern like: -
298 -
299 \c{^(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) \d\d?, \d\d\d\d$} -
300 -
301 (This pattern doesn't catch invalid days, but let's keep it for the -
302 example's purposes). -
303 -
304 We would like to validate the input with this regular expression \e{while} -
305 the user is typing it, so that we can report an error in the input as soon -
306 as it is committed (for instance, the user typed the wrong key). In order -
307 to do so we must distinguish three cases: -
308 -
309 \list -
310 \li the input cannot possibly match the regular expression; -
311 \li the input does match the regular expression; -
312 \li the input does not match the regular expression right now, -
313 but it will if more characters will be added to it. -
314 \endlist -
315 -
316 Note that these three cases represent exactly the possible states of a -
317 QValidator (see the QValidator::State enum). -
318 -
319 In particular, in the last case we want the regular expression engine to -
320 report a partial match: we are successfully matching the pattern against -
321 the subject string but the matching cannot continue because the end of the -
322 subject is encountered. Notice, however, that the matching algorithm should -
323 continue and try all possibilities, and in case a complete (non-partial) -
324 match is found, then this one should be reported, and the input string -
325 accepted as fully valid. -
326 -
327 This behaviour is implemented by the PartialPreferCompleteMatch match type. -
328 For instance: -
329 -
330 \snippet code/src_corelib_tools_qregularexpression.cpp 15 -
331 -
332 If matching the same regular expression against the subject string leads to -
333 a complete match, it is reported as usual: -
334 -
335 \snippet code/src_corelib_tools_qregularexpression.cpp 16 -
336 -
337 Another example with a different pattern, showing the behaviour of -
338 preferring a complete match over a partial one: -
339 -
340 \snippet code/src_corelib_tools_qregularexpression.cpp 17 -
341 -
342 In this case, the subpattern \c{abc\\w+X} partially matches the subject -
343 string; however, the subpattern \c{def} matches the subject string -
344 completely, and therefore a complete match is reported. -
345 -
346 If multiple partial matches are found when matching (but no complete -
347 match), then the QRegularExpressionMatch object will report the first one -
348 that is found. For instance: -
349 -
350 \snippet code/src_corelib_tools_qregularexpression.cpp 18 -
351 -
352 \section2 Incremental/multi-segment matching -
353 -
354 Incremental matching is another use case of partial matching. Suppose that -
355 we want to find the occurrences of a regular expression inside a large text -
356 (that is, substrings matching the regular expression). In order to do so we -
357 would like to "feed" the large text to the regular expression engines in -
358 smaller chunks. The obvious problem is what happens if the substring that -
359 matches the regular expression spans across two or more chunks. -
360 -
361 In this case, the regular expression engine should report a partial match, -
362 so that we can match again adding new data and (eventually) get a complete -
363 match. This implies that the regular expression engine may assume that -
364 there are other characters \e{beyond the end} of the subject string. This -
365 is not to be taken literally -- the engine will never try to access -
366 any character after the last one in the subject. -
367 -
368 QRegularExpression implements this behaviour when using the -
369 PartialPreferFirstMatch match type. This match type reports a partial match -
370 as soon as it is found, and other match alternatives are not tried -
371 (even if they could lead to a complete match). For instance: -
372 -
373 \snippet code/src_corelib_tools_qregularexpression.cpp 19 -
374 -
375 This happens because when matching the first branch of the alternation -
376 operator a partial match is found, and therefore matching stops, without -
377 trying the second branch. Another example: -
378 -
379 \snippet code/src_corelib_tools_qregularexpression.cpp 20 -
380 -
381 This shows what could seem a counterintuitve behaviour of quantifiers: -
382 since \c{?} is greedy, then the engine tries first to continue the match -
383 after having matched \c{"abc"}; but then the matching reaches the end of the -
384 subject string, and therefore a partial match is reported. This is -
385 even more surprising in the following example: -
386 -
387 \snippet code/src_corelib_tools_qregularexpression.cpp 21 -
388 -
389 It's easy to understand this behaviour if we remember that the engine -
390 expects the subject string to be only a substring of the whole text we're -
391 looking for a match into (that is, how we said before, that the engine -
392 assumes that there are other characters beyond the end of the subject -
393 string). -
394 -
395 Since the \c{*} quantifier is greedy, then reporting a complete match could -
396 be an error, because after the current subject \c{"abc"} there may be other -
397 occurrences of \c{"abc"}. For instance, the complete text could have been -
398 "abcabcX", and therefore the \e{right} match to report (in the complete -
399 text) would have been \c{"abcabc"}; by matching only against the leading -
400 \c{"abc"} we instead get a partial match. -
401 -
402 \section1 Error handling -
403 -
404 It is possible for a QRegularExpression object to be invalid because of -
405 syntax errors in the pattern string. The isValid() function will return -
406 true if the regular expression is valid, or false otherwise: -
407 -
408 \snippet code/src_corelib_tools_qregularexpression.cpp 22 -
409 -
410 You can get more information about the specific error by calling the -
411 errorString() function; moreover, the patternErrorOffset() function -
412 will return the offset inside the pattern string -
413 -
414 \snippet code/src_corelib_tools_qregularexpression.cpp 23 -
415 -
416 If a match is attempted with an invalid QRegularExpression, then the -
417 returned QRegularExpressionMatch object will be invalid as well (that is, -
418 its \l{QRegularExpressionMatch::}{isValid()} function will return false). -
419 The same applies for attempting a global match. -
420 -
421 \section1 Unsupported Perl-compatible regular expressions features -
422 -
423 QRegularExpression does not support all the features available in -
424 Perl-compatible regular expressions. The most notable one is the fact that -
425 duplicated names for capturing groups are not supported, and using them can -
426 lead to undefined behaviour. -
427 -
428 This may change in a future version of Qt. -
429 -
430 \section1 Notes for QRegExp users -
431 -
432 The QRegularExpression class introduced in Qt 5 is a big improvement upon -
433 QRegExp, in terms of APIs offered, supported pattern syntax and speed of -
434 execution. The biggest difference is that QRegularExpression simply holds a -
435 regular expression, and it's \e{not} modified when a match is requested. -
436 Instead, a QRegularExpressionMatch object is returned, in order to check -
437 the result of a match and extract the captured substring. The same applies -
438 with global matching and QRegularExpressionMatchIterator. -
439 -
440 Other differences are outlined below. -
441 -
442 \section2 Exact matching -
443 -
444 QRegExp::exactMatch() in Qt 4 served two purposes: it exactly matched -
445 a regular expression against a subject string, and it implemented partial -
446 matching. In fact, if an exact match was not found, one could still find -
447 out how much of the subject string was matched by the regular expression -
448 by calling QRegExp::matchedLength(). If the returned length was equal -
449 to the subject string's length, then one could desume that a partial match -
450 was found. -
451 -
452 QRegularExpression supports partial matching explicitly by means of the -
453 appropriate MatchType. If instead you simply want to be sure that the -
454 subject string matches the regular expression exactly, you can wrap the -
455 pattern between a couple of anchoring expressions. Simply -
456 putting the pattern between the \c{^} and the \c{$} anchors is enough -
457 in most cases: -
458 -
459 \snippet code/src_corelib_tools_qregularexpression.cpp 24 -
460 -
461 However, remember that the \c{$} anchor not only matches at the end of the -
462 string, but also at a newline character right before the end of the string; -
463 that is, the previous pattern matches against the string "this pattern must -
464 match exactly\\n". Also, the behaviour of both the \c{^} and the \c{$} -
465 anchors changes if the MultiLineOption is set either explicitly (as a -
466 pattern option) or implicitly (as a directive inside the pattern string). -
467 -
468 Therefore, in the most general case, you should wrap the pattern between -
469 the \c{\A} and the \c{\z} anchors: -
470 -
471 \snippet code/src_corelib_tools_qregularexpression.cpp 25 -
472 -
473 Note the usage of the non-capturing group in order to preserve the meaning -
474 of the branch operator inside the pattern. -
475 -
476 \section2 Global matching -
477 -
478 Due to limitations of the QRegExp API it was impossible to implement global -
479 matching correctly (that is, like Perl does). In particular, patterns that -
480 can match 0 characters (like \c{"a*"}) are problematic. -
481 -
482 QRegularExpression::globalMatch() implements Perl global match correctly, and -
483 the returned iterator can be used to examine each result. -
484 -
485 \section2 Unicode properties support -
486 -
487 When using QRegExp, character classes such as \c{\w}, \c{\d}, etc. match -
488 characters with the corresponding Unicode property: for instance, \c{\d} -
489 matches any character with the Unicode Nd (decimal digit) property. -
490 -
491 Those character classes only match ASCII characters by default when using -
492 QRegularExpression: for instance, \c{\d} matches exactly a character in the -
493 \c{0-9} ASCII range. It is possible to change this behaviour by using the -
494 UseUnicodePropertiesOption pattern option. -
495 -
496 \section2 Wildcard matching -
497 -
498 There is no equivalent of wildcard matching in QRegularExpression. -
499 Nevertheless, rewriting a regular expression in wildcard syntax to a -
500 Perl-compatible regular expression is a very easy task, given the fact -
501 that wildcard syntax supported by QRegExp is very simple. -
502 -
503 \section2 Other pattern syntaxes -
504 -
505 QRegularExpression supports only Perl-compatible regular expressions. -
506 -
507 \section2 Minimal matching -
508 -
509 QRegExp::setMinimal() implemented minimal matching by simply reversing the -
510 greediness of the quantifiers (QRegExp did not support lazy quantifiers, -
511 like \c{*?}, \c{+?}, etc.). QRegularExpression instead does support greedy, -
512 lazy and possessive quantifiers. The InvertedGreedinessOption -
513 pattern option can be useful to emulate the effects of QRegExp::setMinimal(): -
514 if enabled, it inverts the greediness of quantifiers (greedy ones become -
515 lazy and vice versa). -
516 -
517 \section2 Caret modes -
518 -
519 The AnchoredMatchOption match option can be used to emulate the -
520 QRegExp::CaretAtOffset behaviour. There is no equivalent for the other -
521 QRegExp::CaretMode modes. -
522 -
523 \section1 Debugging code that uses QRegularExpression -
524 -
525 QRegularExpression internally uses a just in time compiler (JIT) to -
526 optimize the execution of the matching algorithm. The JIT makes extensive -
527 usage of self-modifying code, which can lead debugging tools such as -
528 Valgrind to crash. You must enable all checks for self-modifying code if -
529 you want to debug programs using QRegularExpression (f.i., see Valgrind's -
530 \c{--smc-check} command line option). The downside of enabling such checks -
531 is that your program will run considerably slower. -
532 -
533 To avoid that, the JIT is disabled by default if you compile Qt in debug -
534 mode. It is possible to override the default and enable or disable the JIT -
535 usage (both in debug or release mode) by setting the -
536 \c{QT_ENABLE_REGEXP_JIT} environment variable to a non-zero or zero value -
537 respectively. -
538 -
539 \sa QRegularExpressionMatch, QRegularExpressionMatchIterator -
540*/ -
541 -
542/*! -
543 \class QRegularExpressionMatch -
544 \inmodule QtCore -
545 \reentrant -
546 -
547 \brief The QRegularExpressionMatch class provides the results of a matching -
548 a QRegularExpression against a string. -
549 -
550 \since 5.0 -
551 -
552 \ingroup tools -
553 \ingroup shared -
554 -
555 \keyword regular expression match -
556 -
557 A QRegularExpressionMatch object can be obtained by calling the -
558 QRegularExpression::match() function, or as a single result of a global -
559 match from a QRegularExpressionMatchIterator. -
560 -
561 The success or the failure of a match attempt can be inspected by calling -
562 the hasMatch() function. QRegularExpressionMatch also reports a successful -
563 partial match through the hasPartialMatch() function. -
564 -
565 In addition, QRegularExpressionMatch returns the substrings captured by the -
566 capturing groups in the pattern string. The implicit capturing group with -
567 index 0 captures the result of the whole match. The captured() function -
568 returns each substring captured, either by the capturing group's index or -
569 by its name: -
570 -
571 \snippet code/src_corelib_tools_qregularexpression.cpp 29 -
572 -
573 For each captured substring it is possible to query its starting and ending -
574 offsets in the subject string by calling the capturedStart() and the -
575 capturedEnd() function, respectively. The length of each captured -
576 substring is available using the capturedLength() function. -
577 -
578 The convenience function capturedTexts() will return \e{all} the captured -
579 substrings at once (including the substring matched by the entire pattern) -
580 in the order they have been captured by captring groups; that is, -
581 \c{captured(i) == capturedTexts().at(i)}. -
582 -
583 You can retrieve the QRegularExpression object the subject string was -
584 matched against by calling the regularExpression() function; the -
585 match type and the match options are available as well by calling -
586 the matchType() and the matchOptions() respectively. -
587 -
588 Please refer to the QRegularExpression documentation for more information -
589 about the Qt regular expression classes. -
590 -
591 \sa QRegularExpression -
592*/ -
593 -
594/*! -
595 \class QRegularExpressionMatchIterator -
596 \inmodule QtCore -
597 \reentrant -
598 -
599 \brief The QRegularExpressionMatchIterator class provides an iterator on -
600 the results of a global match of a QRegularExpression object against a string. -
601 -
602 \since 5.0 -
603 -
604 \ingroup tools -
605 \ingroup shared -
606 -
607 \keyword regular expression iterator -
608 -
609 A QRegularExpressionMatchIterator object is a forward only Java-like -
610 iterator; it can be obtained by calling the -
611 QRegularExpression::globalMatch() function. A new -
612 QRegularExpressionMatchIterator will be positioned before the first result. -
613 You can then call the hasNext() function to check if there are more -
614 results available; if so, the next() function will return the next -
615 result and advance the iterator. -
616 -
617 Each result is a QRegularExpressionMatch object holding all the information -
618 for that result (including captured substrings). -
619 -
620 For instance: -
621 -
622 \snippet code/src_corelib_tools_qregularexpression.cpp 30 -
623 -
624 Moreover, QRegularExpressionMatchIterator offers a peekNext() function -
625 to get the next result \e{without} advancing the iterator. -
626 -
627 You can retrieve the QRegularExpression object the subject string was -
628 matched against by calling the regularExpression() function; the -
629 match type and the match options are available as well by calling -
630 the matchType() and the matchOptions() respectively. -
631 -
632 Please refer to the QRegularExpression documentation for more information -
633 about the Qt regular expression classes. -
634 -
635 \sa QRegularExpression, QRegularExpressionMatch -
636*/ -
637 -
638 -
639/*! -
640 \enum QRegularExpression::PatternOption -
641 -
642 The PatternOption enum defines modifiers to the way the pattern string -
643 should be interpreted, and therefore the way the pattern matches against a -
644 subject string. -
645 -
646 \value NoPatternOption -
647 No pattern options are set. -
648 -
649 \value CaseInsensitiveOption -
650 The pattern should match against the subject string in a case -
651 insensitive way. This option corresponds to the /i modifier in Perl -
652 regular expressions. -
653 -
654 \value DotMatchesEverythingOption -
655 The dot metacharacter (\c{.}) in the pattern string is allowed to match -
656 any character in the subject string, including newlines (normally, the -
657 dot does not match newlines). This option corresponds to the \c{/s} -
658 modifier in Perl regular expressions. -
659 -
660 \value MultilineOption -
661 The caret (\c{^}) and the dollar (\c{$}) metacharacters in the pattern -
662 string are allowed to match, respectively, immediately after and -
663 immediately before any newline in the subject string, as well as at the -
664 very beginning and at the very end of the subject string. This option -
665 corresponds to the \c{/m} modifier in Perl regular expressions. -
666 -
667 \value ExtendedPatternSyntaxOption -
668 Any whitespace in the pattern string which is not escaped and outside a -
669 character class is ignored. Moreover, an unescaped sharp (\b{#}) -
670 outside a character class causes all the following characters, until -
671 the first newline (included), to be ignored. This can be used to -
672 increase the readability of a pattern string as well as put comments -
673 inside regular expressions; this is particulary useful if the pattern -
674 string is loaded from a file or written by the user, because in C++ -
675 code it is always possible to use the rules for string literals to put -
676 comments outside the pattern string. This option corresponds to the \c{/x} -
677 modifier in Perl regular expressions. -
678 -
679 \value InvertedGreedinessOption -
680 The greediness of the quantifiers is inverted: \c{*}, \c{+}, \c{?}, -
681 \c{{m,n}}, etc. become lazy, while their lazy versions (\c{*?}, -
682 \c{+?}, \c{??}, \c{{m,n}?}, etc.) become greedy. There is no equivalent -
683 for this option in Perl regular expressions. -
684 -
685 \value DontCaptureOption -
686 The non-named capturing groups do not capture substrings; named -
687 capturing groups still work as intended, as well as the implicit -
688 capturing group number 0 corresponding to the entire match. There is no -
689 equivalent for this option in Perl regular expressions. -
690 -
691 \value UseUnicodePropertiesOption -
692 The meaning of the \c{\w}, \c{\d}, etc., character classes, as well as -
693 the meaning of their counterparts (\c{\W}, \c{\D}, etc.), is changed -
694 from matching ASCII characters only to matching any character with the -
695 corresponding Unicode property. For instance, \c{\d} is changed to -
696 match any character with the Unicode Nd (decimal digit) property; -
697 \c{\w} to match any character with either the Unicode L (letter) or N -
698 (digit) property, plus underscore, and so on. This option corresponds -
699 to the \c{/u} modifier in Perl regular expressions. -
700*/ -
701 -
702/*! -
703 \enum QRegularExpression::MatchType -
704 -
705 The MatchType enum defines the type of the match that should be attempted -
706 against the subject string. -
707 -
708 \value NormalMatch -
709 A normal match is done. -
710 -
711 \value PartialPreferCompleteMatch -
712 The pattern string is matched partially against the subject string. If -
713 a partial match is found, then it is recorded, and other matching -
714 alternatives are tried as usual. If a complete match is then found, -
715 then it's preferred to the partial match; in this case only the -
716 complete match is reported. If instead no complete match is found (but -
717 only the partial one), then the partial one is reported. -
718 -
719 \value PartialPreferFirstMatch -
720 The pattern string is matched partially against the subject string. If -
721 a partial match is found, then matching stops and the partial match is -
722 reported. In this case, other matching alternatives (potentially -
723 leading to a complete match) are not tried. Moreover, this match type -
724 assumes that the subject string only a substring of a larger text, and -
725 that (in this text) there are other characters beyond the end of the -
726 subject string. This can lead to surprising results; see the discussion -
727 in the \l{partial matching} section for more details. -
728*/ -
729 -
730/*! -
731 \enum QRegularExpression::MatchOption -
732 -
733 \value NoMatchOption -
734 No match options are set. -
735 -
736 \value AnchoredMatchOption -
737 The match is constrained to start exactly at the offset passed to -
738 match() in order to be successful, even if the pattern string does not -
739 contain any metacharacter that anchors the match at that point. -
740*/ -
741 -
742// after how many usages we optimize the regexp -
743#ifdef QT_BUILD_INTERNAL -
744Q_AUTOTEST_EXPORT unsigned int qt_qregularexpression_optimize_after_use_count = 10; -
745#else -
746static const unsigned int qt_qregularexpression_optimize_after_use_count = 10; -
747#endif // QT_BUILD_INTERNAL -
748 -
749/*! -
750 \internal -
751*/ -
752static int convertToPcreOptions(QRegularExpression::PatternOptions patternOptions) -
753{ -
754 int options = 0;
executed (the execution status of this line is deduced): int options = 0;
-
755 -
756 if (patternOptions & QRegularExpression::CaseInsensitiveOption)
evaluated: patternOptions & QRegularExpression::CaseInsensitiveOption
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:329
40-329
757 options |= PCRE_CASELESS;
executed: options |= 0x00000001;
Execution Count:40
40
758 if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
evaluated: patternOptions & QRegularExpression::DotMatchesEverythingOption
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:314
55-314
759 options |= PCRE_DOTALL;
executed: options |= 0x00000004;
Execution Count:55
55
760 if (patternOptions & QRegularExpression::MultilineOption)
evaluated: patternOptions & QRegularExpression::MultilineOption
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:367
2-367
761 options |= PCRE_MULTILINE;
executed: options |= 0x00000002;
Execution Count:2
2
762 if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
evaluated: patternOptions & QRegularExpression::ExtendedPatternSyntaxOption
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:368
1-368
763 options |= PCRE_EXTENDED;
executed: options |= 0x00000008;
Execution Count:1
1
764 if (patternOptions & QRegularExpression::InvertedGreedinessOption)
evaluated: patternOptions & QRegularExpression::InvertedGreedinessOption
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:368
1-368
765 options |= PCRE_UNGREEDY;
executed: options |= 0x00000200;
Execution Count:1
1
766 if (patternOptions & QRegularExpression::DontCaptureOption)
evaluated: patternOptions & QRegularExpression::DontCaptureOption
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:368
1-368
767 options |= PCRE_NO_AUTO_CAPTURE;
executed: options |= 0x00001000;
Execution Count:1
1
768 if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
evaluated: patternOptions & QRegularExpression::UseUnicodePropertiesOption
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:368
1-368
769 options |= PCRE_UCP;
executed: options |= 0x20000000;
Execution Count:1
1
770 -
771 return options;
executed: return options;
Execution Count:369
369
772} -
773 -
774/*! -
775 \internal -
776*/ -
777static int convertToPcreOptions(QRegularExpression::MatchOptions matchOptions) -
778{ -
779 int options = 0;
executed (the execution status of this line is deduced): int options = 0;
-
780 -
781 if (matchOptions & QRegularExpression::AnchoredMatchOption)
evaluated: matchOptions & QRegularExpression::AnchoredMatchOption
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:884
10-884
782 options |= PCRE_ANCHORED;
executed: options |= 0x00000010;
Execution Count:10
10
783 -
784 return options;
executed: return options;
Execution Count:894
894
785} -
786 -
787struct QRegularExpressionPrivate : QSharedData -
788{ -
789 QRegularExpressionPrivate(); -
790 ~QRegularExpressionPrivate(); -
791 QRegularExpressionPrivate(const QRegularExpressionPrivate &other); -
792 -
793 void cleanCompiledPattern(); -
794 void compilePattern(); -
795 void getPatternInfo(); -
796 pcre16_extra *optimizePattern(); -
797 -
798 QRegularExpressionMatchPrivate *doMatch(const QString &subject, -
799 int offset, -
800 QRegularExpression::MatchType matchType, -
801 QRegularExpression::MatchOptions matchOptions, -
802 bool checkSubjectString = true, -
803 const QRegularExpressionMatchPrivate *previous = 0) const; -
804 -
805 int captureIndexForName(const QString &name) const; -
806 -
807 QString pattern; -
808 QRegularExpression::PatternOptions patternOptions; -
809 -
810 // *All* of the following members are set managed while holding this mutex, -
811 // except for isDirty which is set to true by QRegularExpression setters -
812 // (right after a detach happened). -
813 // On the other hand, after the compilation and studying, -
814 // it's safe to *use* (i.e. read) them from multiple threads at the same time. -
815 // Therefore, doMatch doesn't need to lock this mutex. -
816 QMutex mutex; -
817 -
818 // The PCRE pointers are reference-counted by the QRegularExpressionPrivate -
819 // objects themselves; when the private is copied (i.e. a detach happened) -
820 // they are set to 0 -
821 pcre16 *compiledPattern; -
822 pcre16_extra *studyData; -
823 const char *errorString; -
824 int errorOffset; -
825 int capturingCount; -
826 unsigned int usedCount; -
827 bool usingCrLfNewlines; -
828 bool isDirty; -
829}; -
830 -
831struct QRegularExpressionMatchPrivate : QSharedData -
832{ -
833 QRegularExpressionMatchPrivate(const QRegularExpression &re, -
834 const QString &subject, -
835 QRegularExpression::MatchType matchType, -
836 QRegularExpression::MatchOptions matchOptions, -
837 int capturingCount); -
838 -
839 QRegularExpressionMatch nextMatch() const; -
840 -
841 const QRegularExpression regularExpression; -
842 const QString subject; -
843 // the capturedOffsets vector contains pairs of (start, end) positions -
844 // for each captured substring -
845 QVector<int> capturedOffsets; -
846 -
847 const QRegularExpression::MatchType matchType; -
848 const QRegularExpression::MatchOptions matchOptions; -
849 -
850 int capturedCount; -
851 -
852 bool hasMatch; -
853 bool hasPartialMatch; -
854 bool isValid; -
855}; -
856 -
857struct QRegularExpressionMatchIteratorPrivate : QSharedData -
858{ -
859 QRegularExpressionMatchIteratorPrivate(const QRegularExpression &re, -
860 QRegularExpression::MatchType matchType, -
861 QRegularExpression::MatchOptions matchOptions, -
862 const QRegularExpressionMatch &next); -
863 -
864 bool hasNext() const; -
865 QRegularExpressionMatch next; -
866 const QRegularExpression regularExpression; -
867 const QRegularExpression::MatchType matchType; -
868 const QRegularExpression::MatchOptions matchOptions; -
869}; -
870 -
871/*! -
872 \internal -
873*/ -
874QRegularExpression::QRegularExpression(QRegularExpressionPrivate &dd) -
875 : d(&dd) -
876{ -
877}
executed: }
Execution Count:902
902
878 -
879/*! -
880 \internal -
881*/ -
882QRegularExpressionPrivate::QRegularExpressionPrivate() -
883 : pattern(), patternOptions(0), -
884 mutex(), -
885 compiledPattern(0), studyData(0), -
886 errorString(0), errorOffset(-1), -
887 capturingCount(0), -
888 usedCount(0), -
889 usingCrLfNewlines(false), -
890 isDirty(true) -
891{ -
892}
executed: }
Execution Count:582
582
893 -
894/*! -
895 \internal -
896*/ -
897QRegularExpressionPrivate::~QRegularExpressionPrivate() -
898{ -
899 cleanCompiledPattern();
executed (the execution status of this line is deduced): cleanCompiledPattern();
-
900}
executed: }
Execution Count:583
583
901 -
902/*! -
903 \internal -
904 -
905 Copies the private, which means copying only the pattern and the pattern -
906 options. The compiledPattern and the studyData pointers are NOT copied (we -
907 do not own them any more), and in general all the members set when -
908 compiling a pattern are set to default values. isDirty is set back to true -
909 so that the pattern has to be recompiled again. -
910*/ -
911QRegularExpressionPrivate::QRegularExpressionPrivate(const QRegularExpressionPrivate &other) -
912 : QSharedData(other), -
913 pattern(other.pattern), patternOptions(other.patternOptions), -
914 mutex(), -
915 compiledPattern(0), studyData(0), -
916 errorString(0), -
917 errorOffset(-1), capturingCount(0), -
918 usedCount(0), -
919 usingCrLfNewlines(false), isDirty(true) -
920{ -
921}
executed: }
Execution Count:1
1
922 -
923/*! -
924 \internal -
925*/ -
926void QRegularExpressionPrivate::cleanCompiledPattern() -
927{ -
928 pcre16_free(compiledPattern);
executed (the execution status of this line is deduced): pcre16_free(compiledPattern);
-
929 pcre16_free_study(studyData);
executed (the execution status of this line is deduced): pcre16_free_study(studyData);
-
930 usedCount = 0;
executed (the execution status of this line is deduced): usedCount = 0;
-
931 compiledPattern = 0;
executed (the execution status of this line is deduced): compiledPattern = 0;
-
932 studyData = 0;
executed (the execution status of this line is deduced): studyData = 0;
-
933 usingCrLfNewlines = false;
executed (the execution status of this line is deduced): usingCrLfNewlines = false;
-
934 errorOffset = -1;
executed (the execution status of this line is deduced): errorOffset = -1;
-
935 capturingCount = 0;
executed (the execution status of this line is deduced): capturingCount = 0;
-
936}
executed: }
Execution Count:952
952
937 -
938/*! -
939 \internal -
940*/ -
941void QRegularExpressionPrivate::compilePattern() -
942{ -
943 QMutexLocker lock(&mutex);
executed (the execution status of this line is deduced): QMutexLocker lock(&mutex);
-
944 -
945 if (!isDirty)
evaluated: !isDirty
TRUEFALSE
yes
Evaluation Count:892
yes
Evaluation Count:369
369-892
946 return;
executed: return;
Execution Count:892
892
947 -
948 isDirty = false;
executed (the execution status of this line is deduced): isDirty = false;
-
949 cleanCompiledPattern();
executed (the execution status of this line is deduced): cleanCompiledPattern();
-
950 -
951 int options = convertToPcreOptions(patternOptions);
executed (the execution status of this line is deduced): int options = convertToPcreOptions(patternOptions);
-
952 options |= PCRE_UTF16;
executed (the execution status of this line is deduced): options |= 0x00000800;
-
953 -
954 int errorCode;
executed (the execution status of this line is deduced): int errorCode;
-
955 compiledPattern = pcre16_compile2(pattern.utf16(), options,
executed (the execution status of this line is deduced): compiledPattern = pcre16_compile2(pattern.utf16(), options,
-
956 &errorCode, &errorString, &errorOffset, 0);
executed (the execution status of this line is deduced): &errorCode, &errorString, &errorOffset, 0);
-
957 -
958 if (!compiledPattern)
evaluated: !compiledPattern
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:357
12-357
959 return;
executed: return;
Execution Count:12
12
960 -
961 Q_ASSERT(errorCode == 0);
executed (the execution status of this line is deduced): qt_noop();
-
962 Q_ASSERT(studyData == 0); // studying (=>optimizing) is always done later
executed (the execution status of this line is deduced): qt_noop();
-
963 errorOffset = -1;
executed (the execution status of this line is deduced): errorOffset = -1;
-
964 -
965 getPatternInfo();
executed (the execution status of this line is deduced): getPatternInfo();
-
966}
executed: }
Execution Count:357
357
967 -
968/*! -
969 \internal -
970*/ -
971void QRegularExpressionPrivate::getPatternInfo() -
972{ -
973 Q_ASSERT(compiledPattern);
executed (the execution status of this line is deduced): qt_noop();
-
974 -
975 pcre16_fullinfo(compiledPattern, 0, PCRE_INFO_CAPTURECOUNT, &capturingCount);
executed (the execution status of this line is deduced): pcre16_fullinfo(compiledPattern, 0, 2, &capturingCount);
-
976 -
977 // detect the settings for the newline -
978 unsigned long int patternNewlineSetting;
executed (the execution status of this line is deduced): unsigned long int patternNewlineSetting;
-
979 pcre16_fullinfo(compiledPattern, studyData, PCRE_INFO_OPTIONS, &patternNewlineSetting);
executed (the execution status of this line is deduced): pcre16_fullinfo(compiledPattern, studyData, 0, &patternNewlineSetting);
-
980 patternNewlineSetting &= PCRE_NEWLINE_CR | PCRE_NEWLINE_LF | PCRE_NEWLINE_CRLF
executed (the execution status of this line is deduced): patternNewlineSetting &= 0x00100000 | 0x00200000 | 0x00300000
-
981 | PCRE_NEWLINE_ANY | PCRE_NEWLINE_ANYCRLF;
executed (the execution status of this line is deduced): | 0x00400000 | 0x00500000;
-
982 if (patternNewlineSetting == 0) {
evaluated: patternNewlineSetting == 0
TRUEFALSE
yes
Evaluation Count:354
yes
Evaluation Count:3
3-354
983 // no option was specified in the regexp, grab PCRE build defaults -
984 int pcreNewlineSetting;
executed (the execution status of this line is deduced): int pcreNewlineSetting;
-
985 pcre16_config(PCRE_CONFIG_NEWLINE, &pcreNewlineSetting);
executed (the execution status of this line is deduced): pcre16_config(1, &pcreNewlineSetting);
-
986 switch (pcreNewlineSetting) { -
987 case 13: -
988 patternNewlineSetting = PCRE_NEWLINE_CR; break;
never executed: break;
0
989 case 10: -
990 patternNewlineSetting = PCRE_NEWLINE_LF; break;
executed: break;
Execution Count:354
354
991 case 3338: // (13<<8 | 10) -
992 patternNewlineSetting = PCRE_NEWLINE_CRLF; break;
never executed: break;
0
993 case -2: -
994 patternNewlineSetting = PCRE_NEWLINE_ANYCRLF; break;
never executed: break;
0
995 case -1: -
996 patternNewlineSetting = PCRE_NEWLINE_ANY; break;
never executed: break;
0
997 default: -
998 qWarning("QRegularExpressionPrivate::compilePattern(): "
never executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 998, __PRETTY_FUNCTION__).warning("QRegularExpressionPrivate::compilePattern(): "
-
999 "PCRE_CONFIG_NEWLINE returned an unknown newline");
never executed (the execution status of this line is deduced): "PCRE_CONFIG_NEWLINE returned an unknown newline");
-
1000 break;
never executed: break;
0
1001 } -
1002 }
executed: }
Execution Count:354
354
1003 -
1004 usingCrLfNewlines = (patternNewlineSetting == PCRE_NEWLINE_CRLF) ||
evaluated: (patternNewlineSetting == 0x00300000)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:355
2-355
1005 (patternNewlineSetting == PCRE_NEWLINE_ANY) ||
partially evaluated: (patternNewlineSetting == 0x00400000)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:355
0-355
1006 (patternNewlineSetting == PCRE_NEWLINE_ANYCRLF);
evaluated: (patternNewlineSetting == 0x00500000)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:354
1-354
1007}
executed: }
Execution Count:357
357
1008 -
1009 -
1010/* -
1011 Simple "smartpointer" wrapper around a pcre_jit_stack, to be used with -
1012 QThreadStorage. -
1013*/ -
1014class QPcreJitStackPointer -
1015{ -
1016 Q_DISABLE_COPY(QPcreJitStackPointer); -
1017 -
1018public: -
1019 /*! -
1020 \internal -
1021 */ -
1022 QPcreJitStackPointer() -
1023 { -
1024 // The default JIT stack size in PCRE is 32K, -
1025 // we allocate from 32K up to 512K. -
1026 stack = pcre16_jit_stack_alloc(32*1024, 512*1024);
never executed (the execution status of this line is deduced): stack = pcre16_jit_stack_alloc(32*1024, 512*1024);
-
1027 }
never executed: }
0
1028 /*! -
1029 \internal -
1030 */ -
1031 ~QPcreJitStackPointer() -
1032 { -
1033 if (stack)
never evaluated: stack
0
1034 pcre16_jit_stack_free(stack);
never executed: pcre16_jit_stack_free(stack);
0
1035 }
never executed: }
0
1036 -
1037 pcre16_jit_stack *stack; -
1038}; -
1039 -
1040Q_GLOBAL_STATIC(QThreadStorage<QPcreJitStackPointer *>, jitStacks)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:172
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:170
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-172
1041 -
1042/*! -
1043 \internal -
1044*/ -
1045static pcre16_jit_stack *qtPcreCallback(void *) -
1046{ -
1047 if (jitStacks()->hasLocalData())
partially evaluated: jitStacks()->hasLocalData()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:172
0-172
1048 return jitStacks()->localData()->stack;
never executed: return jitStacks()->localData()->stack;
0
1049 -
1050 return 0;
executed: return 0;
Execution Count:172
172
1051} -
1052 -
1053/*! -
1054 \internal -
1055*/ -
1056static bool isJitEnabled() -
1057{ -
1058 QByteArray jitEnvironment = qgetenv("QT_ENABLE_REGEXP_JIT");
executed (the execution status of this line is deduced): QByteArray jitEnvironment = qgetenv("QT_ENABLE_REGEXP_JIT");
-
1059 if (!jitEnvironment.isEmpty()) {
partially evaluated: !jitEnvironment.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1060 bool ok;
never executed (the execution status of this line is deduced): bool ok;
-
1061 int enableJit = jitEnvironment.toInt(&ok);
never executed (the execution status of this line is deduced): int enableJit = jitEnvironment.toInt(&ok);
-
1062 return ok ? (enableJit != 0) : true;
never executed: return ok ? (enableJit != 0) : true;
0
1063 } -
1064 -
1065#ifdef QT_DEBUG -
1066 return false; -
1067#else -
1068 return true;
executed: return true;
Execution Count:2
2
1069#endif -
1070} -
1071 -
1072/*! -
1073 \internal -
1074 -
1075 The purpose of the function is to call pcre16_study (which allows some -
1076 optimizations to be performed, including JIT-compiling the pattern), and -
1077 setting the studyData member variable to the result of the study. It gets -
1078 called by doMatch() every time a match is performed. As of now, the -
1079 optimizations on the pattern are performed after a certain number of usages -
1080 (i.e. the qt_qregularexpression_optimize_after_use_count constant). -
1081 -
1082 Notice that although the method is protected by a mutex, one thread may -
1083 invoke this function and return immediately (i.e. not study the pattern, -
1084 leaving studyData to NULL); but before calling pcre16_exec to perform the -
1085 match, another thread performs the studying and sets studyData to something -
1086 else. Although the assignment to studyData is itself atomic, the release of -
1087 the memory pointed by studyData isn't. Therefore, the current studyData -
1088 value is returned and used by doMatch. -
1089*/ -
1090pcre16_extra *QRegularExpressionPrivate::optimizePattern() -
1091{ -
1092 Q_ASSERT(compiledPattern);
executed (the execution status of this line is deduced): qt_noop();
-
1093 -
1094 QMutexLocker lock(&mutex);
executed (the execution status of this line is deduced): QMutexLocker lock(&mutex);
-
1095 -
1096 if (studyData || (++usedCount != qt_qregularexpression_optimize_after_use_count))
evaluated: studyData
TRUEFALSE
yes
Evaluation Count:168
yes
Evaluation Count:726
evaluated: (++usedCount != qt_qregularexpression_optimize_after_use_count)
TRUEFALSE
yes
Evaluation Count:711
yes
Evaluation Count:15
15-726
1097 return studyData;
executed: return studyData;
Execution Count:879
879
1098 -
1099 static const bool enableJit = isJitEnabled(); -
1100 -
1101 int studyOptions = 0;
executed (the execution status of this line is deduced): int studyOptions = 0;
-
1102 if (enableJit)
partially evaluated: enableJit
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
1103 studyOptions |= PCRE_STUDY_JIT_COMPILE;
executed: studyOptions |= 0x0001;
Execution Count:15
15
1104 -
1105 const char *err;
executed (the execution status of this line is deduced): const char *err;
-
1106 studyData = pcre16_study(compiledPattern, studyOptions, &err);
executed (the execution status of this line is deduced): studyData = pcre16_study(compiledPattern, studyOptions, &err);
-
1107 -
1108 if (studyData && studyData->flags & PCRE_EXTRA_EXECUTABLE_JIT)
partially evaluated: studyData
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
partially evaluated: studyData->flags & 0x0040
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
1109 pcre16_assign_jit_stack(studyData, qtPcreCallback, 0);
executed: pcre16_assign_jit_stack(studyData, qtPcreCallback, 0);
Execution Count:15
15
1110 -
1111 if (!studyData && err)
partially evaluated: !studyData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
never evaluated: err
0-15
1112 qWarning("QRegularExpressionPrivate::optimizePattern(): pcre_study failed: %s", err);
never executed: QMessageLogger("tools/qregularexpression.cpp", 1112, __PRETTY_FUNCTION__).warning("QRegularExpressionPrivate::optimizePattern(): pcre_study failed: %s", err);
0
1113 -
1114 return studyData;
executed: return studyData;
Execution Count:15
15
1115} -
1116 -
1117/*! -
1118 \internal -
1119 -
1120 Returns the capturing group number for the given name. Duplicated names for -
1121 capturing groups are not supported. -
1122*/ -
1123int QRegularExpressionPrivate::captureIndexForName(const QString &name) const -
1124{ -
1125 Q_ASSERT(!name.isEmpty());
executed (the execution status of this line is deduced): qt_noop();
-
1126 -
1127 if (!compiledPattern)
partially evaluated: !compiledPattern
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1128 return -1;
never executed: return -1;
0
1129 -
1130 int index = pcre16_get_stringnumber(compiledPattern, name.utf16());
executed (the execution status of this line is deduced): int index = pcre16_get_stringnumber(compiledPattern, name.utf16());
-
1131 if (index >= 0)
evaluated: index >= 0
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
1132 return index;
executed: return index;
Execution Count:6
6
1133 -
1134 return -1;
executed: return -1;
Execution Count:6
6
1135} -
1136 -
1137/*! -
1138 \internal -
1139 -
1140 This is a simple wrapper for pcre16_exec for handling the case in which the -
1141 JIT runs out of memory. In that case, we allocate a thread-local JIT stack -
1142 and re-run pcre16_exec. -
1143*/ -
1144static int pcre16SafeExec(const pcre16 *code, const pcre16_extra *extra, -
1145 const unsigned short *subject, int length, -
1146 int startOffset, int options, -
1147 int *ovector, int ovecsize) -
1148{ -
1149 int result = pcre16_exec(code, extra, subject, length,
executed (the execution status of this line is deduced): int result = pcre16_exec(code, extra, subject, length,
-
1150 startOffset, options, ovector, ovecsize);
executed (the execution status of this line is deduced): startOffset, options, ovector, ovecsize);
-
1151 -
1152 if (result == PCRE_ERROR_JIT_STACKLIMIT && !jitStacks()->hasLocalData()) {
partially evaluated: result == (-27)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:990
never evaluated: !jitStacks()->hasLocalData()
0-990
1153 QPcreJitStackPointer *p = new QPcreJitStackPointer;
never executed (the execution status of this line is deduced): QPcreJitStackPointer *p = new QPcreJitStackPointer;
-
1154 jitStacks()->setLocalData(p);
never executed (the execution status of this line is deduced): jitStacks()->setLocalData(p);
-
1155 -
1156 result = pcre16_exec(code, extra, subject, length,
never executed (the execution status of this line is deduced): result = pcre16_exec(code, extra, subject, length,
-
1157 startOffset, options, ovector, ovecsize);
never executed (the execution status of this line is deduced): startOffset, options, ovector, ovecsize);
-
1158 }
never executed: }
0
1159 -
1160 return result;
executed: return result;
Execution Count:990
990
1161} -
1162 -
1163/*! -
1164 \internal -
1165 -
1166 Performs a match of type \a matchType on the given \a subject string with -
1167 options \a matchOptions and returns the QRegularExpressionMatchPrivate of -
1168 the result. It also advances a match if a previous result is given as \a -
1169 previous. The \a subject string goes a Unicode validity check if -
1170 \a checkSubjectString is true (PCRE doesn't like illegal UTF-16 sequences). -
1171 -
1172 Advancing a match is a tricky algorithm. If the previous match matched a -
1173 non-empty string, we just do an ordinary match at the offset position. -
1174 -
1175 If the previous match matched an empty string, then an anchored, non-empty -
1176 match is attempted at the offset position. If that succeeds, then we got -
1177 the next match and we can return it. Otherwise, we advance by 1 position -
1178 (which can be one or two code units in UTF-16!) and reattempt a "normal" -
1179 match. We also have the problem of detecting the current newline format: if -
1180 the new advanced offset is pointing to the beginning of a CRLF sequence, we -
1181 must advance over it. -
1182*/ -
1183QRegularExpressionMatchPrivate *QRegularExpressionPrivate::doMatch(const QString &subject, -
1184 int offset, -
1185 QRegularExpression::MatchType matchType, -
1186 QRegularExpression::MatchOptions matchOptions, -
1187 bool checkSubjectString, -
1188 const QRegularExpressionMatchPrivate *previous) const -
1189{ -
1190 if (offset < 0)
evaluated: offset < 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:897
5-897
1191 offset += subject.length();
executed: offset += subject.length();
Execution Count:5
5
1192 -
1193 QRegularExpression re(*const_cast<QRegularExpressionPrivate *>(this));
executed (the execution status of this line is deduced): QRegularExpression re(*const_cast<QRegularExpressionPrivate *>(this));
-
1194 -
1195 if (offset < 0 || offset > subject.length())
partially evaluated: offset < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:902
partially evaluated: offset > subject.length()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:902
0-902
1196 return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0);
never executed: return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0);
0
1197 -
1198 if (!compiledPattern) {
evaluated: !compiledPattern
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:894
8-894
1199 qWarning("QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object");
executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 1199, __PRETTY_FUNCTION__).warning("QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object");
-
1200 return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0);
executed: return new QRegularExpressionMatchPrivate(re, subject, matchType, matchOptions, 0);
Execution Count:8
8
1201 } -
1202 -
1203 QRegularExpressionMatchPrivate *priv = new QRegularExpressionMatchPrivate(re, subject,
executed (the execution status of this line is deduced): QRegularExpressionMatchPrivate *priv = new QRegularExpressionMatchPrivate(re, subject,
-
1204 matchType, matchOptions,
executed (the execution status of this line is deduced): matchType, matchOptions,
-
1205 capturingCount);
executed (the execution status of this line is deduced): capturingCount);
-
1206 -
1207 // this is mutex protected -
1208 const pcre16_extra *currentStudyData = const_cast<QRegularExpressionPrivate *>(this)->optimizePattern();
executed (the execution status of this line is deduced): const pcre16_extra *currentStudyData = const_cast<QRegularExpressionPrivate *>(this)->optimizePattern();
-
1209 -
1210 int pcreOptions = convertToPcreOptions(matchOptions);
executed (the execution status of this line is deduced): int pcreOptions = convertToPcreOptions(matchOptions);
-
1211 -
1212 if (matchType == QRegularExpression::PartialPreferCompleteMatch)
evaluated: matchType == QRegularExpression::PartialPreferCompleteMatch
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:884
10-884
1213 pcreOptions |= PCRE_PARTIAL_SOFT;
executed: pcreOptions |= 0x00008000;
Execution Count:10
10
1214 else if (matchType == QRegularExpression::PartialPreferFirstMatch)
evaluated: matchType == QRegularExpression::PartialPreferFirstMatch
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:871
13-871
1215 pcreOptions |= PCRE_PARTIAL_HARD;
executed: pcreOptions |= 0x08000000;
Execution Count:13
13
1216 -
1217 if (!checkSubjectString)
evaluated: !checkSubjectString
TRUEFALSE
yes
Evaluation Count:561
yes
Evaluation Count:333
333-561
1218 pcreOptions |= PCRE_NO_UTF16_CHECK;
executed: pcreOptions |= 0x00002000;
Execution Count:561
561
1219 -
1220 bool previousMatchWasEmpty = false;
executed (the execution status of this line is deduced): bool previousMatchWasEmpty = false;
-
1221 if (previous && previous->hasMatch &&
evaluated: previous
TRUEFALSE
yes
Evaluation Count:561
yes
Evaluation Count:333
partially evaluated: previous->hasMatch
TRUEFALSE
yes
Evaluation Count:561
no
Evaluation Count:0
0-561
1222 (previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))) {
evaluated: (previous->capturedOffsets.at(0) == previous->capturedOffsets.at(1))
TRUEFALSE
yes
Evaluation Count:100
yes
Evaluation Count:461
100-461
1223 previousMatchWasEmpty = true;
executed (the execution status of this line is deduced): previousMatchWasEmpty = true;
-
1224 }
executed: }
Execution Count:100
100
1225 -
1226 int * const captureOffsets = priv->capturedOffsets.data();
executed (the execution status of this line is deduced): int * const captureOffsets = priv->capturedOffsets.data();
-
1227 const int captureOffsetsCount = priv->capturedOffsets.size();
executed (the execution status of this line is deduced): const int captureOffsetsCount = priv->capturedOffsets.size();
-
1228 -
1229 const unsigned short * const subjectUtf16 = subject.utf16();
executed (the execution status of this line is deduced): const unsigned short * const subjectUtf16 = subject.utf16();
-
1230 const int subjectLength = subject.length();
executed (the execution status of this line is deduced): const int subjectLength = subject.length();
-
1231 -
1232 int result;
executed (the execution status of this line is deduced): int result;
-
1233 -
1234 if (!previousMatchWasEmpty) {
evaluated: !previousMatchWasEmpty
TRUEFALSE
yes
Evaluation Count:794
yes
Evaluation Count:100
100-794
1235 result = pcre16SafeExec(compiledPattern, currentStudyData,
executed (the execution status of this line is deduced): result = pcre16SafeExec(compiledPattern, currentStudyData,
-
1236 subjectUtf16, subjectLength,
executed (the execution status of this line is deduced): subjectUtf16, subjectLength,
-
1237 offset, pcreOptions,
executed (the execution status of this line is deduced): offset, pcreOptions,
-
1238 captureOffsets, captureOffsetsCount);
executed (the execution status of this line is deduced): captureOffsets, captureOffsetsCount);
-
1239 } else {
executed: }
Execution Count:794
794
1240 result = pcre16SafeExec(compiledPattern, currentStudyData,
executed (the execution status of this line is deduced): result = pcre16SafeExec(compiledPattern, currentStudyData,
-
1241 subjectUtf16, subjectLength,
executed (the execution status of this line is deduced): subjectUtf16, subjectLength,
-
1242 offset, pcreOptions | PCRE_NOTEMPTY_ATSTART | PCRE_ANCHORED,
executed (the execution status of this line is deduced): offset, pcreOptions | 0x10000000 | 0x00000010,
-
1243 captureOffsets, captureOffsetsCount);
executed (the execution status of this line is deduced): captureOffsets, captureOffsetsCount);
-
1244 -
1245 if (result == PCRE_ERROR_NOMATCH) {
evaluated: result == (-1)
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:4
4-96
1246 ++offset;
executed (the execution status of this line is deduced): ++offset;
-
1247 -
1248 if (usingCrLfNewlines
evaluated: usingCrLfNewlines
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:74
22-74
1249 && offset < subjectLength
evaluated: offset < subjectLength
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:6
6-16
1250 && subjectUtf16[offset - 1] == QLatin1Char('\r')
evaluated: subjectUtf16[offset - 1] == QLatin1Char('\r')
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:2
2-14
1251 && subjectUtf16[offset] == QLatin1Char('\n')) {
evaluated: subjectUtf16[offset] == QLatin1Char('\n')
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
2-12
1252 ++offset;
executed (the execution status of this line is deduced): ++offset;
-
1253 } else if (offset < subjectLength
executed: }
Execution Count:12
evaluated: offset < subjectLength
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:33
12-51
1254 && QChar::isLowSurrogate(subjectUtf16[offset])) {
evaluated: QChar::isLowSurrogate(subjectUtf16[offset])
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:45
6-45
1255 ++offset;
executed (the execution status of this line is deduced): ++offset;
-
1256 }
executed: }
Execution Count:6
6
1257 -
1258 result = pcre16SafeExec(compiledPattern, currentStudyData,
executed (the execution status of this line is deduced): result = pcre16SafeExec(compiledPattern, currentStudyData,
-
1259 subjectUtf16, subjectLength,
executed (the execution status of this line is deduced): subjectUtf16, subjectLength,
-
1260 offset, pcreOptions,
executed (the execution status of this line is deduced): offset, pcreOptions,
-
1261 captureOffsets, captureOffsetsCount);
executed (the execution status of this line is deduced): captureOffsets, captureOffsetsCount);
-
1262 }
executed: }
Execution Count:96
96
1263 }
executed: }
Execution Count:100
100
1264 -
1265#ifdef QREGULAREXPRESSION_DEBUG -
1266 qDebug() << "Matching" << pattern << "against" << subject -
1267 << offset << matchType << matchOptions << previousMatchWasEmpty -
1268 << "result" << result; -
1269#endif -
1270 -
1271 // result == 0 means not enough space in captureOffsets; should never happen -
1272 Q_ASSERT(result != 0);
executed (the execution status of this line is deduced): qt_noop();
-
1273 -
1274 if (result > 0) {
evaluated: result > 0
TRUEFALSE
yes
Evaluation Count:644
yes
Evaluation Count:250
250-644
1275 // full match -
1276 priv->isValid = true;
executed (the execution status of this line is deduced): priv->isValid = true;
-
1277 priv->hasMatch = true;
executed (the execution status of this line is deduced): priv->hasMatch = true;
-
1278 priv->capturedCount = result;
executed (the execution status of this line is deduced): priv->capturedCount = result;
-
1279 priv->capturedOffsets.resize(result * 2);
executed (the execution status of this line is deduced): priv->capturedOffsets.resize(result * 2);
-
1280 } else {
executed: }
Execution Count:644
644
1281 // no match, partial match or error -
1282 priv->hasPartialMatch = (result == PCRE_ERROR_PARTIAL);
executed (the execution status of this line is deduced): priv->hasPartialMatch = (result == (-12));
-
1283 priv->isValid = (result == PCRE_ERROR_NOMATCH || result == PCRE_ERROR_PARTIAL);
evaluated: result == (-1)
TRUEFALSE
yes
Evaluation Count:205
yes
Evaluation Count:45
evaluated: result == (-12)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:28
17-205
1284 -
1285 if (result == PCRE_ERROR_PARTIAL) {
evaluated: result == (-12)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:233
17-233
1286 // partial match: -
1287 // leave the start and end capture offsets (i.e. cap(0)) -
1288 priv->capturedCount = 1;
executed (the execution status of this line is deduced): priv->capturedCount = 1;
-
1289 priv->capturedOffsets.resize(2);
executed (the execution status of this line is deduced): priv->capturedOffsets.resize(2);
-
1290 } else {
executed: }
Execution Count:17
17
1291 // no match or error -
1292 priv->capturedCount = 0;
executed (the execution status of this line is deduced): priv->capturedCount = 0;
-
1293 priv->capturedOffsets.clear();
executed (the execution status of this line is deduced): priv->capturedOffsets.clear();
-
1294 }
executed: }
Execution Count:233
233
1295 } -
1296 -
1297 return priv;
executed: return priv;
Execution Count:894
894
1298} -
1299 -
1300/*! -
1301 \internal -
1302*/ -
1303QRegularExpressionMatchPrivate::QRegularExpressionMatchPrivate(const QRegularExpression &re, -
1304 const QString &subject, -
1305 QRegularExpression::MatchType matchType, -
1306 QRegularExpression::MatchOptions matchOptions, -
1307 int capturingCount) -
1308 : regularExpression(re), subject(subject), -
1309 matchType(matchType), matchOptions(matchOptions), -
1310 capturedCount(0), -
1311 hasMatch(false), hasPartialMatch(false), isValid(false) -
1312{ -
1313 Q_ASSERT(capturingCount >= 0);
executed (the execution status of this line is deduced): qt_noop();
-
1314 const int captureOffsetsCount = (capturingCount + 1) * 3;
executed (the execution status of this line is deduced): const int captureOffsetsCount = (capturingCount + 1) * 3;
-
1315 capturedOffsets.resize(captureOffsetsCount);
executed (the execution status of this line is deduced): capturedOffsets.resize(captureOffsetsCount);
-
1316}
executed: }
Execution Count:902
902
1317 -
1318 -
1319/*! -
1320 \internal -
1321*/ -
1322QRegularExpressionMatch QRegularExpressionMatchPrivate::nextMatch() const -
1323{ -
1324 Q_ASSERT(isValid);
executed (the execution status of this line is deduced): qt_noop();
-
1325 Q_ASSERT(hasMatch || hasPartialMatch);
executed (the execution status of this line is deduced): qt_noop();
-
1326 -
1327 // Note the "false" passed for the check of the subject string: -
1328 // if we're advancing a match on the same subject, -
1329 // then that subject was already checked at least once (when this object -
1330 // was created, or when the object that created this one was created, etc.) -
1331 QRegularExpressionMatchPrivate *nextPrivate = regularExpression.d->doMatch(subject,
executed (the execution status of this line is deduced): QRegularExpressionMatchPrivate *nextPrivate = regularExpression.d->doMatch(subject,
-
1332 capturedOffsets.at(1),
executed (the execution status of this line is deduced): capturedOffsets.at(1),
-
1333 matchType,
executed (the execution status of this line is deduced): matchType,
-
1334 matchOptions,
executed (the execution status of this line is deduced): matchOptions,
-
1335 false,
executed (the execution status of this line is deduced): false,
-
1336 this);
executed (the execution status of this line is deduced): this);
-
1337 return QRegularExpressionMatch(*nextPrivate);
executed: return QRegularExpressionMatch(*nextPrivate);
Execution Count:561
561
1338} -
1339 -
1340/*! -
1341 \internal -
1342*/ -
1343QRegularExpressionMatchIteratorPrivate::QRegularExpressionMatchIteratorPrivate(const QRegularExpression &re, -
1344 QRegularExpression::MatchType matchType, -
1345 QRegularExpression::MatchOptions matchOptions, -
1346 const QRegularExpressionMatch &next) -
1347 : next(next), -
1348 regularExpression(re), -
1349 matchType(matchType), matchOptions(matchOptions) -
1350{ -
1351}
executed: }
Execution Count:138
138
1352 -
1353/*! -
1354 \internal -
1355*/ -
1356bool QRegularExpressionMatchIteratorPrivate::hasNext() const -
1357{ -
1358 return next.isValid() && (next.hasMatch() || next.hasPartialMatch());
executed: return next.isValid() && (next.hasMatch() || next.hasPartialMatch());
Execution Count:1350
1350
1359} -
1360 -
1361// PUBLIC API -
1362 -
1363/*! -
1364 Constructs a QRegularExpression object with an empty pattern and no pattern -
1365 options. -
1366 -
1367 \sa setPattern(), setPatternOptions() -
1368*/ -
1369QRegularExpression::QRegularExpression() -
1370 : d(new QRegularExpressionPrivate) -
1371{ -
1372}
executed: }
Execution Count:64
64
1373 -
1374/*! -
1375 Constructs a QRegularExpression object using the given \a pattern as -
1376 pattern and the \a options as the pattern options. -
1377 -
1378 \sa setPattern(), setPatternOptions() -
1379*/ -
1380QRegularExpression::QRegularExpression(const QString &pattern, PatternOptions options) -
1381 : d(new QRegularExpressionPrivate) -
1382{ -
1383 d->pattern = pattern;
executed (the execution status of this line is deduced): d->pattern = pattern;
-
1384 d->patternOptions = options;
executed (the execution status of this line is deduced): d->patternOptions = options;
-
1385}
executed: }
Execution Count:518
518
1386 -
1387/*! -
1388 Constructs a QRegularExpression object as a copy of \a re. -
1389 -
1390 \sa operator=() -
1391*/ -
1392QRegularExpression::QRegularExpression(const QRegularExpression &re) -
1393 : d(re.d) -
1394{ -
1395}
executed: }
Execution Count:1951
1951
1396 -
1397/*! -
1398 Destroys the QRegularExpression object. -
1399*/ -
1400QRegularExpression::~QRegularExpression() -
1401{ -
1402} -
1403 -
1404/*! -
1405 Assigns the regular expression \a re to this object, and returns a reference -
1406 to the copy. Both the pattern and the pattern options are copied. -
1407*/ -
1408QRegularExpression &QRegularExpression::operator=(const QRegularExpression &re) -
1409{ -
1410 d = re.d;
executed (the execution status of this line is deduced): d = re.d;
-
1411 return *this;
executed: return *this;
Execution Count:48
48
1412} -
1413 -
1414/*! -
1415 \fn void QRegularExpression::swap(QRegularExpression &other) -
1416 -
1417 Swaps the regular expression \a other with this regular expression. This -
1418 operation is very fast and never fails. -
1419*/ -
1420 -
1421/*! -
1422 Returns the pattern string of the regular expression. -
1423 -
1424 \sa setPattern(), patternOptions() -
1425*/ -
1426QString QRegularExpression::pattern() const -
1427{ -
1428 return d->pattern;
executed: return d->pattern;
Execution Count:98
98
1429} -
1430 -
1431/*! -
1432 Sets the pattern string of the regular expression to \a pattern. The -
1433 pattern options are left unchanged. -
1434 -
1435 \sa pattern(), setPatternOptions() -
1436*/ -
1437void QRegularExpression::setPattern(const QString &pattern) -
1438{ -
1439 d.detach();
executed (the execution status of this line is deduced): d.detach();
-
1440 d->isDirty = true;
executed (the execution status of this line is deduced): d->isDirty = true;
-
1441 d->pattern = pattern;
executed (the execution status of this line is deduced): d->pattern = pattern;
-
1442}
executed: }
Execution Count:37
37
1443 -
1444/*! -
1445 Returns the pattern options for the regular expression. -
1446 -
1447 \sa setPatternOptions(), pattern() -
1448*/ -
1449QRegularExpression::PatternOptions QRegularExpression::patternOptions() const -
1450{ -
1451 return d->patternOptions;
executed: return d->patternOptions;
Execution Count:99
99
1452} -
1453 -
1454/*! -
1455 Sets the given \a options as the pattern options of the regular expression. -
1456 The pattern string is left unchanged. -
1457 -
1458 \sa patternOptions(), setPattern() -
1459*/ -
1460void QRegularExpression::setPatternOptions(PatternOptions options) -
1461{ -
1462 d.detach();
executed (the execution status of this line is deduced): d.detach();
-
1463 d->isDirty = true;
executed (the execution status of this line is deduced): d->isDirty = true;
-
1464 d->patternOptions = options;
executed (the execution status of this line is deduced): d->patternOptions = options;
-
1465}
executed: }
Execution Count:38
38
1466 -
1467/*! -
1468 Returns the number of capturing groups inside the pattern string, -
1469 or -1 if the regular expression is not valid. -
1470 -
1471 \sa isValid() -
1472*/ -
1473int QRegularExpression::captureCount() const -
1474{ -
1475 if (!isValid()) // will compile the pattern
evaluated: !isValid()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:32
6-32
1476 return -1;
executed: return -1;
Execution Count:6
6
1477 return d->capturingCount;
executed: return d->capturingCount;
Execution Count:32
32
1478} -
1479 -
1480/*! -
1481 Returns true if the regular expression is a valid regular expression (that -
1482 is, it contains no syntax errors, etc.), or false otherwise. Use -
1483 errorString() to obtain a textual description of the error. -
1484 -
1485 \sa errorString(), patternErrorOffset() -
1486*/ -
1487bool QRegularExpression::isValid() const -
1488{ -
1489 d.data()->compilePattern();
executed (the execution status of this line is deduced): d.data()->compilePattern();
-
1490 return d->compiledPattern;
executed: return d->compiledPattern;
Execution Count:696
696
1491} -
1492 -
1493/*! -
1494 Returns a textual description of the error found when checking the validity -
1495 of the regular expression, or "no error" if no error was found. -
1496 -
1497 \sa isValid(), patternErrorOffset() -
1498*/ -
1499QString QRegularExpression::errorString() const -
1500{ -
1501 d.data()->compilePattern();
executed (the execution status of this line is deduced): d.data()->compilePattern();
-
1502 if (d->errorString)
partially evaluated: d->errorString
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:224
0-224
1503 return QCoreApplication::translate("QRegularExpression", d->errorString);
never executed: return QCoreApplication::translate("QRegularExpression", d->errorString);
0
1504 return QCoreApplication::translate("QRegularExpression", "no error");
executed: return QCoreApplication::translate("QRegularExpression", "no error");
Execution Count:224
224
1505} -
1506 -
1507/*! -
1508 Returns the offset, inside the pattern string, at which an error was found -
1509 when checking the validity of the regular expression. If no error was -
1510 found, then -1 is returned. -
1511 -
1512 \sa pattern(), isValid(), errorString() -
1513*/ -
1514int QRegularExpression::patternErrorOffset() const -
1515{ -
1516 d.data()->compilePattern();
never executed (the execution status of this line is deduced): d.data()->compilePattern();
-
1517 return d->errorOffset;
never executed: return d->errorOffset;
0
1518} -
1519 -
1520/*! -
1521 Attempts to match the regular expression against the given \a subject -
1522 string, starting at the position \a offset inside the subject, using a -
1523 match of type \a matchType and honoring the given \a matchOptions. -
1524 -
1525 The returned QRegularExpressionMatch object contains the results of the -
1526 match. -
1527 -
1528 \sa QRegularExpressionMatch, {normal matching} -
1529*/ -
1530QRegularExpressionMatch QRegularExpression::match(const QString &subject, -
1531 int offset, -
1532 MatchType matchType, -
1533 MatchOptions matchOptions) const -
1534{ -
1535 d.data()->compilePattern();
executed (the execution status of this line is deduced): d.data()->compilePattern();
-
1536 -
1537 QRegularExpressionMatchPrivate *priv = d->doMatch(subject, offset, matchType, matchOptions);
executed (the execution status of this line is deduced): QRegularExpressionMatchPrivate *priv = d->doMatch(subject, offset, matchType, matchOptions);
-
1538 return QRegularExpressionMatch(*priv);
executed: return QRegularExpressionMatch(*priv);
Execution Count:341
341
1539} -
1540 -
1541/*! -
1542 Attempts to perform a global match of the regular expression against the -
1543 given \a subject string, starting at the position \a offset inside the -
1544 subject, using a match of type \a matchType and honoring the given \a -
1545 matchOptions. -
1546 -
1547 The returned QRegularExpressionMatchIterator is positioned before the -
1548 first match result (if any). -
1549 -
1550 \sa QRegularExpressionMatchIterator, {global matching} -
1551*/ -
1552QRegularExpressionMatchIterator QRegularExpression::globalMatch(const QString &subject, -
1553 int offset, -
1554 MatchType matchType, -
1555 MatchOptions matchOptions) const -
1556{ -
1557 QRegularExpressionMatchIteratorPrivate *priv =
executed (the execution status of this line is deduced): QRegularExpressionMatchIteratorPrivate *priv =
-
1558 new QRegularExpressionMatchIteratorPrivate(*this,
executed (the execution status of this line is deduced): new QRegularExpressionMatchIteratorPrivate(*this,
-
1559 matchType,
executed (the execution status of this line is deduced): matchType,
-
1560 matchOptions,
executed (the execution status of this line is deduced): matchOptions,
-
1561 match(subject, offset, matchType, matchOptions));
executed (the execution status of this line is deduced): match(subject, offset, matchType, matchOptions));
-
1562 -
1563 return QRegularExpressionMatchIterator(*priv);
executed: return QRegularExpressionMatchIterator(*priv);
Execution Count:138
138
1564} -
1565 -
1566/*! -
1567 Returns true if the regular expression is equal to \a re, or false -
1568 otherwise. Two QRegularExpression objects are equal if they have -
1569 the same pattern string and the same pattern options. -
1570 -
1571 \sa operator!=() -
1572*/ -
1573bool QRegularExpression::operator==(const QRegularExpression &re) const -
1574{ -
1575 return (d == re.d) ||
executed: return (d == re.d) || (d->pattern == re.d->pattern && d->patternOptions == re.d->patternOptions);
Execution Count:993
993
1576 (d->pattern == re.d->pattern && d->patternOptions == re.d->patternOptions);
executed: return (d == re.d) || (d->pattern == re.d->pattern && d->patternOptions == re.d->patternOptions);
Execution Count:993
993
1577} -
1578 -
1579/*! -
1580 \fn bool QRegularExpression::operator!=(const QRegularExpression &re) const -
1581 -
1582 Returns true if the regular expression is different from \a re, or -
1583 false otherwise. -
1584 -
1585 \sa operator==() -
1586*/ -
1587 -
1588/*! -
1589 Escapes all characters of \a str so that they no longer have any special -
1590 meaning when used as a regular expression pattern string, and returns -
1591 the escaped string. For instance: -
1592 -
1593 \snippet code/src_corelib_tools_qregularexpression.cpp 26 -
1594 -
1595 This is very convenient in order to build patterns from arbitrary strings: -
1596 -
1597 \snippet code/src_corelib_tools_qregularexpression.cpp 27 -
1598 -
1599 \note This function implements Perl's quotemeta algorithm and escapes with -
1600 a backslash all characters in \a str, except for the characters in the -
1601 \c{[A-Z]}, \c{[a-z]} and \c{[0-9]} ranges, as well as the underscore -
1602 (\c{_}) character. The only difference with Perl is that a literal NUL -
1603 inside \a str is escaped with the sequence \c{"\\0"} (backslash + -
1604 \c{'0'}), instead of \c{"\\\0"} (backslash + \c{NUL}). -
1605*/ -
1606QString QRegularExpression::escape(const QString &str) -
1607{ -
1608 QString result;
executed (the execution status of this line is deduced): QString result;
-
1609 const int count = str.size();
executed (the execution status of this line is deduced): const int count = str.size();
-
1610 result.reserve(count * 2);
executed (the execution status of this line is deduced): result.reserve(count * 2);
-
1611 -
1612 // everything but [a-zA-Z0-9_] gets escaped, -
1613 // cf. perldoc -f quotemeta -
1614 for (int i = 0; i < count; ++i) {
evaluated: i < count
TRUEFALSE
yes
Evaluation Count:4317
yes
Evaluation Count:120
120-4317
1615 const QChar current = str.at(i);
executed (the execution status of this line is deduced): const QChar current = str.at(i);
-
1616 -
1617 if (current == QChar::Null) {
evaluated: current == QChar::Null
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:4311
6-4311
1618 // unlike Perl, a literal NUL must be escaped with -
1619 // "\\0" (backslash + 0) and not "\\\0" (backslash + NUL), -
1620 // because pcre16_compile uses a NUL-terminated string -
1621 result.append(QLatin1Char('\\'));
executed (the execution status of this line is deduced): result.append(QLatin1Char('\\'));
-
1622 result.append(QLatin1Char('0'));
executed (the execution status of this line is deduced): result.append(QLatin1Char('0'));
-
1623 } else if ( (current < QLatin1Char('a') || current > QLatin1Char('z')) &&
executed: }
Execution Count:6
evaluated: current < QLatin1Char('a')
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:4164
evaluated: current > QLatin1Char('z')
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:4146
6-4164
1624 (current < QLatin1Char('A') || current > QLatin1Char('Z')) &&
evaluated: current < QLatin1Char('A')
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:113
evaluated: current > QLatin1Char('Z')
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:87
26-113
1625 (current < QLatin1Char('0') || current > QLatin1Char('9')) &&
evaluated: current < QLatin1Char('0')
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:43
evaluated: current > QLatin1Char('9')
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:11
11-43
1626 current != QLatin1Char('_') )
evaluated: current != QLatin1Char('_')
TRUEFALSE
yes
Evaluation Count:66
yes
Evaluation Count:1
1-66
1627 { -
1628 result.append(QLatin1Char('\\'));
executed (the execution status of this line is deduced): result.append(QLatin1Char('\\'));
-
1629 result.append(current);
executed (the execution status of this line is deduced): result.append(current);
-
1630 if (current.isHighSurrogate() && i < (count - 1))
evaluated: current.isHighSurrogate()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:63
partially evaluated: i < (count - 1)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-63
1631 result.append(str.at(++i));
executed: result.append(str.at(++i));
Execution Count:3
3
1632 } else {
executed: }
Execution Count:66
66
1633 result.append(current);
executed (the execution status of this line is deduced): result.append(current);
-
1634 }
executed: }
Execution Count:4245
4245
1635 } -
1636 -
1637 result.squeeze();
executed (the execution status of this line is deduced): result.squeeze();
-
1638 return result;
executed: return result;
Execution Count:120
120
1639} -
1640 -
1641/*! -
1642 Destroys the match result. -
1643*/ -
1644QRegularExpressionMatch::~QRegularExpressionMatch() -
1645{ -
1646} -
1647 -
1648/*! -
1649 Constructs a match result by copying the result of the given \a match. -
1650 -
1651 \sa operator=() -
1652*/ -
1653QRegularExpressionMatch::QRegularExpressionMatch(const QRegularExpressionMatch &match) -
1654 : d(match.d) -
1655{ -
1656}
executed: }
Execution Count:1355
1355
1657 -
1658/*! -
1659 Assigns the match result \a match to this object, and returns a reference -
1660 to the copy. -
1661*/ -
1662QRegularExpressionMatch &QRegularExpressionMatch::operator=(const QRegularExpressionMatch &match) -
1663{ -
1664 d = match.d;
never executed (the execution status of this line is deduced): d = match.d;
-
1665 return *this;
never executed: return *this;
0
1666} -
1667 -
1668/*! -
1669 \fn void QRegularExpressionMatch::swap(QRegularExpressionMatch &other) -
1670 -
1671 Swaps the match result \a other with this match result. This -
1672 operation is very fast and never fails. -
1673*/ -
1674 -
1675/*! -
1676 \internal -
1677*/ -
1678QRegularExpressionMatch::QRegularExpressionMatch(QRegularExpressionMatchPrivate &dd) -
1679 : d(&dd) -
1680{ -
1681}
executed: }
Execution Count:902
902
1682 -
1683/*! -
1684 Returns the QRegularExpression object whose match() function returned this -
1685 object. -
1686 -
1687 \sa QRegularExpression::match(), matchType(), matchOptions() -
1688*/ -
1689QRegularExpression QRegularExpressionMatch::regularExpression() const -
1690{ -
1691 return d->regularExpression;
executed: return d->regularExpression;
Execution Count:252
252
1692} -
1693 -
1694 -
1695/*! -
1696 Returns the match type that was used to get this QRegularExpressionMatch -
1697 object, that is, the match type that was passed to -
1698 QRegularExpression::match() or QRegularExpression::globalMatch(). -
1699 -
1700 \sa QRegularExpression::match(), regularExpression(), matchOptions() -
1701*/ -
1702QRegularExpression::MatchType QRegularExpressionMatch::matchType() const -
1703{ -
1704 return d->matchType;
executed: return d->matchType;
Execution Count:65
65
1705} -
1706 -
1707/*! -
1708 Returns the match options that were used to get this -
1709 QRegularExpressionMatch object, that is, the match options that were passed -
1710 to QRegularExpression::match() or QRegularExpression::globalMatch(). -
1711 -
1712 \sa QRegularExpression::match(), regularExpression(), matchType() -
1713*/ -
1714QRegularExpression::MatchOptions QRegularExpressionMatch::matchOptions() const -
1715{ -
1716 return d->matchOptions;
executed: return d->matchOptions;
Execution Count:65
65
1717} -
1718 -
1719/*! -
1720 Returns the index of the last capturing group that captured something, -
1721 including the implicit capturing group 0. This can be used to extract all -
1722 the substrings that were captured: -
1723 -
1724 \snippet code/src_corelib_tools_qregularexpression.cpp 28 -
1725 -
1726 Note that some of the capturing groups with an index less than -
1727 lastCapturedIndex() could have not matched, and therefore captured nothing. -
1728 -
1729 If the regular expression did not match, this function returns -1. -
1730 -
1731 \sa captured(), capturedStart(), capturedEnd(), capturedLength() -
1732*/ -
1733int QRegularExpressionMatch::lastCapturedIndex() const -
1734{ -
1735 return d->capturedCount - 1;
executed: return d->capturedCount - 1;
Execution Count:6677
6677
1736} -
1737 -
1738/*! -
1739 Returns the substring captured by the \a nth capturing group. If the \a nth -
1740 capturing group did not capture a string or doesn't exist, returns a null -
1741 QString. -
1742 -
1743 \sa capturedRef(), lastCapturedIndex(), capturedStart(), capturedEnd(), -
1744 capturedLength(), QString::isNull() -
1745*/ -
1746QString QRegularExpressionMatch::captured(int nth) const -
1747{ -
1748 if (nth < 0 || nth > lastCapturedIndex())
partially evaluated: nth < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:523
evaluated: nth > lastCapturedIndex()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:513
0-523
1749 return QString();
executed: return QString();
Execution Count:10
10
1750 -
1751 int start = capturedStart(nth);
executed (the execution status of this line is deduced): int start = capturedStart(nth);
-
1752 -
1753 if (start == -1) // didn't capture
evaluated: start == -1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:511
2-511
1754 return QString();
executed: return QString();
Execution Count:2
2
1755 -
1756 return d->subject.mid(start, capturedLength(nth));
executed: return d->subject.mid(start, capturedLength(nth));
Execution Count:511
511
1757} -
1758 -
1759/*! -
1760 Returns a reference to the substring captured by the \a nth capturing group. -
1761 If the \a nth capturing group did not capture a string or doesn't exist, -
1762 returns a null QStringRef. -
1763 -
1764 \sa captured(), lastCapturedIndex(), capturedStart(), capturedEnd(), -
1765 capturedLength(), QStringRef::isNull() -
1766*/ -
1767QStringRef QRegularExpressionMatch::capturedRef(int nth) const -
1768{ -
1769 if (nth < 0 || nth > lastCapturedIndex())
partially evaluated: nth < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:224
partially evaluated: nth > lastCapturedIndex()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:224
0-224
1770 return QStringRef();
never executed: return QStringRef();
0
1771 -
1772 int start = capturedStart(nth);
executed (the execution status of this line is deduced): int start = capturedStart(nth);
-
1773 -
1774 if (start == -1) // didn't capture
evaluated: start == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:223
1-223
1775 return QStringRef();
executed: return QStringRef();
Execution Count:1
1
1776 -
1777 return d->subject.midRef(start, capturedLength(nth));
executed: return d->subject.midRef(start, capturedLength(nth));
Execution Count:223
223
1778} -
1779 -
1780/*! -
1781 Returns the substring captured by the capturing group named \a name. If the -
1782 capturing group named \a name did not capture a string or doesn't exist, -
1783 returns a null QString. -
1784 -
1785 \sa capturedRef(), capturedStart(), capturedEnd(), capturedLength(), -
1786 QString::isNull() -
1787*/ -
1788QString QRegularExpressionMatch::captured(const QString &name) const -
1789{ -
1790 if (name.isEmpty()) {
evaluated: name.isEmpty()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:12
4-12
1791 qWarning("QRegularExpressionMatch::captured: empty capturing group name passed");
executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 1791, __PRETTY_FUNCTION__).warning("QRegularExpressionMatch::captured: empty capturing group name passed");
-
1792 return QString();
executed: return QString();
Execution Count:4
4
1793 } -
1794 int nth = d->regularExpression.d->captureIndexForName(name);
executed (the execution status of this line is deduced): int nth = d->regularExpression.d->captureIndexForName(name);
-
1795 if (nth == -1)
evaluated: nth == -1
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
1796 return QString();
executed: return QString();
Execution Count:6
6
1797 return captured(nth);
executed: return captured(nth);
Execution Count:6
6
1798} -
1799 -
1800/*! -
1801 Returns a reference to the string captured by the capturing group named \a -
1802 name. If the capturing group named \a name did not capture a string or -
1803 doesn't exist, returns a null QStringRef. -
1804 -
1805 \sa captured(), capturedStart(), capturedEnd(), capturedLength(), -
1806 QStringRef::isNull() -
1807*/ -
1808QStringRef QRegularExpressionMatch::capturedRef(const QString &name) const -
1809{ -
1810 if (name.isEmpty()) {
never evaluated: name.isEmpty()
0
1811 qWarning("QRegularExpressionMatch::capturedRef: empty capturing group name passed");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 1811, __PRETTY_FUNCTION__).warning("QRegularExpressionMatch::capturedRef: empty capturing group name passed");
-
1812 return QStringRef();
never executed: return QStringRef();
0
1813 } -
1814 int nth = d->regularExpression.d->captureIndexForName(name);
never executed (the execution status of this line is deduced): int nth = d->regularExpression.d->captureIndexForName(name);
-
1815 if (nth == -1)
never evaluated: nth == -1
0
1816 return QStringRef();
never executed: return QStringRef();
0
1817 return capturedRef(nth);
never executed: return capturedRef(nth);
0
1818} -
1819 -
1820/*! -
1821 Returns a list of all strings captured by capturing groups, in the order -
1822 the groups themselves appear in the pattern string. -
1823*/ -
1824QStringList QRegularExpressionMatch::capturedTexts() const -
1825{ -
1826 QStringList texts;
never executed (the execution status of this line is deduced): QStringList texts;
-
1827 for (int i = 0; i <= lastCapturedIndex(); ++i)
never evaluated: i <= lastCapturedIndex()
0
1828 texts << captured(i);
never executed: texts << captured(i);
0
1829 return texts;
never executed: return texts;
0
1830} -
1831 -
1832/*! -
1833 Returns the offset inside the subject string corresponding to the -
1834 starting position of the substring captured by the \a nth capturing group. -
1835 If the \a nth capturing group did not capture a string or doesn't exist, -
1836 returns -1. -
1837 -
1838 \sa capturedEnd(), capturedLength(), captured() -
1839*/ -
1840int QRegularExpressionMatch::capturedStart(int nth) const -
1841{ -
1842 if (nth < 0 || nth > lastCapturedIndex())
partially evaluated: nth < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2917
evaluated: nth > lastCapturedIndex()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:2897
0-2917
1843 return -1;
executed: return -1;
Execution Count:20
20
1844 -
1845 return d->capturedOffsets.at(nth * 2);
executed: return d->capturedOffsets.at(nth * 2);
Execution Count:2897
2897
1846} -
1847 -
1848/*! -
1849 Returns the length of the substring captured by the \a nth capturing group. -
1850 -
1851 \note This function returns 0 if the \a nth capturing group did not capture -
1852 a string or doesn't exist. -
1853 -
1854 \sa capturedStart(), capturedEnd(), captured() -
1855*/ -
1856int QRegularExpressionMatch::capturedLength(int nth) const -
1857{ -
1858 // bound checking performed by these two functions -
1859 return capturedEnd(nth) - capturedStart(nth);
executed: return capturedEnd(nth) - capturedStart(nth);
Execution Count:1280
1280
1860} -
1861 -
1862/*! -
1863 Returns the offset inside the subject string immediately after the ending -
1864 position of the substring captured by the \a nth capturing group. If the \a -
1865 nth capturing group did not capture a string or doesn't exist, returns -1. -
1866 -
1867 \sa capturedStart(), capturedLength(), captured() -
1868*/ -
1869int QRegularExpressionMatch::capturedEnd(int nth) const -
1870{ -
1871 if (nth < 0 || nth > lastCapturedIndex())
partially evaluated: nth < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1799
evaluated: nth > lastCapturedIndex()
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:1779
0-1799
1872 return -1;
executed: return -1;
Execution Count:20
20
1873 -
1874 return d->capturedOffsets.at(nth * 2 + 1);
executed: return d->capturedOffsets.at(nth * 2 + 1);
Execution Count:1779
1779
1875} -
1876 -
1877/*! -
1878 Returns the offset inside the subject string corresponding to the starting -
1879 position of the substring captured by the capturing group named \a name. -
1880 If the capturing group named \a name did not capture a string or doesn't -
1881 exist, returns -1. -
1882 -
1883 \sa capturedEnd(), capturedLength(), captured() -
1884*/ -
1885int QRegularExpressionMatch::capturedStart(const QString &name) const -
1886{ -
1887 if (name.isEmpty()) {
never evaluated: name.isEmpty()
0
1888 qWarning("QRegularExpressionMatch::capturedStart: empty capturing group name passed");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 1888, __PRETTY_FUNCTION__).warning("QRegularExpressionMatch::capturedStart: empty capturing group name passed");
-
1889 return -1;
never executed: return -1;
0
1890 } -
1891 int nth = d->regularExpression.d->captureIndexForName(name);
never executed (the execution status of this line is deduced): int nth = d->regularExpression.d->captureIndexForName(name);
-
1892 if (nth == -1)
never evaluated: nth == -1
0
1893 return -1;
never executed: return -1;
0
1894 return capturedStart(nth);
never executed: return capturedStart(nth);
0
1895} -
1896 -
1897/*! -
1898 Returns the offset inside the subject string corresponding to the starting -
1899 position of the substring captured by the capturing group named \a name. -
1900 -
1901 \note This function returns 0 if the capturing group named \a name did not -
1902 capture a string or doesn't exist. -
1903 -
1904 \sa capturedStart(), capturedEnd(), captured() -
1905*/ -
1906int QRegularExpressionMatch::capturedLength(const QString &name) const -
1907{ -
1908 if (name.isEmpty()) {
never evaluated: name.isEmpty()
0
1909 qWarning("QRegularExpressionMatch::capturedLength: empty capturing group name passed");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 1909, __PRETTY_FUNCTION__).warning("QRegularExpressionMatch::capturedLength: empty capturing group name passed");
-
1910 return 0;
never executed: return 0;
0
1911 } -
1912 int nth = d->regularExpression.d->captureIndexForName(name);
never executed (the execution status of this line is deduced): int nth = d->regularExpression.d->captureIndexForName(name);
-
1913 if (nth == -1)
never evaluated: nth == -1
0
1914 return 0;
never executed: return 0;
0
1915 return capturedLength(nth);
never executed: return capturedLength(nth);
0
1916} -
1917 -
1918/*! -
1919 Returns the offset inside the subject string immediately after the ending -
1920 position of the substring captured by the capturing group named \a name. If -
1921 the capturing group named \a name did not capture a string or doesn't -
1922 exist, returns -1. -
1923 -
1924 \sa capturedStart(), capturedLength(), captured() -
1925*/ -
1926int QRegularExpressionMatch::capturedEnd(const QString &name) const -
1927{ -
1928 if (name.isEmpty()) {
never evaluated: name.isEmpty()
0
1929 qWarning("QRegularExpressionMatch::capturedEnd: empty capturing group name passed");
never executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 1929, __PRETTY_FUNCTION__).warning("QRegularExpressionMatch::capturedEnd: empty capturing group name passed");
-
1930 return -1;
never executed: return -1;
0
1931 } -
1932 int nth = d->regularExpression.d->captureIndexForName(name);
never executed (the execution status of this line is deduced): int nth = d->regularExpression.d->captureIndexForName(name);
-
1933 if (nth == -1)
never evaluated: nth == -1
0
1934 return -1;
never executed: return -1;
0
1935 return capturedEnd(nth);
never executed: return capturedEnd(nth);
0
1936} -
1937 -
1938/*! -
1939 Returns true if the regular expression matched against the subject string, -
1940 or false otherwise. -
1941 -
1942 \sa QRegularExpression::match(), hasPartialMatch() -
1943*/ -
1944bool QRegularExpressionMatch::hasMatch() const -
1945{ -
1946 return d->hasMatch;
executed: return d->hasMatch;
Execution Count:2268
2268
1947} -
1948 -
1949/*! -
1950 Returns true if the regular expression partially matched against the -
1951 subject string, or false otherwise. -
1952 -
1953 \note Only a match that explicitly used the one of the partial match types -
1954 can yield a partial match. Still, if such a match succeeds totally, this -
1955 function will return false, while hasMatch() will return true. -
1956 -
1957 \sa QRegularExpression::match(), QRegularExpression::MatchType, hasMatch() -
1958*/ -
1959bool QRegularExpressionMatch::hasPartialMatch() const -
1960{ -
1961 return d->hasPartialMatch;
executed: return d->hasPartialMatch;
Execution Count:756
756
1962} -
1963 -
1964/*! -
1965 Returns true if the match object was obtained as a result from the -
1966 QRegularExpression::match() function invoked on a valid QRegularExpression -
1967 object; returns false if the QRegularExpression was invalid. -
1968 -
1969 \sa QRegularExpression::match(), QRegularExpression::isValid() -
1970*/ -
1971bool QRegularExpressionMatch::isValid() const -
1972{ -
1973 return d->isValid;
executed: return d->isValid;
Execution Count:2020
2020
1974} -
1975 -
1976/*! -
1977 \internal -
1978*/ -
1979QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(QRegularExpressionMatchIteratorPrivate &dd) -
1980 : d(&dd) -
1981{ -
1982}
executed: }
Execution Count:138
138
1983 -
1984/*! -
1985 Destroys the QRegularExpressionMatchIterator object. -
1986*/ -
1987QRegularExpressionMatchIterator::~QRegularExpressionMatchIterator() -
1988{ -
1989} -
1990 -
1991/*! -
1992 Constructs a QRegularExpressionMatchIterator object as a copy of \a -
1993 iterator. -
1994 -
1995 \sa operator=() -
1996*/ -
1997QRegularExpressionMatchIterator::QRegularExpressionMatchIterator(const QRegularExpressionMatchIterator &iterator) -
1998 : d(iterator.d) -
1999{ -
2000}
executed: }
Execution Count:26
26
2001 -
2002/*! -
2003 Assigns the iterator \a iterator to this object, and returns a reference to -
2004 the copy. -
2005*/ -
2006QRegularExpressionMatchIterator &QRegularExpressionMatchIterator::operator=(const QRegularExpressionMatchIterator &iterator) -
2007{ -
2008 d = iterator.d;
never executed (the execution status of this line is deduced): d = iterator.d;
-
2009 return *this;
never executed: return *this;
0
2010} -
2011 -
2012/*! -
2013 \fn void QRegularExpressionMatchIterator::swap(QRegularExpressionMatchIterator &other) -
2014 -
2015 Swaps the iterator \a other with this iterator object. This operation is -
2016 very fast and never fails. -
2017*/ -
2018 -
2019/*! -
2020 Returns true if the iterator object was obtained as a result from the -
2021 QRegularExpression::globalMatch() function invoked on a valid -
2022 QRegularExpression object; returns false if the QRegularExpression was -
2023 invalid. -
2024 -
2025 \sa QRegularExpression::globalMatch(), QRegularExpression::isValid() -
2026*/ -
2027bool QRegularExpressionMatchIterator::isValid() const -
2028{ -
2029 return d->next.isValid();
executed: return d->next.isValid();
Execution Count:35
35
2030} -
2031 -
2032/*! -
2033 Returns true if there is at least one match result ahead of the iterator; -
2034 otherwise it returns false. -
2035 -
2036 \sa next() -
2037*/ -
2038bool QRegularExpressionMatchIterator::hasNext() const -
2039{ -
2040 return d->hasNext();
executed: return d->hasNext();
Execution Count:1350
1350
2041} -
2042 -
2043/*! -
2044 Returns the next match result without moving the iterator. -
2045 -
2046 \note Calling this function when the iterator is at the end of the result -
2047 set leads to undefined results. -
2048*/ -
2049QRegularExpressionMatch QRegularExpressionMatchIterator::peekNext() const -
2050{ -
2051 if (!hasNext())
evaluated: !hasNext()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:65
2-65
2052 qWarning("QRegularExpressionMatchIterator::peekNext() called on an iterator already at end");
executed: QMessageLogger("tools/qregularexpression.cpp", 2052, __PRETTY_FUNCTION__).warning("QRegularExpressionMatchIterator::peekNext() called on an iterator already at end");
Execution Count:2
2
2053 -
2054 return d->next;
executed: return d->next;
Execution Count:67
67
2055} -
2056 -
2057/*! -
2058 Returns the next match result and advances the iterator by one position. -
2059 -
2060 \note Calling this function when the iterator is at the end of the result -
2061 set leads to undefined results. -
2062*/ -
2063QRegularExpressionMatch QRegularExpressionMatchIterator::next() -
2064{ -
2065 if (!hasNext()) {
evaluated: !hasNext()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:561
2-561
2066 qWarning("QRegularExpressionMatchIterator::next() called on an iterator already at end");
executed (the execution status of this line is deduced): QMessageLogger("tools/qregularexpression.cpp", 2066, __PRETTY_FUNCTION__).warning("QRegularExpressionMatchIterator::next() called on an iterator already at end");
-
2067 return d->next;
executed: return d->next;
Execution Count:2
2
2068 } -
2069 -
2070 QRegularExpressionMatch current = d->next;
executed (the execution status of this line is deduced): QRegularExpressionMatch current = d->next;
-
2071 d->next = d->next.d.constData()->nextMatch();
executed (the execution status of this line is deduced): d->next = d->next.d.constData()->nextMatch();
-
2072 return current;
executed: return current;
Execution Count:561
561
2073} -
2074 -
2075/*! -
2076 Returns the QRegularExpression object whose globalMatch() function returned -
2077 this object. -
2078 -
2079 \sa QRegularExpression::globalMatch(), matchType(), matchOptions() -
2080*/ -
2081QRegularExpression QRegularExpressionMatchIterator::regularExpression() const -
2082{ -
2083 return d->regularExpression;
executed: return d->regularExpression;
Execution Count:65
65
2084} -
2085 -
2086/*! -
2087 Returns the match type that was used to get this -
2088 QRegularExpressionMatchIterator object, that is, the match type that was -
2089 passed to QRegularExpression::globalMatch(). -
2090 -
2091 \sa QRegularExpression::globalMatch(), regularExpression(), matchOptions() -
2092*/ -
2093QRegularExpression::MatchType QRegularExpressionMatchIterator::matchType() const -
2094{ -
2095 return d->matchType;
executed: return d->matchType;
Execution Count:65
65
2096} -
2097 -
2098/*! -
2099 Returns the match options that were used to get this -
2100 QRegularExpressionMatchIterator object, that is, the match options that -
2101 were passed to QRegularExpression::globalMatch(). -
2102 -
2103 \sa QRegularExpression::globalMatch(), regularExpression(), matchType() -
2104*/ -
2105QRegularExpression::MatchOptions QRegularExpressionMatchIterator::matchOptions() const -
2106{ -
2107 return d->matchOptions;
executed: return d->matchOptions;
Execution Count:65
65
2108} -
2109 -
2110#ifndef QT_NO_DATASTREAM -
2111/*! -
2112 \relates QRegularExpression -
2113 -
2114 Writes the regular expression \a re to stream \a out. -
2115 -
2116 \sa {Serializing Qt Data Types} -
2117*/ -
2118QDataStream &operator<<(QDataStream &out, const QRegularExpression &re) -
2119{ -
2120 out << re.pattern() << quint32(re.patternOptions());
executed (the execution status of this line is deduced): out << re.pattern() << quint32(re.patternOptions());
-
2121 return out;
executed: return out;
Execution Count:19
19
2122} -
2123 -
2124/*! -
2125 \relates QRegularExpression -
2126 -
2127 Reads a regular expression from stream \a in into \a re. -
2128 -
2129 \sa {Serializing Qt Data Types} -
2130*/ -
2131QDataStream &operator>>(QDataStream &in, QRegularExpression &re) -
2132{ -
2133 QString pattern;
executed (the execution status of this line is deduced): QString pattern;
-
2134 quint32 patternOptions;
executed (the execution status of this line is deduced): quint32 patternOptions;
-
2135 in >> pattern >> patternOptions;
executed (the execution status of this line is deduced): in >> pattern >> patternOptions;
-
2136 re.setPattern(pattern);
executed (the execution status of this line is deduced): re.setPattern(pattern);
-
2137 re.setPatternOptions(QRegularExpression::PatternOptions(patternOptions));
executed (the execution status of this line is deduced): re.setPatternOptions(QRegularExpression::PatternOptions(patternOptions));
-
2138 return in;
executed: return in;
Execution Count:22
22
2139} -
2140#endif -
2141 -
2142#ifndef QT_NO_DEBUG_STREAM -
2143/*! -
2144 \relates QRegularExpression -
2145 -
2146 Writes the regular expression \a re into the debug object \a debug for -
2147 debugging purposes. -
2148 -
2149 \sa {Debugging Techniques} -
2150*/ -
2151QDebug operator<<(QDebug debug, const QRegularExpression &re) -
2152{ -
2153 debug.nospace() << "QRegularExpression(" << re.pattern() << ", " << re.patternOptions() << ")";
executed (the execution status of this line is deduced): debug.nospace() << "QRegularExpression(" << re.pattern() << ", " << re.patternOptions() << ")";
-
2154 return debug.space();
executed: return debug.space();
Execution Count:1
1
2155} -
2156 -
2157/*! -
2158 \relates QRegularExpression -
2159 -
2160 Writes the pattern options \a patternOptions into the debug object \a debug -
2161 for debugging purposes. -
2162 -
2163 \sa {Debugging Techniques} -
2164*/ -
2165QDebug operator<<(QDebug debug, QRegularExpression::PatternOptions patternOptions) -
2166{ -
2167 QByteArray flags;
executed (the execution status of this line is deduced): QByteArray flags;
-
2168 -
2169 if (patternOptions == QRegularExpression::NoPatternOption) {
partially evaluated: patternOptions == QRegularExpression::NoPatternOption
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2170 flags = "NoPatternOption";
executed (the execution status of this line is deduced): flags = "NoPatternOption";
-
2171 } else {
executed: }
Execution Count:1
1
2172 flags.reserve(200); // worst case...
never executed (the execution status of this line is deduced): flags.reserve(200);
-
2173 if (patternOptions & QRegularExpression::CaseInsensitiveOption)
never evaluated: patternOptions & QRegularExpression::CaseInsensitiveOption
0
2174 flags.append("CaseInsensitiveOption|");
never executed: flags.append("CaseInsensitiveOption|");
0
2175 if (patternOptions & QRegularExpression::DotMatchesEverythingOption)
never evaluated: patternOptions & QRegularExpression::DotMatchesEverythingOption
0
2176 flags.append("DotMatchesEverythingOption|");
never executed: flags.append("DotMatchesEverythingOption|");
0
2177 if (patternOptions & QRegularExpression::MultilineOption)
never evaluated: patternOptions & QRegularExpression::MultilineOption
0
2178 flags.append("MultilineOption|");
never executed: flags.append("MultilineOption|");
0
2179 if (patternOptions & QRegularExpression::ExtendedPatternSyntaxOption)
never evaluated: patternOptions & QRegularExpression::ExtendedPatternSyntaxOption
0
2180 flags.append("ExtendedPatternSyntaxOption|");
never executed: flags.append("ExtendedPatternSyntaxOption|");
0
2181 if (patternOptions & QRegularExpression::InvertedGreedinessOption)
never evaluated: patternOptions & QRegularExpression::InvertedGreedinessOption
0
2182 flags.append("InvertedGreedinessOption|");
never executed: flags.append("InvertedGreedinessOption|");
0
2183 if (patternOptions & QRegularExpression::DontCaptureOption)
never evaluated: patternOptions & QRegularExpression::DontCaptureOption
0
2184 flags.append("DontCaptureOption|");
never executed: flags.append("DontCaptureOption|");
0
2185 if (patternOptions & QRegularExpression::UseUnicodePropertiesOption)
never evaluated: patternOptions & QRegularExpression::UseUnicodePropertiesOption
0
2186 flags.append("UseUnicodePropertiesOption|");
never executed: flags.append("UseUnicodePropertiesOption|");
0
2187 flags.chop(1);
never executed (the execution status of this line is deduced): flags.chop(1);
-
2188 }
never executed: }
0
2189 -
2190 debug.nospace() << "QRegularExpression::PatternOptions(" << flags << ")";
executed (the execution status of this line is deduced): debug.nospace() << "QRegularExpression::PatternOptions(" << flags << ")";
-
2191 -
2192 return debug.space();
executed: return debug.space();
Execution Count:1
1
2193} -
2194/*! -
2195 \relates QRegularExpressionMatch -
2196 -
2197 Writes the match object \a match into the debug object \a debug for -
2198 debugging purposes. -
2199 -
2200 \sa {Debugging Techniques} -
2201*/ -
2202QDebug operator<<(QDebug debug, const QRegularExpressionMatch &match) -
2203{ -
2204 debug.nospace() << "QRegularExpressionMatch(";
never executed (the execution status of this line is deduced): debug.nospace() << "QRegularExpressionMatch(";
-
2205 -
2206 if (!match.isValid()) {
never evaluated: !match.isValid()
0
2207 debug << "Invalid)";
never executed (the execution status of this line is deduced): debug << "Invalid)";
-
2208 return debug.space();
never executed: return debug.space();
0
2209 } -
2210 -
2211 debug << "Valid";
never executed (the execution status of this line is deduced): debug << "Valid";
-
2212 -
2213 if (match.hasMatch()) {
never evaluated: match.hasMatch()
0
2214 debug << ", has match: ";
never executed (the execution status of this line is deduced): debug << ", has match: ";
-
2215 for (int i = 0; i <= match.lastCapturedIndex(); ++i) {
never evaluated: i <= match.lastCapturedIndex()
0
2216 debug << i
never executed (the execution status of this line is deduced): debug << i
-
2217 << ":(" << match.capturedStart(i) << ", " << match.capturedEnd(i)
never executed (the execution status of this line is deduced): << ":(" << match.capturedStart(i) << ", " << match.capturedEnd(i)
-
2218 << ", " << match.captured(i) << ")";
never executed (the execution status of this line is deduced): << ", " << match.captured(i) << ")";
-
2219 if (i < match.lastCapturedIndex())
never evaluated: i < match.lastCapturedIndex()
0
2220 debug << ", ";
never executed: debug << ", ";
0
2221 }
never executed: }
0
2222 } else if (match.hasPartialMatch()) {
never executed: }
never evaluated: match.hasPartialMatch()
0
2223 debug << ", has partial match: ("
never executed (the execution status of this line is deduced): debug << ", has partial match: ("
-
2224 << match.capturedStart(0) << ", "
never executed (the execution status of this line is deduced): << match.capturedStart(0) << ", "
-
2225 << match.capturedEnd(0) << ", "
never executed (the execution status of this line is deduced): << match.capturedEnd(0) << ", "
-
2226 << match.captured(0) << ")";
never executed (the execution status of this line is deduced): << match.captured(0) << ")";
-
2227 } else {
never executed: }
0
2228 debug << ", no match";
never executed (the execution status of this line is deduced): debug << ", no match";
-
2229 }
never executed: }
0
2230 -
2231 debug << ")";
never executed (the execution status of this line is deduced): debug << ")";
-
2232 -
2233 return debug.space();
never executed: return debug.space();
0
2234} -
2235#endif -
2236 -
2237// fool lupdate: make it extract those strings for translation, but don't put them -
2238// inside Qt -- they're already inside libpcre (cf. man 3 pcreapi, pcre_compile.c). -
2239#if 0 -
2240 -
2241/* PCRE is a library of functions to support regular expressions whose syntax -
2242and semantics are as close as possible to those of the Perl 5 language. -
2243 -
2244 Written by Philip Hazel -
2245 Copyright (c) 1997-2012 University of Cambridge -
2246 -
2247----------------------------------------------------------------------------- -
2248Redistribution and use in source and binary forms, with or without -
2249modification, are permitted provided that the following conditions are met: -
2250 -
2251 * Redistributions of source code must retain the above copyright notice, -
2252 this list of conditions and the following disclaimer. -
2253 -
2254 * Redistributions in binary form must reproduce the above copyright -
2255 notice, this list of conditions and the following disclaimer in the -
2256 documentation and/or other materials provided with the distribution. -
2257 -
2258 * Neither the name of the University of Cambridge nor the names of its -
2259 contributors may be used to endorse or promote products derived from -
2260 this software without specific prior written permission. -
2261 -
2262THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -
2263AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -
2264IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -
2265ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -
2266LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -
2267CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -
2268SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -
2269INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -
2270CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -
2271ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -
2272POSSIBILITY OF SUCH DAMAGE. -
2273----------------------------------------------------------------------------- -
2274*/ -
2275 -
2276static const char *pcreCompileErrorCodes[] = -
2277{ -
2278 QT_TRANSLATE_NOOP("QRegularExpression", "no error"), -
2279 QT_TRANSLATE_NOOP("QRegularExpression", "\\ at end of pattern"), -
2280 QT_TRANSLATE_NOOP("QRegularExpression", "\\c at end of pattern"), -
2281 QT_TRANSLATE_NOOP("QRegularExpression", "unrecognized character follows \\"), -
2282 QT_TRANSLATE_NOOP("QRegularExpression", "numbers out of order in {} quantifier"), -
2283 QT_TRANSLATE_NOOP("QRegularExpression", "number too big in {} quantifier"), -
2284 QT_TRANSLATE_NOOP("QRegularExpression", "missing terminating ] for character class"), -
2285 QT_TRANSLATE_NOOP("QRegularExpression", "invalid escape sequence in character class"), -
2286 QT_TRANSLATE_NOOP("QRegularExpression", "range out of order in character class"), -
2287 QT_TRANSLATE_NOOP("QRegularExpression", "nothing to repeat"), -
2288 QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unexpected repeat"), -
2289 QT_TRANSLATE_NOOP("QRegularExpression", "unrecognized character after (? or (?-"), -
2290 QT_TRANSLATE_NOOP("QRegularExpression", "POSIX named classes are supported only within a class"), -
2291 QT_TRANSLATE_NOOP("QRegularExpression", "missing )"), -
2292 QT_TRANSLATE_NOOP("QRegularExpression", "reference to non-existent subpattern"), -
2293 QT_TRANSLATE_NOOP("QRegularExpression", "erroffset passed as NULL"), -
2294 QT_TRANSLATE_NOOP("QRegularExpression", "unknown option bit(s) set"), -
2295 QT_TRANSLATE_NOOP("QRegularExpression", "missing ) after comment"), -
2296 QT_TRANSLATE_NOOP("QRegularExpression", "regular expression is too large"), -
2297 QT_TRANSLATE_NOOP("QRegularExpression", "failed to get memory"), -
2298 QT_TRANSLATE_NOOP("QRegularExpression", "unmatched parentheses"), -
2299 QT_TRANSLATE_NOOP("QRegularExpression", "internal error: code overflow"), -
2300 QT_TRANSLATE_NOOP("QRegularExpression", "unrecognized character after (?<"), -
2301 QT_TRANSLATE_NOOP("QRegularExpression", "lookbehind assertion is not fixed length"), -
2302 QT_TRANSLATE_NOOP("QRegularExpression", "malformed number or name after (?("), -
2303 QT_TRANSLATE_NOOP("QRegularExpression", "conditional group contains more than two branches"), -
2304 QT_TRANSLATE_NOOP("QRegularExpression", "assertion expected after (?("), -
2305 QT_TRANSLATE_NOOP("QRegularExpression", "(?R or (?[+-]digits must be followed by )"), -
2306 QT_TRANSLATE_NOOP("QRegularExpression", "unknown POSIX class name"), -
2307 QT_TRANSLATE_NOOP("QRegularExpression", "POSIX collating elements are not supported"), -
2308 QT_TRANSLATE_NOOP("QRegularExpression", "this version of PCRE is not compiled with PCRE_UTF8 support"), -
2309 QT_TRANSLATE_NOOP("QRegularExpression", "character value in \\x{...} sequence is too large"), -
2310 QT_TRANSLATE_NOOP("QRegularExpression", "invalid condition (?(0)"), -
2311 QT_TRANSLATE_NOOP("QRegularExpression", "\\C not allowed in lookbehind assertion"), -
2312 QT_TRANSLATE_NOOP("QRegularExpression", "PCRE does not support \\L, \\l, \\N{name}, \\U, or \\u"), -
2313 QT_TRANSLATE_NOOP("QRegularExpression", "number after (?C is > 255"), -
2314 QT_TRANSLATE_NOOP("QRegularExpression", "closing ) for (?C expected"), -
2315 QT_TRANSLATE_NOOP("QRegularExpression", "recursive call could loop indefinitely"), -
2316 QT_TRANSLATE_NOOP("QRegularExpression", "unrecognized character after (?P"), -
2317 QT_TRANSLATE_NOOP("QRegularExpression", "syntax error in subpattern name (missing terminator)"), -
2318 QT_TRANSLATE_NOOP("QRegularExpression", "two named subpatterns have the same name"), -
2319 QT_TRANSLATE_NOOP("QRegularExpression", "invalid UTF-8 string"), -
2320 QT_TRANSLATE_NOOP("QRegularExpression", "support for \\P, \\p, and \\X has not been compiled"), -
2321 QT_TRANSLATE_NOOP("QRegularExpression", "malformed \\P or \\p sequence"), -
2322 QT_TRANSLATE_NOOP("QRegularExpression", "unknown property name after \\P or \\p"), -
2323 QT_TRANSLATE_NOOP("QRegularExpression", "subpattern name is too long (maximum 32 characters)"), -
2324 QT_TRANSLATE_NOOP("QRegularExpression", "too many named subpatterns (maximum 10000)"), -
2325 QT_TRANSLATE_NOOP("QRegularExpression", "octal value is greater than \\377 (not in UTF-8 mode)"), -
2326 QT_TRANSLATE_NOOP("QRegularExpression", "internal error: overran compiling workspace"), -
2327 QT_TRANSLATE_NOOP("QRegularExpression", "internal error: previously-checked referenced subpattern not found"), -
2328 QT_TRANSLATE_NOOP("QRegularExpression", "DEFINE group contains more than one branch"), -
2329 QT_TRANSLATE_NOOP("QRegularExpression", "repeating a DEFINE group is not allowed"), -
2330 QT_TRANSLATE_NOOP("QRegularExpression", "inconsistent NEWLINE options"), -
2331 QT_TRANSLATE_NOOP("QRegularExpression", "\\g is not followed by a braced, angle-bracketed, or quoted name/number or by a plain number"), -
2332 QT_TRANSLATE_NOOP("QRegularExpression", "a numbered reference must not be zero"), -
2333 QT_TRANSLATE_NOOP("QRegularExpression", "an argument is not allowed for (*ACCEPT), (*FAIL), or (*COMMIT)"), -
2334 QT_TRANSLATE_NOOP("QRegularExpression", "(*VERB) not recognized"), -
2335 QT_TRANSLATE_NOOP("QRegularExpression", "number is too big"), -
2336 QT_TRANSLATE_NOOP("QRegularExpression", "subpattern name expected"), -
2337 QT_TRANSLATE_NOOP("QRegularExpression", "digit expected after (?+"), -
2338 QT_TRANSLATE_NOOP("QRegularExpression", "] is an invalid data character in JavaScript compatibility mode"), -
2339 QT_TRANSLATE_NOOP("QRegularExpression", "different names for subpatterns of the same number are not allowed"), -
2340 QT_TRANSLATE_NOOP("QRegularExpression", "(*MARK) must have an argument"), -
2341 QT_TRANSLATE_NOOP("QRegularExpression", "this version of PCRE is not compiled with PCRE_UCP support"), -
2342 QT_TRANSLATE_NOOP("QRegularExpression", "\\c must be followed by an ASCII character"), -
2343 QT_TRANSLATE_NOOP("QRegularExpression", "\\k is not followed by a braced, angle-bracketed, or quoted name"), -
2344 QT_TRANSLATE_NOOP("QRegularExpression", "internal error: unknown opcode in find_fixedlength()"), -
2345 QT_TRANSLATE_NOOP("QRegularExpression", "\\N is not supported in a class"), -
2346 QT_TRANSLATE_NOOP("QRegularExpression", "too many forward references"), -
2347 QT_TRANSLATE_NOOP("QRegularExpression", "disallowed Unicode code point (>= 0xd800 && <= 0xdfff)"), -
2348 QT_TRANSLATE_NOOP("QRegularExpression", "invalid UTF-16 string"), -
2349 QT_TRANSLATE_NOOP("QRegularExpression", "name is too long in (*MARK), (*PRUNE), (*SKIP), or (*THEN)"), -
2350 QT_TRANSLATE_NOOP("QRegularExpression", "character value in \\u.... sequence is too large") -
2351}; -
2352#endif // #if 0 -
2353 -
2354QT_END_NAMESPACE -
2355 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial