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 |
StrvBuilder
is a method of easily building dynamically sized
NULL-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);
Since: 2.68
Synopsis
- newtype StrvBuilder = StrvBuilder (ManagedPtr StrvBuilder)
- strvBuilderAdd :: (HasCallStack, MonadIO m) => StrvBuilder -> Text -> m ()
- strvBuilderAddv :: (HasCallStack, MonadIO m) => StrvBuilder -> [Text] -> m ()
- strvBuilderEnd :: (HasCallStack, MonadIO m) => StrvBuilder -> m [Text]
Exported types
newtype StrvBuilder Source #
Memory-managed wrapper type.
StrvBuilder (ManagedPtr StrvBuilder) |
Instances
Eq StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder (==) :: StrvBuilder -> StrvBuilder -> Bool # (/=) :: StrvBuilder -> StrvBuilder -> Bool # | |
BoxedPtr StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder boxedPtrCopy :: StrvBuilder -> IO StrvBuilder boxedPtrFree :: StrvBuilder -> IO () | |
ManagedPtrNewtype StrvBuilder Source # | |
Defined in GI.GLib.Structs.StrvBuilder toManagedPtr :: StrvBuilder -> ManagedPtr StrvBuilder |
Methods
Click to display all available methods, including inherited ones
add
:: (HasCallStack, MonadIO m) | |
=> StrvBuilder |
|
-> Text |
|
-> m () |
Add a string to the end of the array.
Since 2.68
addv
:: (HasCallStack, MonadIO m) | |
=> StrvBuilder |
|
-> [Text] |
|
-> m () |
Appends all the strings in the given vector to the builder.
Since 2.70
end
:: (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.