Blame glib/gregex.h

Packit ae235b
/* GRegex -- regular expression API wrapper around PCRE.
Packit ae235b
 *
Packit ae235b
 * Copyright (C) 1999, 2000 Scott Wimer
Packit ae235b
 * Copyright (C) 2004, Matthias Clasen <mclasen@redhat.com>
Packit ae235b
 * Copyright (C) 2005 - 2007, Marco Barisione <marco@barisione.org>
Packit ae235b
 *
Packit ae235b
 * This library is free software; you can redistribute it and/or
Packit ae235b
 * modify it under the terms of the GNU Lesser General Public
Packit ae235b
 * License as published by the Free Software Foundation; either
Packit ae235b
 * version 2.1 of the License, or (at your option) any later version.
Packit ae235b
 *
Packit ae235b
 * This library is distributed in the hope that it will be useful,
Packit ae235b
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit ae235b
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit ae235b
 * Lesser General Public License for more details.
Packit ae235b
 *
Packit ae235b
 * You should have received a copy of the GNU Lesser General Public License
Packit ae235b
 * along with this library; if not, see <http://www.gnu.org/licenses/>.
Packit ae235b
 */
Packit ae235b
Packit ae235b
#ifndef __G_REGEX_H__
Packit ae235b
#define __G_REGEX_H__
Packit ae235b
Packit ae235b
#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
Packit ae235b
#error "Only <glib.h> can be included directly."
Packit ae235b
#endif
Packit ae235b
Packit ae235b
#include <glib/gerror.h>
Packit ae235b
#include <glib/gstring.h>
Packit ae235b
Packit ae235b
G_BEGIN_DECLS
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRegexError:
Packit ae235b
 * @G_REGEX_ERROR_COMPILE: Compilation of the regular expression failed.
Packit ae235b
 * @G_REGEX_ERROR_OPTIMIZE: Optimization of the regular expression failed.
Packit ae235b
 * @G_REGEX_ERROR_REPLACE: Replacement failed due to an ill-formed replacement
Packit ae235b
 *     string.
Packit ae235b
 * @G_REGEX_ERROR_MATCH: The match process failed.
Packit ae235b
 * @G_REGEX_ERROR_INTERNAL: Internal error of the regular expression engine.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_STRAY_BACKSLASH: "\\" at end of pattern. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_MISSING_CONTROL_CHAR: "\\c" at end of pattern. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNRECOGNIZED_ESCAPE: Unrecognized character follows "\\".
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER: Numbers out of order in "{}"
Packit ae235b
 *     quantifier. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_QUANTIFIER_TOO_BIG: Number too big in "{}" quantifier.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS: Missing terminating "]" for
Packit ae235b
 *     character class. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS: Invalid escape sequence
Packit ae235b
 *     in character class. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_RANGE_OUT_OF_ORDER: Range out of order in character class.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_NOTHING_TO_REPEAT: Nothing to repeat. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNRECOGNIZED_CHARACTER: Unrecognized character after "(?",
Packit ae235b
 *     "(?<" or "(?P". Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS: POSIX named classes are
Packit ae235b
 *     supported only within a class. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNMATCHED_PARENTHESIS: Missing terminating ")" or ")"
Packit ae235b
 *     without opening "(". Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE: Reference to non-existent
Packit ae235b
 *     subpattern. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNTERMINATED_COMMENT: Missing terminating ")" after comment.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_EXPRESSION_TOO_LARGE: Regular expression too large.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_MEMORY_ERROR: Failed to get memory. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND: Lookbehind assertion is not
Packit ae235b
 *     fixed length. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_MALFORMED_CONDITION: Malformed number or name after "(?(".
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES: Conditional group contains
Packit ae235b
 *     more than two branches. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_ASSERTION_EXPECTED: Assertion expected after "(?(".
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME: Unknown POSIX class name.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED: POSIX collating
Packit ae235b
 *     elements are not supported. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_HEX_CODE_TOO_LARGE: Character value in "\\x{...}" sequence
Packit ae235b
 *     is too large. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_INVALID_CONDITION: Invalid condition "(?(0)". Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND: \\C not allowed in
Packit ae235b
 *     lookbehind assertion. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_INFINITE_LOOP: Recursive call could loop indefinitely.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR: Missing terminator
Packit ae235b
 *     in subpattern name. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME: Two named subpatterns have
Packit ae235b
 *     the same name. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_MALFORMED_PROPERTY: Malformed "\\P" or "\\p" sequence.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_UNKNOWN_PROPERTY: Unknown property name after "\\P" or
Packit ae235b
 *     "\\p". Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG: Subpattern name is too long
Packit ae235b
 *     (maximum 32 characters). Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_TOO_MANY_SUBPATTERNS: Too many named subpatterns (maximum
Packit ae235b
 *     10,000). Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_INVALID_OCTAL_VALUE: Octal value is greater than "\\377".
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE: "DEFINE" group contains more
Packit ae235b
 *     than one branch. Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_DEFINE_REPETION: Repeating a "DEFINE" group is not allowed.
Packit ae235b
 *     This error is never raised. Since: 2.16 Deprecated: 2.34
Packit ae235b
 * @G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS: Inconsistent newline options.
Packit ae235b
 *     Since 2.16
Packit ae235b
 * @G_REGEX_ERROR_MISSING_BACK_REFERENCE: "\\g" is not followed by a braced,
Packit ae235b
 *      angle-bracketed, or quoted name or number, or by a plain number. Since: 2.16
Packit ae235b
 * @G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE: relative reference must not be zero. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN: the backtracing
Packit ae235b
 *     control verb used does not allow an argument. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB: unknown backtracing 
Packit ae235b
 *     control verb. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_NUMBER_TOO_BIG: number is too big in escape sequence. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_MISSING_SUBPATTERN_NAME: Missing subpattern name. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_MISSING_DIGIT: Missing digit. Since 2.34
Packit ae235b
 * @G_REGEX_ERROR_INVALID_DATA_CHARACTER: In JavaScript compatibility mode,
Packit ae235b
 *     "[" is an invalid data character. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME: different names for subpatterns of the 
Packit ae235b
 *     same number are not allowed. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED: the backtracing control
Packit ae235b
 *     verb requires an argument. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_INVALID_CONTROL_CHAR: "\\c" must be followed by an ASCII 
Packit ae235b
 *     character. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_MISSING_NAME: "\\k" is not followed by a braced, angle-bracketed, or 
Packit ae235b
 *     quoted name. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS: "\\N" is not supported in a class. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES: too many forward references. Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_NAME_TOO_LONG: the name is too long in "(*MARK)", "(*PRUNE)", 
Packit ae235b
 *     "(*SKIP)", or "(*THEN)". Since: 2.34
Packit ae235b
 * @G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE: the character value in the \\u sequence is
Packit ae235b
 *     too large. Since: 2.34
Packit ae235b
 *
Packit ae235b
 * Error codes returned by regular expressions functions.
Packit ae235b
 *
Packit ae235b
 * Since: 2.14
Packit ae235b
 */
Packit ae235b
typedef enum
Packit ae235b
{
Packit ae235b
  G_REGEX_ERROR_COMPILE,
Packit ae235b
  G_REGEX_ERROR_OPTIMIZE,
Packit ae235b
  G_REGEX_ERROR_REPLACE,
Packit ae235b
  G_REGEX_ERROR_MATCH,
Packit ae235b
  G_REGEX_ERROR_INTERNAL,
Packit ae235b
Packit ae235b
  /* These are the error codes from PCRE + 100 */
Packit ae235b
  G_REGEX_ERROR_STRAY_BACKSLASH = 101,
Packit ae235b
  G_REGEX_ERROR_MISSING_CONTROL_CHAR = 102,
Packit ae235b
  G_REGEX_ERROR_UNRECOGNIZED_ESCAPE = 103,
Packit ae235b
  G_REGEX_ERROR_QUANTIFIERS_OUT_OF_ORDER = 104,
Packit ae235b
  G_REGEX_ERROR_QUANTIFIER_TOO_BIG = 105,
Packit ae235b
  G_REGEX_ERROR_UNTERMINATED_CHARACTER_CLASS = 106,
Packit ae235b
  G_REGEX_ERROR_INVALID_ESCAPE_IN_CHARACTER_CLASS = 107,
Packit ae235b
  G_REGEX_ERROR_RANGE_OUT_OF_ORDER = 108,
Packit ae235b
  G_REGEX_ERROR_NOTHING_TO_REPEAT = 109,
Packit ae235b
  G_REGEX_ERROR_UNRECOGNIZED_CHARACTER = 112,
Packit ae235b
  G_REGEX_ERROR_POSIX_NAMED_CLASS_OUTSIDE_CLASS = 113,
Packit ae235b
  G_REGEX_ERROR_UNMATCHED_PARENTHESIS = 114,
Packit ae235b
  G_REGEX_ERROR_INEXISTENT_SUBPATTERN_REFERENCE = 115,
Packit ae235b
  G_REGEX_ERROR_UNTERMINATED_COMMENT = 118,
Packit ae235b
  G_REGEX_ERROR_EXPRESSION_TOO_LARGE = 120,
Packit ae235b
  G_REGEX_ERROR_MEMORY_ERROR = 121,
Packit ae235b
  G_REGEX_ERROR_VARIABLE_LENGTH_LOOKBEHIND = 125,
Packit ae235b
  G_REGEX_ERROR_MALFORMED_CONDITION = 126,
Packit ae235b
  G_REGEX_ERROR_TOO_MANY_CONDITIONAL_BRANCHES = 127,
Packit ae235b
  G_REGEX_ERROR_ASSERTION_EXPECTED = 128,
Packit ae235b
  G_REGEX_ERROR_UNKNOWN_POSIX_CLASS_NAME = 130,
Packit ae235b
  G_REGEX_ERROR_POSIX_COLLATING_ELEMENTS_NOT_SUPPORTED = 131,
Packit ae235b
  G_REGEX_ERROR_HEX_CODE_TOO_LARGE = 134,
Packit ae235b
  G_REGEX_ERROR_INVALID_CONDITION = 135,
Packit ae235b
  G_REGEX_ERROR_SINGLE_BYTE_MATCH_IN_LOOKBEHIND = 136,
Packit ae235b
  G_REGEX_ERROR_INFINITE_LOOP = 140,
Packit ae235b
  G_REGEX_ERROR_MISSING_SUBPATTERN_NAME_TERMINATOR = 142,
Packit ae235b
  G_REGEX_ERROR_DUPLICATE_SUBPATTERN_NAME = 143,
Packit ae235b
  G_REGEX_ERROR_MALFORMED_PROPERTY = 146,
Packit ae235b
  G_REGEX_ERROR_UNKNOWN_PROPERTY = 147,
Packit ae235b
  G_REGEX_ERROR_SUBPATTERN_NAME_TOO_LONG = 148,
Packit ae235b
  G_REGEX_ERROR_TOO_MANY_SUBPATTERNS = 149,
Packit ae235b
  G_REGEX_ERROR_INVALID_OCTAL_VALUE = 151,
Packit ae235b
  G_REGEX_ERROR_TOO_MANY_BRANCHES_IN_DEFINE = 154,
Packit ae235b
  G_REGEX_ERROR_DEFINE_REPETION = 155,
Packit ae235b
  G_REGEX_ERROR_INCONSISTENT_NEWLINE_OPTIONS = 156,
Packit ae235b
  G_REGEX_ERROR_MISSING_BACK_REFERENCE = 157,
Packit ae235b
  G_REGEX_ERROR_INVALID_RELATIVE_REFERENCE = 158,
Packit ae235b
  G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_FORBIDDEN = 159,
Packit ae235b
  G_REGEX_ERROR_UNKNOWN_BACKTRACKING_CONTROL_VERB  = 160,
Packit ae235b
  G_REGEX_ERROR_NUMBER_TOO_BIG = 161,
Packit ae235b
  G_REGEX_ERROR_MISSING_SUBPATTERN_NAME = 162,
Packit ae235b
  G_REGEX_ERROR_MISSING_DIGIT = 163,
Packit ae235b
  G_REGEX_ERROR_INVALID_DATA_CHARACTER = 164,
Packit ae235b
  G_REGEX_ERROR_EXTRA_SUBPATTERN_NAME = 165,
Packit ae235b
  G_REGEX_ERROR_BACKTRACKING_CONTROL_VERB_ARGUMENT_REQUIRED = 166,
Packit ae235b
  G_REGEX_ERROR_INVALID_CONTROL_CHAR = 168,
Packit ae235b
  G_REGEX_ERROR_MISSING_NAME = 169,
Packit ae235b
  G_REGEX_ERROR_NOT_SUPPORTED_IN_CLASS = 171,
Packit ae235b
  G_REGEX_ERROR_TOO_MANY_FORWARD_REFERENCES = 172,
Packit ae235b
  G_REGEX_ERROR_NAME_TOO_LONG = 175,
Packit ae235b
  G_REGEX_ERROR_CHARACTER_VALUE_TOO_LARGE = 176
Packit ae235b
} GRegexError;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * G_REGEX_ERROR:
Packit ae235b
 *
Packit ae235b
 * Error domain for regular expressions. Errors in this domain will be
Packit ae235b
 * from the #GRegexError enumeration. See #GError for information on
Packit ae235b
 * error domains.
Packit ae235b
 *
Packit ae235b
 * Since: 2.14
Packit ae235b
 */
Packit ae235b
#define G_REGEX_ERROR g_regex_error_quark ()
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GQuark g_regex_error_quark (void);
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRegexCompileFlags:
Packit ae235b
 * @G_REGEX_CASELESS: Letters in the pattern match both upper- and
Packit ae235b
 *     lowercase letters. This option can be changed within a pattern
Packit ae235b
 *     by a "(?i)" option setting.
Packit ae235b
 * @G_REGEX_MULTILINE: By default, GRegex treats the strings as consisting
Packit ae235b
 *     of a single line of characters (even if it actually contains
Packit ae235b
 *     newlines). The "start of line" metacharacter ("^") matches only
Packit ae235b
 *     at the start of the string, while the "end of line" metacharacter
Packit ae235b
 *     ("$") matches only at the end of the string, or before a terminating
Packit ae235b
 *     newline (unless #G_REGEX_DOLLAR_ENDONLY is set). When
Packit ae235b
 *     #G_REGEX_MULTILINE is set, the "start of line" and "end of line"
Packit ae235b
 *     constructs match immediately following or immediately before any
Packit ae235b
 *     newline in the string, respectively, as well as at the very start
Packit ae235b
 *     and end. This can be changed within a pattern by a "(?m)" option
Packit ae235b
 *     setting.
Packit ae235b
 * @G_REGEX_DOTALL: A dot metacharacter (".") in the pattern matches all
Packit ae235b
 *     characters, including newlines. Without it, newlines are excluded.
Packit ae235b
 *     This option can be changed within a pattern by a ("?s") option setting.
Packit ae235b
 * @G_REGEX_EXTENDED: Whitespace data characters in the pattern are
Packit ae235b
 *     totally ignored except when escaped or inside a character class.
Packit ae235b
 *     Whitespace does not include the VT character (code 11). In addition,
Packit ae235b
 *     characters between an unescaped "#" outside a character class and
Packit ae235b
 *     the next newline character, inclusive, are also ignored. This can
Packit ae235b
 *     be changed within a pattern by a "(?x)" option setting.
Packit ae235b
 * @G_REGEX_ANCHORED: The pattern is forced to be "anchored", that is,
Packit ae235b
 *     it is constrained to match only at the first matching point in the
Packit ae235b
 *     string that is being searched. This effect can also be achieved by
Packit ae235b
 *     appropriate constructs in the pattern itself such as the "^"
Packit ae235b
 *     metacharacter.
Packit ae235b
 * @G_REGEX_DOLLAR_ENDONLY: A dollar metacharacter ("$") in the pattern
Packit ae235b
 *     matches only at the end of the string. Without this option, a
Packit ae235b
 *     dollar also matches immediately before the final character if
Packit ae235b
 *     it is a newline (but not before any other newlines). This option
Packit ae235b
 *     is ignored if #G_REGEX_MULTILINE is set.
Packit ae235b
 * @G_REGEX_UNGREEDY: Inverts the "greediness" of the quantifiers so that
Packit ae235b
 *     they are not greedy by default, but become greedy if followed by "?".
Packit ae235b
 *     It can also be set by a "(?U)" option setting within the pattern.
Packit ae235b
 * @G_REGEX_RAW: Usually strings must be valid UTF-8 strings, using this
Packit ae235b
 *     flag they are considered as a raw sequence of bytes.
Packit ae235b
 * @G_REGEX_NO_AUTO_CAPTURE: Disables the use of numbered capturing
Packit ae235b
 *     parentheses in the pattern. Any opening parenthesis that is not
Packit ae235b
 *     followed by "?" behaves as if it were followed by "?:" but named
Packit ae235b
 *     parentheses can still be used for capturing (and they acquire numbers
Packit ae235b
 *     in the usual way).
Packit ae235b
 * @G_REGEX_OPTIMIZE: Optimize the regular expression. If the pattern will
Packit ae235b
 *     be used many times, then it may be worth the effort to optimize it
Packit ae235b
 *     to improve the speed of matches.
Packit ae235b
 * @G_REGEX_FIRSTLINE: Limits an unanchored pattern to match before (or at) the
Packit ae235b
 *     first newline. Since: 2.34
Packit ae235b
 * @G_REGEX_DUPNAMES: Names used to identify capturing subpatterns need not
Packit ae235b
 *     be unique. This can be helpful for certain types of pattern when it
Packit ae235b
 *     is known that only one instance of the named subpattern can ever be
Packit ae235b
 *     matched.
Packit ae235b
 * @G_REGEX_NEWLINE_CR: Usually any newline character or character sequence is
Packit ae235b
 *     recognized. If this option is set, the only recognized newline character
Packit ae235b
 *     is '\r'.
Packit ae235b
 * @G_REGEX_NEWLINE_LF: Usually any newline character or character sequence is
Packit ae235b
 *     recognized. If this option is set, the only recognized newline character
Packit ae235b
 *     is '\n'.
Packit ae235b
 * @G_REGEX_NEWLINE_CRLF: Usually any newline character or character sequence is
Packit ae235b
 *     recognized. If this option is set, the only recognized newline character
Packit ae235b
 *     sequence is '\r\n'.
Packit ae235b
 * @G_REGEX_NEWLINE_ANYCRLF: Usually any newline character or character sequence
Packit ae235b
 *     is recognized. If this option is set, the only recognized newline character
Packit ae235b
 *     sequences are '\r', '\n', and '\r\n'. Since: 2.34
Packit ae235b
 * @G_REGEX_BSR_ANYCRLF: Usually any newline character or character sequence
Packit ae235b
 *     is recognised. If this option is set, then "\R" only recognizes the newline
Packit ae235b
 *    characters '\r', '\n' and '\r\n'. Since: 2.34
Packit ae235b
 * @G_REGEX_JAVASCRIPT_COMPAT: Changes behaviour so that it is compatible with
Packit ae235b
 *     JavaScript rather than PCRE. Since: 2.34
Packit ae235b
 *
Packit ae235b
 * Flags specifying compile-time options.
Packit ae235b
 *
Packit ae235b
 * Since: 2.14
Packit ae235b
 */
Packit ae235b
/* Remember to update G_REGEX_COMPILE_MASK in gregex.c after
Packit ae235b
 * adding a new flag.
Packit ae235b
 */
Packit ae235b
typedef enum
Packit ae235b
{
Packit ae235b
  G_REGEX_CASELESS          = 1 << 0,
Packit ae235b
  G_REGEX_MULTILINE         = 1 << 1,
Packit ae235b
  G_REGEX_DOTALL            = 1 << 2,
Packit ae235b
  G_REGEX_EXTENDED          = 1 << 3,
Packit ae235b
  G_REGEX_ANCHORED          = 1 << 4,
Packit ae235b
  G_REGEX_DOLLAR_ENDONLY    = 1 << 5,
Packit ae235b
  G_REGEX_UNGREEDY          = 1 << 9,
Packit ae235b
  G_REGEX_RAW               = 1 << 11,
Packit ae235b
  G_REGEX_NO_AUTO_CAPTURE   = 1 << 12,
Packit ae235b
  G_REGEX_OPTIMIZE          = 1 << 13,
Packit ae235b
  G_REGEX_FIRSTLINE         = 1 << 18,
Packit ae235b
  G_REGEX_DUPNAMES          = 1 << 19,
Packit ae235b
  G_REGEX_NEWLINE_CR        = 1 << 20,
Packit ae235b
  G_REGEX_NEWLINE_LF        = 1 << 21,
Packit ae235b
  G_REGEX_NEWLINE_CRLF      = G_REGEX_NEWLINE_CR | G_REGEX_NEWLINE_LF,
Packit ae235b
  G_REGEX_NEWLINE_ANYCRLF   = G_REGEX_NEWLINE_CR | 1 << 22,
Packit ae235b
  G_REGEX_BSR_ANYCRLF       = 1 << 23,
Packit ae235b
  G_REGEX_JAVASCRIPT_COMPAT = 1 << 25
Packit ae235b
} GRegexCompileFlags;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRegexMatchFlags:
Packit ae235b
 * @G_REGEX_MATCH_ANCHORED: The pattern is forced to be "anchored", that is,
Packit ae235b
 *     it is constrained to match only at the first matching point in the
Packit ae235b
 *     string that is being searched. This effect can also be achieved by
Packit ae235b
 *     appropriate constructs in the pattern itself such as the "^"
Packit ae235b
 *     metacharacter.
Packit ae235b
 * @G_REGEX_MATCH_NOTBOL: Specifies that first character of the string is
Packit ae235b
 *     not the beginning of a line, so the circumflex metacharacter should
Packit ae235b
 *     not match before it. Setting this without #G_REGEX_MULTILINE (at
Packit ae235b
 *     compile time) causes circumflex never to match. This option affects
Packit ae235b
 *     only the behaviour of the circumflex metacharacter, it does not
Packit ae235b
 *     affect "\A".
Packit ae235b
 * @G_REGEX_MATCH_NOTEOL: Specifies that the end of the subject string is
Packit ae235b
 *     not the end of a line, so the dollar metacharacter should not match
Packit ae235b
 *     it nor (except in multiline mode) a newline immediately before it.
Packit ae235b
 *     Setting this without #G_REGEX_MULTILINE (at compile time) causes
Packit ae235b
 *     dollar never to match. This option affects only the behaviour of
Packit ae235b
 *     the dollar metacharacter, it does not affect "\Z" or "\z".
Packit ae235b
 * @G_REGEX_MATCH_NOTEMPTY: An empty string is not considered to be a valid
Packit ae235b
 *     match if this option is set. If there are alternatives in the pattern,
Packit ae235b
 *     they are tried. If all the alternatives match the empty string, the
Packit ae235b
 *     entire match fails. For example, if the pattern "a?b?" is applied to
Packit ae235b
 *     a string not beginning with "a" or "b", it matches the empty string
Packit ae235b
 *     at the start of the string. With this flag set, this match is not
Packit ae235b
 *     valid, so GRegex searches further into the string for occurrences
Packit ae235b
 *     of "a" or "b".
Packit ae235b
 * @G_REGEX_MATCH_PARTIAL: Turns on the partial matching feature, for more
Packit ae235b
 *     documentation on partial matching see g_match_info_is_partial_match().
Packit ae235b
 * @G_REGEX_MATCH_NEWLINE_CR: Overrides the newline definition set when
Packit ae235b
 *     creating a new #GRegex, setting the '\r' character as line terminator.
Packit ae235b
 * @G_REGEX_MATCH_NEWLINE_LF: Overrides the newline definition set when
Packit ae235b
 *     creating a new #GRegex, setting the '\n' character as line terminator.
Packit ae235b
 * @G_REGEX_MATCH_NEWLINE_CRLF: Overrides the newline definition set when
Packit ae235b
 *     creating a new #GRegex, setting the '\r\n' characters sequence as line terminator.
Packit ae235b
 * @G_REGEX_MATCH_NEWLINE_ANY: Overrides the newline definition set when
Packit ae235b
 *     creating a new #GRegex, any Unicode newline sequence
Packit ae235b
 *     is recognised as a newline. These are '\r', '\n' and '\rn', and the
Packit ae235b
 *     single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
Packit ae235b
 *     U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
Packit ae235b
 *     U+2029 PARAGRAPH SEPARATOR.
Packit ae235b
 * @G_REGEX_MATCH_NEWLINE_ANYCRLF: Overrides the newline definition set when
Packit ae235b
 *     creating a new #GRegex; any '\r', '\n', or '\r\n' character sequence
Packit ae235b
 *     is recognized as a newline. Since: 2.34
Packit ae235b
 * @G_REGEX_MATCH_BSR_ANYCRLF: Overrides the newline definition for "\R" set when
Packit ae235b
 *     creating a new #GRegex; only '\r', '\n', or '\r\n' character sequences
Packit ae235b
 *     are recognized as a newline by "\R". Since: 2.34
Packit ae235b
 * @G_REGEX_MATCH_BSR_ANY: Overrides the newline definition for "\R" set when
Packit ae235b
 *     creating a new #GRegex; any Unicode newline character or character sequence
Packit ae235b
 *     are recognized as a newline by "\R". These are '\r', '\n' and '\rn', and the
Packit ae235b
 *     single characters U+000B LINE TABULATION, U+000C FORM FEED (FF),
Packit ae235b
 *     U+0085 NEXT LINE (NEL), U+2028 LINE SEPARATOR and
Packit ae235b
 *     U+2029 PARAGRAPH SEPARATOR. Since: 2.34
Packit ae235b
 * @G_REGEX_MATCH_PARTIAL_SOFT: An alias for #G_REGEX_MATCH_PARTIAL. Since: 2.34
Packit ae235b
 * @G_REGEX_MATCH_PARTIAL_HARD: Turns on the partial matching feature. In contrast to
Packit ae235b
 *     to #G_REGEX_MATCH_PARTIAL_SOFT, this stops matching as soon as a partial match
Packit ae235b
 *     is found, without continuing to search for a possible complete match. See
Packit ae235b
 *     g_match_info_is_partial_match() for more information. Since: 2.34
Packit ae235b
 * @G_REGEX_MATCH_NOTEMPTY_ATSTART: Like #G_REGEX_MATCH_NOTEMPTY, but only applied to
Packit ae235b
 *     the start of the matched string. For anchored
Packit ae235b
 *     patterns this can only happen for pattern containing "\K". Since: 2.34
Packit ae235b
 *
Packit ae235b
 * Flags specifying match-time options.
Packit ae235b
 *
Packit ae235b
 * Since: 2.14
Packit ae235b
 */
Packit ae235b
/* Remember to update G_REGEX_MATCH_MASK in gregex.c after
Packit ae235b
 * adding a new flag. */
Packit ae235b
typedef enum
Packit ae235b
{
Packit ae235b
  G_REGEX_MATCH_ANCHORED         = 1 << 4,
Packit ae235b
  G_REGEX_MATCH_NOTBOL           = 1 << 7,
Packit ae235b
  G_REGEX_MATCH_NOTEOL           = 1 << 8,
Packit ae235b
  G_REGEX_MATCH_NOTEMPTY         = 1 << 10,
Packit ae235b
  G_REGEX_MATCH_PARTIAL          = 1 << 15,
Packit ae235b
  G_REGEX_MATCH_NEWLINE_CR       = 1 << 20,
Packit ae235b
  G_REGEX_MATCH_NEWLINE_LF       = 1 << 21,
Packit ae235b
  G_REGEX_MATCH_NEWLINE_CRLF     = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_LF,
Packit ae235b
  G_REGEX_MATCH_NEWLINE_ANY      = 1 << 22,
Packit ae235b
  G_REGEX_MATCH_NEWLINE_ANYCRLF  = G_REGEX_MATCH_NEWLINE_CR | G_REGEX_MATCH_NEWLINE_ANY,
Packit ae235b
  G_REGEX_MATCH_BSR_ANYCRLF      = 1 << 23,
Packit ae235b
  G_REGEX_MATCH_BSR_ANY          = 1 << 24,
Packit ae235b
  G_REGEX_MATCH_PARTIAL_SOFT     = G_REGEX_MATCH_PARTIAL,
Packit ae235b
  G_REGEX_MATCH_PARTIAL_HARD     = 1 << 27,
Packit ae235b
  G_REGEX_MATCH_NOTEMPTY_ATSTART = 1 << 28
Packit ae235b
} GRegexMatchFlags;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRegex:
Packit ae235b
 *
Packit ae235b
 * A GRegex is the "compiled" form of a regular expression pattern.
Packit ae235b
 * This structure is opaque and its fields cannot be accessed directly.
Packit ae235b
 *
Packit ae235b
 * Since: 2.14
Packit ae235b
 */
Packit ae235b
typedef struct _GRegex		GRegex;
Packit ae235b
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GMatchInfo:
Packit ae235b
 *
Packit ae235b
 * A GMatchInfo is an opaque struct used to return information about
Packit ae235b
 * matches.
Packit ae235b
 */
Packit ae235b
typedef struct _GMatchInfo	GMatchInfo;
Packit ae235b
Packit ae235b
/**
Packit ae235b
 * GRegexEvalCallback:
Packit ae235b
 * @match_info: the #GMatchInfo generated by the match.
Packit ae235b
 *     Use g_match_info_get_regex() and g_match_info_get_string() if you
Packit ae235b
 *     need the #GRegex or the matched string.
Packit ae235b
 * @result: a #GString containing the new string
Packit ae235b
 * @user_data: user data passed to g_regex_replace_eval()
Packit ae235b
 *
Packit ae235b
 * Specifies the type of the function passed to g_regex_replace_eval().
Packit ae235b
 * It is called for each occurrence of the pattern in the string passed
Packit ae235b
 * to g_regex_replace_eval(), and it should append the replacement to
Packit ae235b
 * @result.
Packit ae235b
 *
Packit ae235b
 * Returns: %FALSE to continue the replacement process, %TRUE to stop it
Packit ae235b
 *
Packit ae235b
 * Since: 2.14
Packit ae235b
 */
Packit ae235b
typedef gboolean (*GRegexEvalCallback)		(const GMatchInfo *match_info,
Packit ae235b
						 GString          *result,
Packit ae235b
						 gpointer          user_data);
Packit ae235b
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GRegex		 *g_regex_new			(const gchar         *pattern,
Packit ae235b
						 GRegexCompileFlags   compile_options,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GRegex           *g_regex_ref			(GRegex              *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void		  g_regex_unref			(GRegex              *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
const gchar	 *g_regex_get_pattern		(const GRegex        *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint		  g_regex_get_max_backref	(const GRegex        *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint		  g_regex_get_capture_count	(const GRegex        *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean          g_regex_get_has_cr_or_lf      (const GRegex        *regex);
Packit ae235b
GLIB_AVAILABLE_IN_2_38
Packit ae235b
gint              g_regex_get_max_lookbehind    (const GRegex        *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint		  g_regex_get_string_number	(const GRegex        *regex, 
Packit ae235b
						 const gchar         *name);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_regex_escape_string		(const gchar         *string,
Packit ae235b
						 gint                 length);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_regex_escape_nul		(const gchar         *string,
Packit ae235b
						 gint                 length);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GRegexCompileFlags g_regex_get_compile_flags    (const GRegex        *regex);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GRegexMatchFlags   g_regex_get_match_flags      (const GRegex        *regex);
Packit ae235b
Packit ae235b
/* Matching. */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_regex_match_simple		(const gchar         *pattern,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 GRegexCompileFlags   compile_options,
Packit ae235b
						 GRegexMatchFlags     match_options);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_regex_match			(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GMatchInfo         **match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_regex_match_full		(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 gssize               string_len,
Packit ae235b
						 gint                 start_position,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GMatchInfo         **match_info,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_regex_match_all		(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GMatchInfo         **match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_regex_match_all_full	(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 gssize               string_len,
Packit ae235b
						 gint                 start_position,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GMatchInfo         **match_info,
Packit ae235b
						 GError             **error);
Packit ae235b
Packit ae235b
/* String splitting. */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		**g_regex_split_simple		(const gchar         *pattern,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 GRegexCompileFlags   compile_options,
Packit ae235b
						 GRegexMatchFlags     match_options);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		**g_regex_split			(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 GRegexMatchFlags     match_options);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		**g_regex_split_full		(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 gssize               string_len,
Packit ae235b
						 gint                 start_position,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 gint                 max_tokens,
Packit ae235b
						 GError             **error);
Packit ae235b
Packit ae235b
/* String replacement. */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_regex_replace		(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 gssize               string_len,
Packit ae235b
						 gint                 start_position,
Packit ae235b
						 const gchar         *replacement,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_regex_replace_literal	(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 gssize               string_len,
Packit ae235b
						 gint                 start_position,
Packit ae235b
						 const gchar         *replacement,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_regex_replace_eval		(const GRegex        *regex,
Packit ae235b
						 const gchar         *string,
Packit ae235b
						 gssize               string_len,
Packit ae235b
						 gint                 start_position,
Packit ae235b
						 GRegexMatchFlags     match_options,
Packit ae235b
						 GRegexEvalCallback   eval,
Packit ae235b
						 gpointer             user_data,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_regex_check_replacement	(const gchar         *replacement,
Packit ae235b
						 gboolean            *has_references,
Packit ae235b
						 GError             **error);
Packit ae235b
Packit ae235b
/* Match info */
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GRegex		 *g_match_info_get_regex	(const GMatchInfo    *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
const gchar      *g_match_info_get_string       (const GMatchInfo    *match_info);
Packit ae235b
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
GMatchInfo       *g_match_info_ref              (GMatchInfo          *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void              g_match_info_unref            (GMatchInfo          *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
void		  g_match_info_free		(GMatchInfo          *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_match_info_next		(GMatchInfo          *match_info,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_match_info_matches		(const GMatchInfo    *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gint		  g_match_info_get_match_count	(const GMatchInfo    *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_match_info_is_partial_match	(const GMatchInfo    *match_info);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_match_info_expand_references(const GMatchInfo    *match_info,
Packit ae235b
						 const gchar         *string_to_expand,
Packit ae235b
						 GError             **error);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_match_info_fetch		(const GMatchInfo    *match_info,
Packit ae235b
						 gint                 match_num);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_match_info_fetch_pos	(const GMatchInfo    *match_info,
Packit ae235b
						 gint                 match_num,
Packit ae235b
						 gint                *start_pos,
Packit ae235b
						 gint                *end_pos);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		 *g_match_info_fetch_named	(const GMatchInfo    *match_info,
Packit ae235b
						 const gchar         *name);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gboolean	  g_match_info_fetch_named_pos	(const GMatchInfo    *match_info,
Packit ae235b
						 const gchar         *name,
Packit ae235b
						 gint                *start_pos,
Packit ae235b
						 gint                *end_pos);
Packit ae235b
GLIB_AVAILABLE_IN_ALL
Packit ae235b
gchar		**g_match_info_fetch_all	(const GMatchInfo    *match_info);
Packit ae235b
Packit ae235b
G_END_DECLS
Packit ae235b
Packit ae235b
#endif  /*  __G_REGEX_H__ */