Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
GI.GLib.Structs.PatternSpec
Description
A GPatternSpec
struct is the ‘compiled’ form of a glob-style pattern.
The patternMatchSimple
and patternSpecMatch
functions
match a string against a pattern containing *
and ?
wildcards with similar
semantics as the standard glob()
function: *
matches an arbitrary,
possibly empty, string, ?
matches an arbitrary character.
Note that in contrast to `glob()`), the /
character can be
matched by the wildcards, there are no […]
character ranges and *
and ?
can not be escaped to include them literally in a pattern.
When multiple strings must be matched against the same pattern, it is better
to compile the pattern to a [structgLib
.PatternSpec] using
patternSpecNew
and use patternSpecMatchString
instead of patternMatchSimple
. This avoids the overhead of repeated
pattern compilation.
Synopsis
- newtype PatternSpec = PatternSpec (ManagedPtr PatternSpec)
- patternSpecCopy :: (HasCallStack, MonadIO m) => PatternSpec -> m PatternSpec
- patternSpecEqual :: (HasCallStack, MonadIO m) => PatternSpec -> PatternSpec -> m Bool
- patternSpecFree :: (HasCallStack, MonadIO m) => PatternSpec -> m ()
- patternSpecMatch :: (HasCallStack, MonadIO m) => PatternSpec -> CSize -> Text -> Maybe Text -> m Bool
- patternSpecMatchString :: (HasCallStack, MonadIO m) => PatternSpec -> Text -> m Bool
- patternSpecNew :: (HasCallStack, MonadIO m) => Text -> m PatternSpec
Exported types
newtype PatternSpec Source #
Memory-managed wrapper type.
Constructors
PatternSpec (ManagedPtr PatternSpec) |
Instances
Eq PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec | |
GBoxed PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec | |
ManagedPtrNewtype PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods toManagedPtr :: PatternSpec -> ManagedPtr PatternSpec | |
TypedObject PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods glibType :: IO GType | |
HasParentTypes PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec | |
IsGValue (Maybe PatternSpec) Source # | Convert |
Defined in GI.GLib.Structs.PatternSpec Methods gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe PatternSpec -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe PatternSpec) | |
type ParentTypes PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec type ParentTypes PatternSpec = '[] :: [Type] |
Methods
Click to display all available methods, including inherited ones
copy
Arguments
:: (HasCallStack, MonadIO m) | |
=> PatternSpec |
|
-> m PatternSpec | Returns: a copy of |
Copies pspec
in a new [typegLib
.PatternSpec].
Since: 2.70
equal
Arguments
:: (HasCallStack, MonadIO m) | |
=> PatternSpec |
|
-> 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
Arguments
:: (HasCallStack, MonadIO m) | |
=> PatternSpec |
|
-> m () |
Frees the memory allocated for the [typegLib
.PatternSpec].
match
Arguments
:: (HasCallStack, MonadIO m) | |
=> PatternSpec |
|
-> CSize |
|
-> Text |
|
-> Maybe Text |
|
-> m Bool | Returns: |
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 NULL
, this is more efficient if the reversed
version of the string to be matched is not at hand, as
patternSpecMatch
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 patternSpecMatch
.
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 |
|
-> Text |
|
-> m Bool | Returns: |
Matches a string against a compiled pattern.
If the string is to be
matched against more than one pattern, consider using
patternSpecMatch
instead while supplying the reversed string.
Since: 2.70
new
Arguments
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m PatternSpec | Returns: a newly-allocated [type |
Compiles a pattern to a [typegLib
.PatternSpec].