| Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | None |
| Language | Haskell2010 |
GI.GLib.Structs.String
Contents
Description
The GString struct contains the public fields of a GString.
Synopsis
- newtype String = String (ManagedPtr String)
- newZeroString :: MonadIO m => m String
- noString :: Maybe String
- stringAppend :: (HasCallStack, MonadIO m) => String -> Text -> m String
- stringAppendC :: (HasCallStack, MonadIO m) => String -> Int8 -> m String
- stringAppendLen :: (HasCallStack, MonadIO m) => String -> Text -> Int64 -> m String
- stringAppendUnichar :: (HasCallStack, MonadIO m) => String -> Char -> m String
- stringAppendUriEscaped :: (HasCallStack, MonadIO m) => String -> Text -> Text -> Bool -> m String
- stringAsciiDown :: (HasCallStack, MonadIO m) => String -> m String
- stringAsciiUp :: (HasCallStack, MonadIO m) => String -> m String
- stringAssign :: (HasCallStack, MonadIO m) => String -> Text -> m String
- stringDown :: (HasCallStack, MonadIO m) => String -> m String
- stringEqual :: (HasCallStack, MonadIO m) => String -> String -> m Bool
- stringErase :: (HasCallStack, MonadIO m) => String -> Int64 -> Int64 -> m String
- stringFree :: (HasCallStack, MonadIO m) => String -> Bool -> m (Maybe Text)
- stringFreeToBytes :: (HasCallStack, MonadIO m) => String -> m Bytes
- stringHash :: (HasCallStack, MonadIO m) => String -> m Word32
- stringInsert :: (HasCallStack, MonadIO m) => String -> Int64 -> Text -> m String
- stringInsertC :: (HasCallStack, MonadIO m) => String -> Int64 -> Int8 -> m String
- stringInsertLen :: (HasCallStack, MonadIO m) => String -> Int64 -> Text -> Int64 -> m String
- stringInsertUnichar :: (HasCallStack, MonadIO m) => String -> Int64 -> Char -> m String
- stringOverwrite :: (HasCallStack, MonadIO m) => String -> Word64 -> Text -> m String
- stringOverwriteLen :: (HasCallStack, MonadIO m) => String -> Word64 -> Text -> Int64 -> m String
- stringPrepend :: (HasCallStack, MonadIO m) => String -> Text -> m String
- stringPrependC :: (HasCallStack, MonadIO m) => String -> Int8 -> m String
- stringPrependLen :: (HasCallStack, MonadIO m) => String -> Text -> Int64 -> m String
- stringPrependUnichar :: (HasCallStack, MonadIO m) => String -> Char -> m String
- stringSetSize :: (HasCallStack, MonadIO m) => String -> Word64 -> m String
- stringTruncate :: (HasCallStack, MonadIO m) => String -> Word64 -> m String
- stringUp :: (HasCallStack, MonadIO m) => String -> m String
- getStringAllocatedLen :: MonadIO m => String -> m Word64
- setStringAllocatedLen :: MonadIO m => String -> Word64 -> m ()
- getStringLen :: MonadIO m => String -> m Word64
- setStringLen :: MonadIO m => String -> Word64 -> m ()
- clearStringStr :: MonadIO m => String -> m ()
- getStringStr :: MonadIO m => String -> m (Maybe Text)
- setStringStr :: MonadIO m => String -> CString -> m ()
Exported types
Memory-managed wrapper type.
Constructors
| String (ManagedPtr String) |
Methods
Overloaded methods
append
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Text |
|
| -> m String | Returns: |
Adds a string onto the end of a String, expanding
it if necessary.
appendC
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Int8 |
|
| -> m String | Returns: |
Adds a byte onto the end of a String, expanding
it if necessary.
appendLen
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Text |
|
| -> Int64 |
|
| -> m String | Returns: |
Appends len bytes of val to string.
If len is positive, val may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val has at least len addressable bytes.
If len is negative, val must be nul-terminated and len
is considered to request the entire string length. This
makes stringAppendLen equivalent to stringAppend.
appendUnichar
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Char |
|
| -> m String | Returns: |
Converts a Unicode character into UTF-8, and appends it to the string.
appendUriEscaped
stringAppendUriEscaped Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Text |
|
| -> Text |
|
| -> Bool |
|
| -> m String | Returns: |
Appends unescaped to string, escaped any characters that
are reserved in URIs using URI-style escape sequences.
Since: 2.16
asciiDown
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> m String | Returns: passed-in |
Converts all uppercase ASCII letters to lowercase ASCII letters.
asciiUp
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> m String | Returns: passed-in |
Converts all lowercase ASCII letters to uppercase ASCII letters.
assign
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Text |
|
| -> m String | Returns: |
Copies the bytes from a string into a String,
destroying any previous contents. It is rather like
the standard strcpy() function, except that you do not
have to worry about having enough space to copy the string.
down
Deprecated: (Since version 2.2)This function uses the locale-specific tolower() function, which is almost never the right thing. Use stringAsciiDown or utf8Strdown instead.
Converts a String to lowercase.
equal
erase
free
freeToBytes
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> m Bytes | Returns: A newly allocated |
Transfers ownership of the contents of string to a newly allocated
Bytes. The String structure itself is deallocated, and it is
therefore invalid to use string after invoking this function.
Note that while String ensures that its buffer always has a
trailing nul character (not reflected in its "len"), the returned
Bytes does not include this extra nul; i.e. it has length exactly
equal to the "len" member.
Since: 2.34
hash
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> m Word32 | Returns: hash code for |
Creates a hash code for str; for use with HashTable.
insert
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Int64 |
|
| -> Text |
|
| -> m String | Returns: |
Inserts a copy of a string into a String,
expanding it if necessary.
insertC
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Int64 |
|
| -> Int8 |
|
| -> m String | Returns: |
Inserts a byte into a String, expanding it if necessary.
insertLen
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Int64 |
|
| -> Text |
|
| -> Int64 |
|
| -> m String | Returns: |
Inserts len bytes of val into string at pos.
If len is positive, val may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val has at least len addressable bytes.
If len is negative, val must be nul-terminated and len
is considered to request the entire string length.
If pos is -1, bytes are inserted at the end of the string.
insertUnichar
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Int64 |
|
| -> Char |
|
| -> m String | Returns: |
Converts a Unicode character into UTF-8, and insert it into the string at the given position.
overwrite
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Word64 |
|
| -> Text |
|
| -> m String | Returns: |
Overwrites part of a string, lengthening it if necessary.
Since: 2.14
overwriteLen
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Word64 |
|
| -> Text |
|
| -> Int64 |
|
| -> m String | Returns: |
Overwrites part of a string, lengthening it if necessary. This function will work with embedded nuls.
Since: 2.14
prepend
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Text |
|
| -> m String | Returns: |
Adds a string on to the start of a String,
expanding it if necessary.
prependC
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Int8 |
|
| -> m String | Returns: |
Adds a byte onto the start of a String,
expanding it if necessary.
prependLen
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Text |
|
| -> Int64 |
|
| -> m String | Returns: |
Prepends len bytes of val to string.
If len is positive, val may contain embedded nuls and need
not be nul-terminated. It is the caller's responsibility to
ensure that val has at least len addressable bytes.
If len is negative, val must be nul-terminated and len
is considered to request the entire string length. This
makes stringPrependLen equivalent to stringPrepend.
prependUnichar
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Char |
|
| -> m String | Returns: |
Converts a Unicode character into UTF-8, and prepends it to the string.
setSize
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Word64 |
|
| -> m String | Returns: |
Sets the length of a String. If the length is less than
the current length, the string will be truncated. If the
length is greater than the current length, the contents
of the newly added area are undefined. (However, as
always, string->str[string->len] will be a nul byte.)
truncate
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> Word64 |
|
| -> m String | Returns: |
Cuts off the end of the GString, leaving the first len bytes.
up
Arguments
| :: (HasCallStack, MonadIO m) | |
| => String |
|
| -> m String | Returns: |
Deprecated: (Since version 2.2)This function uses the locale-specific toupper() function, which is almost never the right thing. Use stringAsciiUp or utf8Strup instead.
Converts a String to uppercase.
Properties
allocatedLen
the number of bytes that can be stored in the
string before it needs to be reallocated. May be larger than len.
getStringAllocatedLen :: MonadIO m => String -> m Word64 Source #
Get the value of the “allocated_len” field.
When overloading is enabled, this is equivalent to
get string #allocatedLen
setStringAllocatedLen :: MonadIO m => String -> Word64 -> m () Source #
Set the value of the “allocated_len” field.
When overloading is enabled, this is equivalent to
setstring [ #allocatedLen:=value ]
len
contains the length of the string, not including the terminating nul byte.
getStringLen :: MonadIO m => String -> m Word64 Source #
Get the value of the “len” field.
When overloading is enabled, this is equivalent to
get string #len
setStringLen :: MonadIO m => String -> Word64 -> m () Source #
Set the value of the “len” field.
When overloading is enabled, this is equivalent to
setstring [ #len:=value ]
str
points to the character data. It may move as text is added.
The str field is null-terminated and so
can be used as an ordinary C string.
clearStringStr :: MonadIO m => String -> m () Source #
Set the value of the “str” field to Nothing.
When overloading is enabled, this is equivalent to
clear #str
getStringStr :: MonadIO m => String -> m (Maybe Text) Source #
Get the value of the “str” field.
When overloading is enabled, this is equivalent to
get string #str
setStringStr :: MonadIO m => String -> CString -> m () Source #
Set the value of the “str” field.
When overloading is enabled, this is equivalent to
setstring [ #str:=value ]