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 |
An opaque data structure representing String Chunks. It should only be accessed by using the following functions.
Synopsis
- newtype StringChunk = StringChunk (ManagedPtr StringChunk)
- stringChunkClear :: (HasCallStack, MonadIO m) => StringChunk -> m ()
- stringChunkFree :: (HasCallStack, MonadIO m) => StringChunk -> m ()
- stringChunkInsert :: (HasCallStack, MonadIO m) => StringChunk -> Text -> m Text
- stringChunkInsertConst :: (HasCallStack, MonadIO m) => StringChunk -> Text -> m Text
- stringChunkInsertLen :: (HasCallStack, MonadIO m) => StringChunk -> Text -> Int64 -> m Text
Exported types
newtype StringChunk Source #
Memory-managed wrapper type.
Instances
Eq StringChunk Source # | |
Defined in GI.GLib.Structs.StringChunk (==) :: StringChunk -> StringChunk -> Bool # (/=) :: StringChunk -> StringChunk -> Bool # | |
BoxedPtr StringChunk Source # | |
Defined in GI.GLib.Structs.StringChunk boxedPtrCopy :: StringChunk -> IO StringChunk # boxedPtrFree :: StringChunk -> IO () # | |
ManagedPtrNewtype StringChunk Source # | |
Defined in GI.GLib.Structs.StringChunk |
Methods
Click to display all available methods, including inherited ones
clear
:: (HasCallStack, MonadIO m) | |
=> StringChunk |
|
-> m () |
Frees all strings contained within the StringChunk
.
After calling stringChunkClear
it is not safe to
access any of the strings which were contained within it.
Since: 2.14
free
:: (HasCallStack, MonadIO m) | |
=> StringChunk |
|
-> m () |
Frees all memory allocated by the StringChunk
.
After calling stringChunkFree
it is not safe to
access any of the strings which were contained within it.
insert
:: (HasCallStack, MonadIO m) | |
=> StringChunk |
|
-> Text |
|
-> m Text | Returns: a pointer to the copy of |
Adds a copy of string
to the StringChunk
.
It returns a pointer to the new copy of the string
in the StringChunk
. The characters in the string
can be changed, if necessary, though you should not
change anything after the end of the string.
Unlike stringChunkInsertConst
, this function
does not check for duplicates. Also strings added
with stringChunkInsert
will not be searched
by stringChunkInsertConst
when looking for
duplicates.
insertConst
stringChunkInsertConst Source #
:: (HasCallStack, MonadIO m) | |
=> StringChunk |
|
-> Text |
|
-> m Text | Returns: a pointer to the new or existing copy of |
Adds a copy of string
to the StringChunk
, unless the same
string has already been added to the StringChunk
with
stringChunkInsertConst
.
This function is useful if you need to copy a large number of strings but do not want to waste space storing duplicates. But you must remember that there may be several pointers to the same string, and so any changes made to the strings should be done very carefully.
Note that stringChunkInsertConst
will not return a
pointer to a string added with stringChunkInsert
, even
if they do match.
insertLen
:: (HasCallStack, MonadIO m) | |
=> StringChunk |
|
-> Text |
|
-> Int64 |
|
-> m Text | Returns: a pointer to the copy of |
Adds a copy of the first len
bytes of string
to the StringChunk
.
The copy is nul-terminated.
Since this function does not stop at nul bytes, it is the caller's
responsibility to ensure that string
has at least len
addressable
bytes.
The characters in the returned string can be changed, if necessary, though you should not change anything after the end of the string.
Since: 2.4