pcre2-2.2.1: Regular expressions via the PCRE2 C library (included)
Safe HaskellNone
LanguageHaskell2010

Text.Regex.Pcre2.Foreign

Description

A complete binding to the low-level C API.

Items here are named identically to their C counterparts. Therefore, documentation will be sparse; the official PCRE2 API docs should suffice.

Synopsis

Types

type PCRE2_UCHAR = CUChar Source #

"The UCHAR types define unsigned code units of the appropriate widths. For example, PCRE2_UCHAR16 is usually defined as uint16_t."

type PCRE2_SPTR = Ptr PCRE2_UCHAR Source #

"The SPTR types are constant pointers to the equivalent UCHAR types, that is, they are pointers to vectors of unsigned code units."

type PCRE2_SIZE = CSize Source #

"...string lengths and offsets into strings of code units...are always of type PCRE2_SIZE...currently always defined as size_t."

Opaque types

These correspond to structs that are only ever passed by reference. They simply exist for type safety and cannot be constructed in Haskell.

The general context

pcre2_general_context_create Source #

Arguments

:: FunPtr (PCRE2_SIZE -> Ptr a -> IO (Ptr b))

custom malloc

-> FunPtr (Ptr b -> Ptr a -> IO ())

custom free

-> Ptr a 
-> IO (Ptr Pcre2_general_context) 

The compile context

Compile context setters

pcre2_set_bsr Source #

Arguments

:: Ptr Pcre2_compile_context 
-> CUInt

See below for possible values.

-> IO CInt 

pcre2_set_compile_extra_options Source #

Arguments

:: Ptr Pcre2_compile_context 
-> CUInt

See "Extra compile options" below for possible bit flags.

-> IO CInt 

pcre2_set_newline Source #

Arguments

:: Ptr Pcre2_compile_context 
-> CUInt

See below for possible values.

-> IO CInt 

The match context

Match context setters

pcre2_set_offset_limit Source #

Arguments

:: Ptr Pcre2_match_context 
-> PCRE2_SIZE

Can be unset. See below.

-> IO CInt 

Checking build-time options

pcre2_config Source #

Arguments

:: CUInt

See below for possible values.

-> Ptr a

See the C API docs for what gets returned here.

-> IO CInt 

Compiling a pattern

pcre2_compile Source #

Arguments

:: PCRE2_SPTR 
-> PCRE2_SIZE

Can be zero-terminated. See below.

-> CUInt

See "Main compile options" below for possible bit flags.

-> Ptr CInt 
-> Ptr PCRE2_SIZE 
-> Ptr Pcre2_compile_context 
-> IO (Ptr Pcre2_code) 

Main compile options

Extra compile options

JIT compilation

pcre2_jit_compile Source #

Arguments

:: Ptr Pcre2_code 
-> CUInt

See below for possible bit flags.

-> IO CInt 

pcre2_jit_match Source #

Arguments

:: Ptr Pcre2_code 
-> PCRE2_SPTR

subject

-> PCRE2_SIZE

length

-> PCRE2_SIZE

startoffset

-> CUInt

options

-> Ptr Pcre2_match_data 
-> Ptr Pcre2_match_context 
-> IO CInt 

Locale support

Information about a compiled pattern

pcre2_pattern_info Source #

Arguments

:: Ptr Pcre2_code 
-> CUInt

See below for possible values.

-> Ptr a 
-> IO CInt

See below for possible error values.

Duplicate capture group names

Callouts

Callout struct getters

These functions are not part of the official API; we provide them here. C API consumers are supposed to access struct fields directly, but the FFI cannot yet do that as of GHC 8.8.4.

pcre2_callout_block

pcre2_callout_enumerate_block

pcre2_substitute_callout_block

The match data block

Matching a pattern

pcre2_match Source #

Arguments

:: Ptr Pcre2_code 
-> PCRE2_SPTR

subject

-> PCRE2_SIZE

length

-> PCRE2_SIZE

startoffset

-> CUInt

See below for possible bit flags.

-> Ptr Pcre2_match_data 
-> Ptr Pcre2_match_context 
-> IO CInt 

Match options

Match errors

UTF-16-specific errors

pcre2_ERROR_UTF16_ERR1 :: CInt Source #

"Missing low surrogate at end of string"

pcre2_ERROR_UTF16_ERR2 :: CInt Source #

"Invalid low surrogate follows high surrogate"

pcre2_ERROR_UTF16_ERR3 :: CInt Source #

"Isolated low surrogate"

DFA matching

pcre2_dfa_match Source #

Arguments

:: Ptr Pcre2_code 
-> PCRE2_SPTR

subject

-> PCRE2_SIZE

length

-> PCRE2_SIZE

startoffset

-> CUInt

options

-> Ptr Pcre2_match_data 
-> Ptr Pcre2_match_context 
-> Ptr CInt

workspace

-> PCRE2_SIZE

wscount

-> IO CInt 

DFA matching options

DFA matching errors

Returned string and captured substrings

Creating a new string with substitutions

pcre2_substitute Source #

Arguments

:: Ptr Pcre2_code 
-> PCRE2_SPTR

subject

-> PCRE2_SIZE

length

-> PCRE2_SIZE

startoffset

-> CUInt

options

-> Ptr Pcre2_match_data 
-> Ptr Pcre2_match_context 
-> PCRE2_SPTR

replacement

-> PCRE2_SIZE

rlength

-> Ptr PCRE2_UCHAR

outputbuffer

-> Ptr PCRE2_SIZE

outlengthptr

-> IO CInt 

Substitution options

Substitution errors

Other information about a match

Obtaining a textual error message

Pattern serialization

pcre2_serialize_decode Source #

Arguments

:: Ptr (Ptr Pcre2_code)

codes

-> CInt

number of codes

-> Ptr CUInt

bytes

-> Ptr Pcre2_general_context 
-> IO CInt 

pcre2_serialize_encode Source #

Arguments

:: Ptr (Ptr Pcre2_code)

codes

-> CInt

number of codes

-> Ptr (Ptr CUInt)

serialized bytes

-> Ptr PCRE2_SIZE

serialized size

-> Ptr Pcre2_general_context 
-> IO CInt