| 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.StrvBuilder
Contents
Description
GStrvBuilder is a helper object to build a Nothing-terminated string arrays.
The following example shows how to build a two element array:
c code
g_autoptr(GStrvBuilder) builder = g_strv_builder_new ();
g_strv_builder_add (builder, "hello");
g_strv_builder_add (builder, "world");
g_auto(GStrv) array = g_strv_builder_end (builder);
g_assert_true (g_strv_equal (array, (const char *[]) { "hello", "world", NULL }));Since: 2.68
Synopsis
- newtype StrvBuilder = StrvBuilder (ManagedPtr StrvBuilder)
- type family ResolveStrvBuilderMethod (t :: Symbol) o where ...
- data StrvBuilderAddMethodInfo
- strvBuilderAdd :: (HasCallStack, MonadIO m) => StrvBuilder -> Text -> m ()
- data StrvBuilderAddvMethodInfo
- strvBuilderAddv :: (HasCallStack, MonadIO m) => StrvBuilder -> [Text] -> m ()
- data StrvBuilderEndMethodInfo
- strvBuilderEnd :: (HasCallStack, MonadIO m) => StrvBuilder -> m [Text]
- strvBuilderNew :: (HasCallStack, MonadIO m) => m StrvBuilder
- data StrvBuilderRefMethodInfo
- strvBuilderRef :: (HasCallStack, MonadIO m) => StrvBuilder -> m StrvBuilder
- data StrvBuilderTakeMethodInfo
- strvBuilderTake :: (HasCallStack, MonadIO m) => StrvBuilder -> Text -> m ()
- data StrvBuilderUnrefMethodInfo
- strvBuilderUnref :: (HasCallStack, MonadIO m) => StrvBuilder -> m ()
- data StrvBuilderUnrefToStrvMethodInfo
- strvBuilderUnrefToStrv :: (HasCallStack, MonadIO m) => StrvBuilder -> m [Text]
Exported types
newtype StrvBuilder Source #
Memory-managed wrapper type.
Constructors
| StrvBuilder (ManagedPtr StrvBuilder) |
Instances
Methods
Click to display all available methods, including inherited ones
type family ResolveStrvBuilderMethod (t :: Symbol) o where ... Source #
Equations
| ResolveStrvBuilderMethod "add" o = StrvBuilderAddMethodInfo | |
| ResolveStrvBuilderMethod "addv" o = StrvBuilderAddvMethodInfo | |
| ResolveStrvBuilderMethod "end" o = StrvBuilderEndMethodInfo | |
| ResolveStrvBuilderMethod "ref" o = StrvBuilderRefMethodInfo | |
| ResolveStrvBuilderMethod "take" o = StrvBuilderTakeMethodInfo | |
| ResolveStrvBuilderMethod "unref" o = StrvBuilderUnrefMethodInfo | |
| ResolveStrvBuilderMethod "unrefToStrv" o = StrvBuilderUnrefToStrvMethodInfo | |
| ResolveStrvBuilderMethod l o = MethodResolutionFailed l o :: Type |
add
data StrvBuilderAddMethodInfo Source #
Instances
| (signature ~ (Text -> m ()), MonadIO m) => OverloadedMethod StrvBuilderAddMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderAddMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> Text |
|
| -> m () |
Add a string to the end of the array.
Since 2.68
addv
data StrvBuilderAddvMethodInfo Source #
Instances
| (signature ~ ([Text] -> m ()), MonadIO m) => OverloadedMethod StrvBuilderAddvMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderAddvMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> [Text] |
|
| -> m () |
Appends all the strings in the given vector to the builder.
Since 2.70
end
data StrvBuilderEndMethodInfo Source #
Instances
| (signature ~ m [Text], MonadIO m) => OverloadedMethod StrvBuilderEndMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderEndMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> m [Text] | Returns: the constructed string array. Since 2.68 |
Ends the builder process and returns the constructed NULL-terminated string
array. The returned value should be freed with strfreev when no longer
needed.
new
Arguments
| :: (HasCallStack, MonadIO m) | |
| => m StrvBuilder | Returns: the new |
Creates a new StrvBuilder with a reference count of 1.
Use strvBuilderUnref on the returned value when no longer needed.
Since: 2.68
ref
data StrvBuilderRefMethodInfo Source #
Instances
| (signature ~ m StrvBuilder, MonadIO m) => OverloadedMethod StrvBuilderRefMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderRefMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> m StrvBuilder | Returns: The passed in |
Atomically increments the reference count of builder by one.
This function is thread-safe and may be called from any thread.
Since: 2.68
take
data StrvBuilderTakeMethodInfo Source #
Instances
| (signature ~ (Text -> m ()), MonadIO m) => OverloadedMethod StrvBuilderTakeMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderTakeMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> Text |
|
| -> m () |
Add a string to the end of the array. After value belongs to the
StrvBuilder and may no longer be modified by the caller.
Since 2.80
unref
data StrvBuilderUnrefMethodInfo Source #
Instances
| (signature ~ m (), MonadIO m) => OverloadedMethod StrvBuilderUnrefMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderUnrefMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> m () |
Decreases the reference count on builder.
In the event that there are no more references, releases all memory
associated with the StrvBuilder.
Since: 2.68
unrefToStrv
data StrvBuilderUnrefToStrvMethodInfo Source #
Instances
| (signature ~ m [Text], MonadIO m) => OverloadedMethod StrvBuilderUnrefToStrvMethodInfo StrvBuilder signature Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods overloadedMethod :: StrvBuilder -> signature # | |
| OverloadedMethodInfo StrvBuilderUnrefToStrvMethodInfo StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder Methods | |
strvBuilderUnrefToStrv Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => StrvBuilder |
|
| -> m [Text] | Returns: the constructed string array |
Decreases the reference count on the string vector builder, and returns
its contents as a NULL-terminated string array.
This function is especially useful for cases where it's not possible
to use g_autoptr().
c code
GStrvBuilder *builder = g_strv_builder_new ();
g_strv_builder_add (builder, "hello");
g_strv_builder_add (builder, "world");
GStrv array = g_strv_builder_unref_to_strv (builder);
g_assert_true (g_strv_equal (array, (const char *[]) { "hello", "world", NULL }));
g_strfreev (array);Since: 2.82