gi-glib-2.0.24: GLib bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellNone
LanguageHaskell2010

GI.GLib.Structs.StringChunk

Description

An opaque data structure representing String Chunks. It should only be accessed by using the following functions.

Synopsis

Exported types

newtype StringChunk Source #

Memory-managed wrapper type.

Methods

Overloaded methods

clear

stringChunkClear Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> StringChunk

chunk: a 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

stringChunkFree Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> StringChunk

chunk: a 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

stringChunkInsert Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> StringChunk

chunk: a StringChunk

-> Text

string: the string to add

-> m Text

Returns: a pointer to the copy of string within the StringChunk

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 #

Arguments

:: (HasCallStack, MonadIO m) 
=> StringChunk

chunk: a StringChunk

-> Text

string: the string to add

-> m Text

Returns: a pointer to the new or existing copy of string within the StringChunk

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

stringChunkInsertLen Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> StringChunk

chunk: a StringChunk

-> Text

string: bytes to insert

-> Int64

len: number of bytes of string to insert, or -1 to insert a nul-terminated string

-> m Text

Returns: a pointer to the copy of string within the StringChunk

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