| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| 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 PatternSpec using
patternSpecNew and use patternSpecMatchString
instead of patternMatchSimple. This avoids the overhead of repeated
pattern compilation.
Synopsis
- newtype PatternSpec = PatternSpec (ManagedPtr PatternSpec)
- type family ResolvePatternSpecMethod (t :: Symbol) o where ...
- data PatternSpecCopyMethodInfo
- patternSpecCopy :: (HasCallStack, MonadIO m) => PatternSpec -> m PatternSpec
- data PatternSpecEqualMethodInfo
- patternSpecEqual :: (HasCallStack, MonadIO m) => PatternSpec -> PatternSpec -> m Bool
- data PatternSpecFreeMethodInfo
- patternSpecFree :: (HasCallStack, MonadIO m) => PatternSpec -> m ()
- data PatternSpecMatchMethodInfo
- patternSpecMatch :: (HasCallStack, MonadIO m) => PatternSpec -> CSize -> Text -> Maybe Text -> m Bool
- data PatternSpecMatchStringMethodInfo
- 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
Methods
Click to display all available methods, including inherited ones
type family ResolvePatternSpecMethod (t :: Symbol) o where ... Source #
Equations
| ResolvePatternSpecMethod "copy" o = PatternSpecCopyMethodInfo | |
| ResolvePatternSpecMethod "equal" o = PatternSpecEqualMethodInfo | |
| ResolvePatternSpecMethod "free" o = PatternSpecFreeMethodInfo | |
| ResolvePatternSpecMethod "match" o = PatternSpecMatchMethodInfo | |
| ResolvePatternSpecMethod "matchString" o = PatternSpecMatchStringMethodInfo | |
| ResolvePatternSpecMethod l o = MethodResolutionFailed l o :: Type |
copy
data PatternSpecCopyMethodInfo Source #
Instances
| (signature ~ m PatternSpec, MonadIO m) => OverloadedMethod PatternSpecCopyMethodInfo PatternSpec signature Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods overloadedMethod :: PatternSpec -> signature # | |
| OverloadedMethodInfo PatternSpecCopyMethodInfo PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => PatternSpec |
|
| -> m PatternSpec | Returns: a copy of |
Copies pspec in a new [typegLib.PatternSpec].
Since: 2.70
equal
data PatternSpecEqualMethodInfo Source #
Instances
| (signature ~ (PatternSpec -> m Bool), MonadIO m) => OverloadedMethod PatternSpecEqualMethodInfo PatternSpec signature Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods overloadedMethod :: PatternSpec -> signature # | |
| OverloadedMethodInfo PatternSpecEqualMethodInfo PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods | |
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
data PatternSpecFreeMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod PatternSpecFreeMethodInfo PatternSpec signature Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods overloadedMethod :: PatternSpec -> signature # | |
| OverloadedMethodInfo PatternSpecFreeMethodInfo PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => PatternSpec |
|
| -> m () |
Frees the memory allocated for the [typegLib.PatternSpec].
match
data PatternSpecMatchMethodInfo Source #
Instances
| (signature ~ (CSize -> Text -> Maybe Text -> m Bool), MonadIO m) => OverloadedMethod PatternSpecMatchMethodInfo PatternSpec signature Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods overloadedMethod :: PatternSpec -> signature # | |
| OverloadedMethodInfo PatternSpecMatchMethodInfo PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods | |
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
data PatternSpecMatchStringMethodInfo Source #
Instances
| (signature ~ (Text -> m Bool), MonadIO m) => OverloadedMethod PatternSpecMatchStringMethodInfo PatternSpec signature Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods overloadedMethod :: PatternSpec -> signature # | |
| OverloadedMethodInfo PatternSpecMatchStringMethodInfo PatternSpec Source # | |
Defined in GI.GLib.Structs.PatternSpec Methods | |
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].