gi-glib-2.0.26: GLib bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.GLib.Structs.PatternSpec

Description

A GPatternSpec struct is the 'compiled' form of a pattern. This structure is opaque and its fields cannot be accessed directly.

Synopsis

Exported types

newtype PatternSpec Source #

Memory-managed wrapper type.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

copy, equal, free, match, matchString.

Getters

None.

Setters

None.

copy

patternSpecCopy Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> PatternSpec

pspec: a PatternSpec

-> m PatternSpec

Returns: a copy of pspec.

Copies pspec in a new PatternSpec.

Since: 2.70

equal

patternSpecEqual Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> PatternSpec

pspec1: a PatternSpec

-> PatternSpec

pspec2: another PatternSpec

-> m Bool

Returns: Whether the compiled patterns are equal

Compares two compiled pattern specs and returns whether they will match the same set of strings.

free

patternSpecFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> PatternSpec

pspec: a PatternSpec

-> m () 

Frees the memory allocated for the PatternSpec.

match

patternSpecMatch Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> PatternSpec

pspec: a PatternSpec

-> Word64

stringLength: the length of string (in bytes, i.e. strlen(), not utf8Strlen)

-> Text

string: the UTF-8 encoded string to match

-> Maybe Text

stringReversed: the reverse of string or Nothing

-> m Bool

Returns: True if string matches pspec

Matches a string against a compiled pattern. Passing the correct length of the string given is mandatory. The reversed string can be omitted by passing Nothing, this is more efficient if the reversed version of the string to be matched is not at hand, as g_pattern_match() will only construct it if the compiled pattern requires reverse matches.

Note that, if the user code will (possibly) match a string against a multitude of patterns containing wildcards, chances are high that some patterns will require a reversed string. In this case, it's more efficient to provide the reversed string to avoid multiple constructions thereof in the various calls to g_pattern_match().

Note also that the reverse of a UTF-8 encoded string can in general not be obtained by strreverse. This works only if the string does not contain any multibyte characters. GLib offers the utf8Strreverse function to reverse UTF-8 encoded strings.

Since: 2.70

matchString

patternSpecMatchString Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> PatternSpec

pspec: a PatternSpec

-> Text

string: the UTF-8 encoded string to match

-> m Bool

Returns: True if string matches pspec

Matches a string against a compiled pattern. If the string is to be matched against more than one pattern, consider using g_pattern_match() instead while supplying the reversed string.

Since: 2.70

new

patternSpecNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Text

pattern: a zero-terminated UTF-8 encoded string

-> m PatternSpec

Returns: a newly-allocated PatternSpec

Compiles a pattern to a PatternSpec.