{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)

The GString struct contains the public fields of a GString.
-}

#define ENABLE_OVERLOADING \
       (!defined(__HADDOCK_VERSION__))

module GI.GLib.Structs.String
    ( 

-- * Exported types
    String(..)                              ,
    newZeroString                           ,
    noString                                ,


 -- * Methods
-- ** append #method:append#

#if ENABLE_OVERLOADING
    StringAppendMethodInfo                  ,
#endif
    stringAppend                            ,


-- ** appendC #method:appendC#

#if ENABLE_OVERLOADING
    StringAppendCMethodInfo                 ,
#endif
    stringAppendC                           ,


-- ** appendLen #method:appendLen#

#if ENABLE_OVERLOADING
    StringAppendLenMethodInfo               ,
#endif
    stringAppendLen                         ,


-- ** appendUnichar #method:appendUnichar#

#if ENABLE_OVERLOADING
    StringAppendUnicharMethodInfo           ,
#endif
    stringAppendUnichar                     ,


-- ** appendUriEscaped #method:appendUriEscaped#

#if ENABLE_OVERLOADING
    StringAppendUriEscapedMethodInfo        ,
#endif
    stringAppendUriEscaped                  ,


-- ** asciiDown #method:asciiDown#

#if ENABLE_OVERLOADING
    StringAsciiDownMethodInfo               ,
#endif
    stringAsciiDown                         ,


-- ** asciiUp #method:asciiUp#

#if ENABLE_OVERLOADING
    StringAsciiUpMethodInfo                 ,
#endif
    stringAsciiUp                           ,


-- ** assign #method:assign#

#if ENABLE_OVERLOADING
    StringAssignMethodInfo                  ,
#endif
    stringAssign                            ,


-- ** down #method:down#

#if ENABLE_OVERLOADING
    StringDownMethodInfo                    ,
#endif
    stringDown                              ,


-- ** equal #method:equal#

#if ENABLE_OVERLOADING
    StringEqualMethodInfo                   ,
#endif
    stringEqual                             ,


-- ** erase #method:erase#

#if ENABLE_OVERLOADING
    StringEraseMethodInfo                   ,
#endif
    stringErase                             ,


-- ** free #method:free#

#if ENABLE_OVERLOADING
    StringFreeMethodInfo                    ,
#endif
    stringFree                              ,


-- ** freeToBytes #method:freeToBytes#

#if ENABLE_OVERLOADING
    StringFreeToBytesMethodInfo             ,
#endif
    stringFreeToBytes                       ,


-- ** hash #method:hash#

#if ENABLE_OVERLOADING
    StringHashMethodInfo                    ,
#endif
    stringHash                              ,


-- ** insert #method:insert#

#if ENABLE_OVERLOADING
    StringInsertMethodInfo                  ,
#endif
    stringInsert                            ,


-- ** insertC #method:insertC#

#if ENABLE_OVERLOADING
    StringInsertCMethodInfo                 ,
#endif
    stringInsertC                           ,


-- ** insertLen #method:insertLen#

#if ENABLE_OVERLOADING
    StringInsertLenMethodInfo               ,
#endif
    stringInsertLen                         ,


-- ** insertUnichar #method:insertUnichar#

#if ENABLE_OVERLOADING
    StringInsertUnicharMethodInfo           ,
#endif
    stringInsertUnichar                     ,


-- ** overwrite #method:overwrite#

#if ENABLE_OVERLOADING
    StringOverwriteMethodInfo               ,
#endif
    stringOverwrite                         ,


-- ** overwriteLen #method:overwriteLen#

#if ENABLE_OVERLOADING
    StringOverwriteLenMethodInfo            ,
#endif
    stringOverwriteLen                      ,


-- ** prepend #method:prepend#

#if ENABLE_OVERLOADING
    StringPrependMethodInfo                 ,
#endif
    stringPrepend                           ,


-- ** prependC #method:prependC#

#if ENABLE_OVERLOADING
    StringPrependCMethodInfo                ,
#endif
    stringPrependC                          ,


-- ** prependLen #method:prependLen#

#if ENABLE_OVERLOADING
    StringPrependLenMethodInfo              ,
#endif
    stringPrependLen                        ,


-- ** prependUnichar #method:prependUnichar#

#if ENABLE_OVERLOADING
    StringPrependUnicharMethodInfo          ,
#endif
    stringPrependUnichar                    ,


-- ** setSize #method:setSize#

#if ENABLE_OVERLOADING
    StringSetSizeMethodInfo                 ,
#endif
    stringSetSize                           ,


-- ** truncate #method:truncate#

#if ENABLE_OVERLOADING
    StringTruncateMethodInfo                ,
#endif
    stringTruncate                          ,


-- ** up #method:up#

#if ENABLE_OVERLOADING
    StringUpMethodInfo                      ,
#endif
    stringUp                                ,




 -- * Properties
-- ** allocatedLen #attr:allocatedLen#
{- | the number of bytes that can be stored in the
  string before it needs to be reallocated. May be larger than /@len@/.
-}
    getStringAllocatedLen                   ,
    setStringAllocatedLen                   ,
#if ENABLE_OVERLOADING
    string_allocatedLen                     ,
#endif


-- ** len #attr:len#
{- | contains the length of the string, not including the
  terminating nul byte.
-}
    getStringLen                            ,
    setStringLen                            ,
#if ENABLE_OVERLOADING
    string_len                              ,
#endif


-- ** str #attr: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                          ,
    getStringStr                            ,
    setStringStr                            ,
#if ENABLE_OVERLOADING
    string_str                              ,
#endif




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import {-# SOURCE #-} qualified GI.GLib.Structs.Bytes as GLib.Bytes

-- | Memory-managed wrapper type.
newtype String = String (ManagedPtr String)
foreign import ccall "g_gstring_get_type" c_g_gstring_get_type :: 
    IO GType

instance BoxedObject String where
    boxedType :: String -> IO GType
boxedType _ = IO GType
c_g_gstring_get_type

-- | Construct a `String` struct initialized to zero.
newZeroString :: MonadIO m => m String
newZeroString :: m String
newZeroString = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ Int -> IO (Ptr String)
forall a. BoxedObject a => Int -> IO (Ptr a)
callocBoxedBytes 24 IO (Ptr String) -> (Ptr String -> IO String) -> IO String
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr String -> String
String

instance tag ~ 'AttrSet => Constructible String tag where
    new :: (ManagedPtr String -> String) -> [AttrOp String tag] -> m String
new _ attrs :: [AttrOp String tag]
attrs = do
        String
o <- m String
forall (m :: * -> *). MonadIO m => m String
newZeroString
        String -> [AttrOp String 'AttrSet] -> m ()
forall o (m :: * -> *).
MonadIO m =>
o -> [AttrOp o 'AttrSet] -> m ()
GI.Attributes.set String
o [AttrOp String tag]
[AttrOp String 'AttrSet]
attrs
        String -> m String
forall (m :: * -> *) a. Monad m => a -> m a
return String
o


-- | A convenience alias for `Nothing` :: `Maybe` `String`.
noString :: Maybe String
noString :: Maybe String
noString = Maybe String
forall a. Maybe a
Nothing

{- |
Get the value of the “@str@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' string #str
@
-}
getStringStr :: MonadIO m => String -> m (Maybe T.Text)
getStringStr :: String -> m (Maybe Text)
getStringStr s :: String
s = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO (Maybe Text)) -> IO (Maybe Text)
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO (Maybe Text)) -> IO (Maybe Text))
-> (Ptr String -> IO (Maybe Text)) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    CString
val <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek (Ptr String
ptr Ptr String -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) :: IO CString
    Maybe Text
result <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
SP.convertIfNonNull CString
val ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \val' :: CString
val' -> do
        Text
val'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
val'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
val''
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
result

{- |
Set the value of the “@str@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' string [ #str 'Data.GI.Base.Attributes.:=' value ]
@
-}
setStringStr :: MonadIO m => String -> CString -> m ()
setStringStr :: String -> CString -> m ()
setStringStr s :: String
s val :: CString
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO ()) -> IO ()) -> (Ptr String -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr String
ptr Ptr String -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
val :: CString)

{- |
Set the value of the “@str@” field to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #str
@
-}
clearStringStr :: MonadIO m => String -> m ()
clearStringStr :: String -> m ()
clearStringStr s :: String
s = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO ()) -> IO ()) -> (Ptr String -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    Ptr CString -> CString -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr String
ptr Ptr String -> Int -> Ptr CString
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 0) (CString
forall a. Ptr a
FP.nullPtr :: CString)

#if ENABLE_OVERLOADING
data StringStrFieldInfo
instance AttrInfo StringStrFieldInfo where
    type AttrAllowedOps StringStrFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint StringStrFieldInfo = (~) CString
    type AttrBaseTypeConstraint StringStrFieldInfo = (~) String
    type AttrGetType StringStrFieldInfo = Maybe T.Text
    type AttrLabel StringStrFieldInfo = "str"
    type AttrOrigin StringStrFieldInfo = String
    attrGet _ = getStringStr
    attrSet _ = setStringStr
    attrConstruct = undefined
    attrClear _ = clearStringStr

string_str :: AttrLabelProxy "str"
string_str = AttrLabelProxy

#endif


{- |
Get the value of the “@len@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' string #len
@
-}
getStringLen :: MonadIO m => String -> m Word64
getStringLen :: String -> m Word64
getStringLen s :: String
s = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO Word64) -> IO Word64
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO Word64) -> IO Word64)
-> (Ptr String -> IO Word64) -> IO Word64
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    Word64
val <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek (Ptr String
ptr Ptr String -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) :: IO Word64
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
val

{- |
Set the value of the “@len@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' string [ #len 'Data.GI.Base.Attributes.:=' value ]
@
-}
setStringLen :: MonadIO m => String -> Word64 -> m ()
setStringLen :: String -> Word64 -> m ()
setStringLen s :: String
s val :: Word64
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO ()) -> IO ()) -> (Ptr String -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr String
ptr Ptr String -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 8) (Word64
val :: Word64)

#if ENABLE_OVERLOADING
data StringLenFieldInfo
instance AttrInfo StringLenFieldInfo where
    type AttrAllowedOps StringLenFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint StringLenFieldInfo = (~) Word64
    type AttrBaseTypeConstraint StringLenFieldInfo = (~) String
    type AttrGetType StringLenFieldInfo = Word64
    type AttrLabel StringLenFieldInfo = "len"
    type AttrOrigin StringLenFieldInfo = String
    attrGet _ = getStringLen
    attrSet _ = setStringLen
    attrConstruct = undefined
    attrClear _ = undefined

string_len :: AttrLabelProxy "len"
string_len = AttrLabelProxy

#endif


{- |
Get the value of the “@allocated_len@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' string #allocatedLen
@
-}
getStringAllocatedLen :: MonadIO m => String -> m Word64
getStringAllocatedLen :: String -> m Word64
getStringAllocatedLen s :: String
s = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO Word64) -> IO Word64
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO Word64) -> IO Word64)
-> (Ptr String -> IO Word64) -> IO Word64
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    Word64
val <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek (Ptr String
ptr Ptr String -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) :: IO Word64
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
val

{- |
Set the value of the “@allocated_len@” field.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' string [ #allocatedLen 'Data.GI.Base.Attributes.:=' value ]
@
-}
setStringAllocatedLen :: MonadIO m => String -> Word64 -> m ()
setStringAllocatedLen :: String -> Word64 -> m ()
setStringAllocatedLen s :: String
s val :: Word64
val = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ String -> (Ptr String -> IO ()) -> IO ()
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
withManagedPtr String
s ((Ptr String -> IO ()) -> IO ()) -> (Ptr String -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \ptr :: Ptr String
ptr -> do
    Ptr Word64 -> Word64 -> IO ()
forall a. Storable a => Ptr a -> a -> IO ()
poke (Ptr String
ptr Ptr String -> Int -> Ptr Word64
forall a b. Ptr a -> Int -> Ptr b
`plusPtr` 16) (Word64
val :: Word64)

#if ENABLE_OVERLOADING
data StringAllocatedLenFieldInfo
instance AttrInfo StringAllocatedLenFieldInfo where
    type AttrAllowedOps StringAllocatedLenFieldInfo = '[ 'AttrSet, 'AttrGet]
    type AttrSetTypeConstraint StringAllocatedLenFieldInfo = (~) Word64
    type AttrBaseTypeConstraint StringAllocatedLenFieldInfo = (~) String
    type AttrGetType StringAllocatedLenFieldInfo = Word64
    type AttrLabel StringAllocatedLenFieldInfo = "allocated_len"
    type AttrOrigin StringAllocatedLenFieldInfo = String
    attrGet _ = getStringAllocatedLen
    attrSet _ = setStringAllocatedLen
    attrConstruct = undefined
    attrClear _ = undefined

string_allocatedLen :: AttrLabelProxy "allocatedLen"
string_allocatedLen = AttrLabelProxy

#endif



#if ENABLE_OVERLOADING
instance O.HasAttributeList String
type instance O.AttributeList String = StringAttributeList
type StringAttributeList = ('[ '("str", StringStrFieldInfo), '("len", StringLenFieldInfo), '("allocatedLen", StringAllocatedLenFieldInfo)] :: [(Symbol, *)])
#endif

-- method String::append
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to append onto the end of @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_append" g_string_append :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- val : TBasicType TUTF8
    IO (Ptr String)

{- |
Adds a string onto the end of a 'GI.GLib.Structs.String.String', expanding
it if necessary.
-}
stringAppend ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> T.Text
    {- ^ /@val@/: the string to append onto the end of /@string@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringAppend :: String -> Text -> m String
stringAppend string :: String
string val :: Text
val = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> CString -> IO (Ptr String)
g_string_append Ptr String
string' CString
val'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAppend" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAppendMethodInfo
instance (signature ~ (T.Text -> m String), MonadIO m) => O.MethodInfo StringAppendMethodInfo String signature where
    overloadedMethod _ = stringAppend

#endif

-- method String::append_c
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the byte to append onto the end of @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_append_c" g_string_append_c :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int8 ->                                 -- c : TBasicType TInt8
    IO (Ptr String)

{- |
Adds a byte onto the end of a 'GI.GLib.Structs.String.String', expanding
it if necessary.
-}
stringAppendC ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int8
    {- ^ /@c@/: the byte to append onto the end of /@string@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringAppendC :: String -> Int8 -> m String
stringAppendC string :: String
string c :: Int8
c = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> Int8 -> IO (Ptr String)
g_string_append_c Ptr String
string' Int8
c
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAppendC" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAppendCMethodInfo
instance (signature ~ (Int8 -> m String), MonadIO m) => O.MethodInfo StringAppendCMethodInfo String signature where
    overloadedMethod _ = stringAppendC

#endif

-- method String::append_len
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bytes to append", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes of @val to use, or -1 for all of @val", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_append_len" g_string_append_len :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- val : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO (Ptr String)

{- |
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 'GI.GLib.Structs.String.stringAppendLen' equivalent to 'GI.GLib.Structs.String.stringAppend'.
-}
stringAppendLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> T.Text
    {- ^ /@val@/: bytes to append -}
    -> Int64
    {- ^ /@len@/: number of bytes of /@val@/ to use, or -1 for all of /@val@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringAppendLen :: String -> Text -> Int64 -> m String
stringAppendLen string :: String
string val :: Text
val len :: Int64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> CString -> Int64 -> IO (Ptr String)
g_string_append_len Ptr String
string' CString
val' Int64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAppendLen" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAppendLenMethodInfo
instance (signature ~ (T.Text -> Int64 -> m String), MonadIO m) => O.MethodInfo StringAppendLenMethodInfo String signature where
    overloadedMethod _ = stringAppendLen

#endif

-- method String::append_unichar
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "wc", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_append_unichar" g_string_append_unichar :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CInt ->                                 -- wc : TBasicType TUniChar
    IO (Ptr String)

{- |
Converts a Unicode character into UTF-8, and appends it
to the string.
-}
stringAppendUnichar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Char
    {- ^ /@wc@/: a Unicode character -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringAppendUnichar :: String -> Char -> m String
stringAppendUnichar string :: String
string wc :: Char
wc = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    let wc' :: CInt
wc' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
wc
    Ptr String
result <- Ptr String -> CInt -> IO (Ptr String)
g_string_append_unichar Ptr String
string' CInt
wc'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAppendUnichar" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAppendUnicharMethodInfo
instance (signature ~ (Char -> m String), MonadIO m) => O.MethodInfo StringAppendUnicharMethodInfo String signature where
    overloadedMethod _ = stringAppendUnichar

#endif

-- method String::append_uri_escaped
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "unescaped", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "reserved_chars_allowed", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string of reserved characters allowed\n    to be used, or %NULL", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "allow_utf8", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "set %TRUE if the escaped string may include UTF8 characters", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_append_uri_escaped" g_string_append_uri_escaped :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- unescaped : TBasicType TUTF8
    CString ->                              -- reserved_chars_allowed : TBasicType TUTF8
    CInt ->                                 -- allow_utf8 : TBasicType TBoolean
    IO (Ptr String)

{- |
Appends /@unescaped@/ to /@string@/, escaped any characters that
are reserved in URIs using URI-style escape sequences.

/Since: 2.16/
-}
stringAppendUriEscaped ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> T.Text
    {- ^ /@unescaped@/: a string -}
    -> T.Text
    {- ^ /@reservedCharsAllowed@/: a string of reserved characters allowed
    to be used, or 'Nothing' -}
    -> Bool
    {- ^ /@allowUtf8@/: set 'True' if the escaped string may include UTF8 characters -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringAppendUriEscaped :: String -> Text -> Text -> Bool -> m String
stringAppendUriEscaped string :: String
string unescaped :: Text
unescaped reservedCharsAllowed :: Text
reservedCharsAllowed allowUtf8 :: Bool
allowUtf8 = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
unescaped' <- Text -> IO CString
textToCString Text
unescaped
    CString
reservedCharsAllowed' <- Text -> IO CString
textToCString Text
reservedCharsAllowed
    let allowUtf8' :: CInt
allowUtf8' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
allowUtf8
    Ptr String
result <- Ptr String -> CString -> CString -> CInt -> IO (Ptr String)
g_string_append_uri_escaped Ptr String
string' CString
unescaped' CString
reservedCharsAllowed' CInt
allowUtf8'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAppendUriEscaped" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
unescaped'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
reservedCharsAllowed'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAppendUriEscapedMethodInfo
instance (signature ~ (T.Text -> T.Text -> Bool -> m String), MonadIO m) => O.MethodInfo StringAppendUriEscapedMethodInfo String signature where
    overloadedMethod _ = stringAppendUriEscaped

#endif

-- method String::ascii_down
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_ascii_down" g_string_ascii_down :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    IO (Ptr String)

{- |
Converts all uppercase ASCII letters to lowercase ASCII letters.
-}
stringAsciiDown ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a GString -}
    -> m String
    {- ^ __Returns:__ passed-in /@string@/ pointer, with all the
    uppercase characters converted to lowercase in place,
    with semantics that exactly match 'GI.GLib.Functions.asciiTolower'. -}
stringAsciiDown :: String -> m String
stringAsciiDown string :: String
string = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> IO (Ptr String)
g_string_ascii_down Ptr String
string'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAsciiDown" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAsciiDownMethodInfo
instance (signature ~ (m String), MonadIO m) => O.MethodInfo StringAsciiDownMethodInfo String signature where
    overloadedMethod _ = stringAsciiDown

#endif

-- method String::ascii_up
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_ascii_up" g_string_ascii_up :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    IO (Ptr String)

{- |
Converts all lowercase ASCII letters to uppercase ASCII letters.
-}
stringAsciiUp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a GString -}
    -> m String
    {- ^ __Returns:__ passed-in /@string@/ pointer, with all the
    lowercase characters converted to uppercase in place,
    with semantics that exactly match 'GI.GLib.Functions.asciiToupper'. -}
stringAsciiUp :: String -> m String
stringAsciiUp string :: String
string = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> IO (Ptr String)
g_string_ascii_up Ptr String
string'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAsciiUp" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAsciiUpMethodInfo
instance (signature ~ (m String), MonadIO m) => O.MethodInfo StringAsciiUpMethodInfo String signature where
    overloadedMethod _ = stringAsciiUp

#endif

-- method String::assign
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the destination #GString. Its current contents\n         are destroyed.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "rval", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to copy into @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_assign" g_string_assign :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- rval : TBasicType TUTF8
    IO (Ptr String)

{- |
Copies the bytes from a string into a 'GI.GLib.Structs.String.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.
-}
stringAssign ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: the destination 'GI.GLib.Structs.String.String'. Its current contents
         are destroyed. -}
    -> T.Text
    {- ^ /@rval@/: the string to copy into /@string@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringAssign :: String -> Text -> m String
stringAssign string :: String
string rval :: Text
rval = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
rval' <- Text -> IO CString
textToCString Text
rval
    Ptr String
result <- Ptr String -> CString -> IO (Ptr String)
g_string_assign Ptr String
string' CString
rval'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringAssign" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
rval'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringAssignMethodInfo
instance (signature ~ (T.Text -> m String), MonadIO m) => O.MethodInfo StringAssignMethodInfo String signature where
    overloadedMethod _ = stringAssign

#endif

-- method String::down
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_down" g_string_down :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    IO (Ptr String)

{-# DEPRECATED stringDown ["(Since version 2.2)","This function uses the locale-specific","    @/tolower()/@ function, which is almost never the right thing.","    Use 'GI.GLib.Structs.String.stringAsciiDown' or 'GI.GLib.Functions.utf8Strdown' instead."] #-}
{- |
Converts a 'GI.GLib.Structs.String.String' to lowercase.
-}
stringDown ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> m String
    {- ^ __Returns:__ the 'GI.GLib.Structs.String.String' -}
stringDown :: String -> m String
stringDown string :: String
string = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> IO (Ptr String)
g_string_down Ptr String
string'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringDown" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringDownMethodInfo
instance (signature ~ (m String), MonadIO m) => O.MethodInfo StringDownMethodInfo String signature where
    overloadedMethod _ = stringDown

#endif

-- method String::equal
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "v", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "v2", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "another #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "g_string_equal" g_string_equal :: 
    Ptr String ->                           -- v : TInterface (Name {namespace = "GLib", name = "String"})
    Ptr String ->                           -- v2 : TInterface (Name {namespace = "GLib", name = "String"})
    IO CInt

{- |
Compares two strings for equality, returning 'True' if they are equal.
For use with 'GI.GLib.Structs.HashTable.HashTable'.
-}
stringEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@v@/: a 'GI.GLib.Structs.String.String' -}
    -> String
    {- ^ /@v2@/: another 'GI.GLib.Structs.String.String' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if the strings are the same length and contain the
    same bytes -}
stringEqual :: String -> String -> m Bool
stringEqual v :: String
v v2 :: String
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
v' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
v
    Ptr String
v2' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
v2
    CInt
result <- Ptr String -> Ptr String -> IO CInt
g_string_equal Ptr String
v' Ptr String
v2'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= 0) CInt
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
v
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
v2
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'

#if ENABLE_OVERLOADING
data StringEqualMethodInfo
instance (signature ~ (String -> m Bool), MonadIO m) => O.MethodInfo StringEqualMethodInfo String signature where
    overloadedMethod _ = stringEqual

#endif

-- method String::erase
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position of the content to remove", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to remove, or -1 to remove all\n      following bytes", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_erase" g_string_erase :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int64 ->                                -- pos : TBasicType TInt64
    Int64 ->                                -- len : TBasicType TInt64
    IO (Ptr String)

{- |
Removes /@len@/ bytes from a 'GI.GLib.Structs.String.String', starting at position /@pos@/.
The rest of the 'GI.GLib.Structs.String.String' is shifted down to fill the gap.
-}
stringErase ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int64
    {- ^ /@pos@/: the position of the content to remove -}
    -> Int64
    {- ^ /@len@/: the number of bytes to remove, or -1 to remove all
      following bytes -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringErase :: String -> Int64 -> Int64 -> m String
stringErase string :: String
string pos :: Int64
pos len :: Int64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> Int64 -> Int64 -> IO (Ptr String)
g_string_erase Ptr String
string' Int64
pos Int64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringErase" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringEraseMethodInfo
instance (signature ~ (Int64 -> Int64 -> m String), MonadIO m) => O.MethodInfo StringEraseMethodInfo String signature where
    overloadedMethod _ = stringErase

#endif

-- method String::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "free_segment", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if %TRUE, the actual character data is freed as well", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "g_string_free" g_string_free :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CInt ->                                 -- free_segment : TBasicType TBoolean
    IO CString

{- |
Frees the memory allocated for the 'GI.GLib.Structs.String.String'.
If /@freeSegment@/ is 'True' it also frees the character data.  If
it\'s 'False', the caller gains ownership of the buffer and must
free it after use with 'GI.GLib.Functions.free'.
-}
stringFree ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Bool
    {- ^ /@freeSegment@/: if 'True', the actual character data is freed as well -}
    -> m (Maybe T.Text)
    {- ^ __Returns:__ the character data of /@string@/
         (i.e. 'Nothing' if /@freeSegment@/ is 'True') -}
stringFree :: String -> Bool -> m (Maybe Text)
stringFree string :: String
string freeSegment :: Bool
freeSegment = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed String
string
    let freeSegment' :: CInt
freeSegment' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Bool -> Int) -> Bool -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> Int
forall a. Enum a => a -> Int
fromEnum) Bool
freeSegment
    CString
result <- Ptr String -> CInt -> IO CString
g_string_free Ptr String
string' CInt
freeSegment'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult

#if ENABLE_OVERLOADING
data StringFreeMethodInfo
instance (signature ~ (Bool -> m (Maybe T.Text)), MonadIO m) => O.MethodInfo StringFreeMethodInfo String signature where
    overloadedMethod _ = stringFree

#endif

-- method String::free_to_bytes
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "Bytes"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_free_to_bytes" g_string_free_to_bytes :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    IO (Ptr GLib.Bytes.Bytes)

{- |
Transfers ownership of the contents of /@string@/ to a newly allocated
'GI.GLib.Structs.Bytes.Bytes'.  The 'GI.GLib.Structs.String.String' structure itself is deallocated, and it is
therefore invalid to use /@string@/ after invoking this function.

Note that while 'GI.GLib.Structs.String.String' ensures that its buffer always has a
trailing nul character (not reflected in its \"len\"), the returned
'GI.GLib.Structs.Bytes.Bytes' does not include this extra nul; i.e. it has length exactly
equal to the \"len\" member.

/Since: 2.34/
-}
stringFreeToBytes ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> m GLib.Bytes.Bytes
    {- ^ __Returns:__ A newly allocated 'GI.GLib.Structs.Bytes.Bytes' containing contents of /@string@/; /@string@/ itself is freed -}
stringFreeToBytes :: String -> m Bytes
stringFreeToBytes string :: String
string = IO Bytes -> m Bytes
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bytes -> m Bytes) -> IO Bytes -> m Bytes
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, BoxedObject a) => a -> IO (Ptr a)
B.ManagedPtr.disownBoxed String
string
    Ptr Bytes
result <- Ptr String -> IO (Ptr Bytes)
g_string_free_to_bytes Ptr String
string'
    Text -> Ptr Bytes -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringFreeToBytes" Ptr Bytes
result
    Bytes
result' <- ((ManagedPtr Bytes -> Bytes) -> Ptr Bytes -> IO Bytes
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Bytes -> Bytes
GLib.Bytes.Bytes) Ptr Bytes
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    Bytes -> IO Bytes
forall (m :: * -> *) a. Monad m => a -> m a
return Bytes
result'

#if ENABLE_OVERLOADING
data StringFreeToBytesMethodInfo
instance (signature ~ (m GLib.Bytes.Bytes), MonadIO m) => O.MethodInfo StringFreeToBytesMethodInfo String signature where
    overloadedMethod _ = stringFreeToBytes

#endif

-- method String::hash
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "str", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a string to hash", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "g_string_hash" g_string_hash :: 
    Ptr String ->                           -- str : TInterface (Name {namespace = "GLib", name = "String"})
    IO Word32

{- |
Creates a hash code for /@str@/; for use with 'GI.GLib.Structs.HashTable.HashTable'.
-}
stringHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@str@/: a string to hash -}
    -> m Word32
    {- ^ __Returns:__ hash code for /@str@/ -}
stringHash :: String -> m Word32
stringHash str :: String
str = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
str' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
str
    Word32
result <- Ptr String -> IO Word32
g_string_hash Ptr String
str'
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
str
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result

#if ENABLE_OVERLOADING
data StringHashMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo StringHashMethodInfo String signature where
    overloadedMethod _ = stringHash

#endif

-- method String::insert
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position to insert the copy of the string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to insert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_insert" g_string_insert :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int64 ->                                -- pos : TBasicType TInt64
    CString ->                              -- val : TBasicType TUTF8
    IO (Ptr String)

{- |
Inserts a copy of a string into a 'GI.GLib.Structs.String.String',
expanding it if necessary.
-}
stringInsert ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int64
    {- ^ /@pos@/: the position to insert the copy of the string -}
    -> T.Text
    {- ^ /@val@/: the string to insert -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringInsert :: String -> Int64 -> Text -> m String
stringInsert string :: String
string pos :: Int64
pos val :: Text
val = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> Int64 -> CString -> IO (Ptr String)
g_string_insert Ptr String
string' Int64
pos CString
val'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringInsert" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringInsertMethodInfo
instance (signature ~ (Int64 -> T.Text -> m String), MonadIO m) => O.MethodInfo StringInsertMethodInfo String signature where
    overloadedMethod _ = stringInsert

#endif

-- method String::insert_c
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position to insert the byte", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the byte to insert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_insert_c" g_string_insert_c :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int64 ->                                -- pos : TBasicType TInt64
    Int8 ->                                 -- c : TBasicType TInt8
    IO (Ptr String)

{- |
Inserts a byte into a 'GI.GLib.Structs.String.String', expanding it if necessary.
-}
stringInsertC ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int64
    {- ^ /@pos@/: the position to insert the byte -}
    -> Int8
    {- ^ /@c@/: the byte to insert -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringInsertC :: String -> Int64 -> Int8 -> m String
stringInsertC string :: String
string pos :: Int64
pos c :: Int8
c = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> Int64 -> Int8 -> IO (Ptr String)
g_string_insert_c Ptr String
string' Int64
pos Int8
c
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringInsertC" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringInsertCMethodInfo
instance (signature ~ (Int64 -> Int8 -> m String), MonadIO m) => O.MethodInfo StringInsertCMethodInfo String signature where
    overloadedMethod _ = stringInsertC

#endif

-- method String::insert_len
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "position in @string where insertion should\n      happen, or -1 for at the end", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bytes to insert", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes of @val to insert, or -1 for all of @val", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_insert_len" g_string_insert_len :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int64 ->                                -- pos : TBasicType TInt64
    CString ->                              -- val : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO (Ptr String)

{- |
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.
-}
stringInsertLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int64
    {- ^ /@pos@/: position in /@string@/ where insertion should
      happen, or -1 for at the end -}
    -> T.Text
    {- ^ /@val@/: bytes to insert -}
    -> Int64
    {- ^ /@len@/: number of bytes of /@val@/ to insert, or -1 for all of /@val@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringInsertLen :: String -> Int64 -> Text -> Int64 -> m String
stringInsertLen string :: String
string pos :: Int64
pos val :: Text
val len :: Int64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> Int64 -> CString -> Int64 -> IO (Ptr String)
g_string_insert_len Ptr String
string' Int64
pos CString
val' Int64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringInsertLen" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringInsertLenMethodInfo
instance (signature ~ (Int64 -> T.Text -> Int64 -> m String), MonadIO m) => O.MethodInfo StringInsertLenMethodInfo String signature where
    overloadedMethod _ = stringInsertLen

#endif

-- method String::insert_unichar
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position at which to insert character, or -1\n    to append at the end of the string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "wc", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_insert_unichar" g_string_insert_unichar :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int64 ->                                -- pos : TBasicType TInt64
    CInt ->                                 -- wc : TBasicType TUniChar
    IO (Ptr String)

{- |
Converts a Unicode character into UTF-8, and insert it
into the string at the given position.
-}
stringInsertUnichar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int64
    {- ^ /@pos@/: the position at which to insert character, or -1
    to append at the end of the string -}
    -> Char
    {- ^ /@wc@/: a Unicode character -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringInsertUnichar :: String -> Int64 -> Char -> m String
stringInsertUnichar string :: String
string pos :: Int64
pos wc :: Char
wc = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    let wc' :: CInt
wc' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
wc
    Ptr String
result <- Ptr String -> Int64 -> CInt -> IO (Ptr String)
g_string_insert_unichar Ptr String
string' Int64
pos CInt
wc'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringInsertUnichar" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringInsertUnicharMethodInfo
instance (signature ~ (Int64 -> Char -> m String), MonadIO m) => O.MethodInfo StringInsertUnicharMethodInfo String signature where
    overloadedMethod _ = stringInsertUnichar

#endif

-- method String::overwrite
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position at which to start overwriting", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string that will overwrite the @string starting at @pos", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_overwrite" g_string_overwrite :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Word64 ->                               -- pos : TBasicType TUInt64
    CString ->                              -- val : TBasicType TUTF8
    IO (Ptr String)

{- |
Overwrites part of a string, lengthening it if necessary.

/Since: 2.14/
-}
stringOverwrite ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Word64
    {- ^ /@pos@/: the position at which to start overwriting -}
    -> T.Text
    {- ^ /@val@/: the string that will overwrite the /@string@/ starting at /@pos@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringOverwrite :: String -> Word64 -> Text -> m String
stringOverwrite string :: String
string pos :: Word64
pos val :: Text
val = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> Word64 -> CString -> IO (Ptr String)
g_string_overwrite Ptr String
string' Word64
pos CString
val'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringOverwrite" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringOverwriteMethodInfo
instance (signature ~ (Word64 -> T.Text -> m String), MonadIO m) => O.MethodInfo StringOverwriteMethodInfo String signature where
    overloadedMethod _ = stringOverwrite

#endif

-- method String::overwrite_len
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "pos", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position at which to start overwriting", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string that will overwrite the @string starting at @pos", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the number of bytes to write from @val", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_overwrite_len" g_string_overwrite_len :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Word64 ->                               -- pos : TBasicType TUInt64
    CString ->                              -- val : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO (Ptr String)

{- |
Overwrites part of a string, lengthening it if necessary.
This function will work with embedded nuls.

/Since: 2.14/
-}
stringOverwriteLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Word64
    {- ^ /@pos@/: the position at which to start overwriting -}
    -> T.Text
    {- ^ /@val@/: the string that will overwrite the /@string@/ starting at /@pos@/ -}
    -> Int64
    {- ^ /@len@/: the number of bytes to write from /@val@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringOverwriteLen :: String -> Word64 -> Text -> Int64 -> m String
stringOverwriteLen string :: String
string pos :: Word64
pos val :: Text
val len :: Int64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> Word64 -> CString -> Int64 -> IO (Ptr String)
g_string_overwrite_len Ptr String
string' Word64
pos CString
val' Int64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringOverwriteLen" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringOverwriteLenMethodInfo
instance (signature ~ (Word64 -> T.Text -> Int64 -> m String), MonadIO m) => O.MethodInfo StringOverwriteLenMethodInfo String signature where
    overloadedMethod _ = stringOverwriteLen

#endif

-- method String::prepend
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the string to prepend on the start of @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_prepend" g_string_prepend :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- val : TBasicType TUTF8
    IO (Ptr String)

{- |
Adds a string on to the start of a 'GI.GLib.Structs.String.String',
expanding it if necessary.
-}
stringPrepend ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> T.Text
    {- ^ /@val@/: the string to prepend on the start of /@string@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringPrepend :: String -> Text -> m String
stringPrepend string :: String
string val :: Text
val = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> CString -> IO (Ptr String)
g_string_prepend Ptr String
string' CString
val'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringPrepend" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringPrependMethodInfo
instance (signature ~ (T.Text -> m String), MonadIO m) => O.MethodInfo StringPrependMethodInfo String signature where
    overloadedMethod _ = stringPrepend

#endif

-- method String::prepend_c
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "c", argType = TBasicType TInt8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the byte to prepend on the start of the #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_prepend_c" g_string_prepend_c :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Int8 ->                                 -- c : TBasicType TInt8
    IO (Ptr String)

{- |
Adds a byte onto the start of a 'GI.GLib.Structs.String.String',
expanding it if necessary.
-}
stringPrependC ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Int8
    {- ^ /@c@/: the byte to prepend on the start of the 'GI.GLib.Structs.String.String' -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringPrependC :: String -> Int8 -> m String
stringPrependC string :: String
string c :: Int8
c = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> Int8 -> IO (Ptr String)
g_string_prepend_c Ptr String
string' Int8
c
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringPrependC" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringPrependCMethodInfo
instance (signature ~ (Int8 -> m String), MonadIO m) => O.MethodInfo StringPrependCMethodInfo String signature where
    overloadedMethod _ = stringPrependC

#endif

-- method String::prepend_len
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "val", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "bytes to prepend", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "number of bytes in @val to prepend, or -1 for all of @val", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_prepend_len" g_string_prepend_len :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- val : TBasicType TUTF8
    Int64 ->                                -- len : TBasicType TInt64
    IO (Ptr String)

{- |
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 'GI.GLib.Structs.String.stringPrependLen' equivalent to 'GI.GLib.Structs.String.stringPrepend'.
-}
stringPrependLen ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> T.Text
    {- ^ /@val@/: bytes to prepend -}
    -> Int64
    {- ^ /@len@/: number of bytes in /@val@/ to prepend, or -1 for all of /@val@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringPrependLen :: String -> Text -> Int64 -> m String
stringPrependLen string :: String
string val :: Text
val len :: Int64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
val' <- Text -> IO CString
textToCString Text
val
    Ptr String
result <- Ptr String -> CString -> Int64 -> IO (Ptr String)
g_string_prepend_len Ptr String
string' CString
val' Int64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringPrependLen" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
val'
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringPrependLenMethodInfo
instance (signature ~ (T.Text -> Int64 -> m String), MonadIO m) => O.MethodInfo StringPrependLenMethodInfo String signature where
    overloadedMethod _ = stringPrependLen

#endif

-- method String::prepend_unichar
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "wc", argType = TBasicType TUniChar, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a Unicode character", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_prepend_unichar" g_string_prepend_unichar :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CInt ->                                 -- wc : TBasicType TUniChar
    IO (Ptr String)

{- |
Converts a Unicode character into UTF-8, and prepends it
to the string.
-}
stringPrependUnichar ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Char
    {- ^ /@wc@/: a Unicode character -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringPrependUnichar :: String -> Char -> m String
stringPrependUnichar string :: String
string wc :: Char
wc = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    let wc' :: CInt
wc' = (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CInt) -> (Char -> Int) -> Char -> CInt
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Int
ord) Char
wc
    Ptr String
result <- Ptr String -> CInt -> IO (Ptr String)
g_string_prepend_unichar Ptr String
string' CInt
wc'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringPrependUnichar" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringPrependUnicharMethodInfo
instance (signature ~ (Char -> m String), MonadIO m) => O.MethodInfo StringPrependUnicharMethodInfo String signature where
    overloadedMethod _ = stringPrependUnichar

#endif

-- method String::set_size
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new length", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_set_size" g_string_set_size :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Word64 ->                               -- len : TBasicType TUInt64
    IO (Ptr String)

{- |
Sets the length of a 'GI.GLib.Structs.String.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.)
-}
stringSetSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Word64
    {- ^ /@len@/: the new length -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringSetSize :: String -> Word64 -> m String
stringSetSize string :: String
string len :: Word64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> Word64 -> IO (Ptr String)
g_string_set_size Ptr String
string' Word64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringSetSize" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringSetSizeMethodInfo
instance (signature ~ (Word64 -> m String), MonadIO m) => O.MethodInfo StringSetSizeMethodInfo String signature where
    overloadedMethod _ = stringSetSize

#endif

-- method String::truncate
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "len", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the new size of @string", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_truncate" g_string_truncate :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    Word64 ->                               -- len : TBasicType TUInt64
    IO (Ptr String)

{- |
Cuts off the end of the GString, leaving the first /@len@/ bytes.
-}
stringTruncate ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> Word64
    {- ^ /@len@/: the new size of /@string@/ -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringTruncate :: String -> Word64 -> m String
stringTruncate string :: String
string len :: Word64
len = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> Word64 -> IO (Ptr String)
g_string_truncate Ptr String
string' Word64
len
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringTruncate" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringTruncateMethodInfo
instance (signature ~ (Word64 -> m String), MonadIO m) => O.MethodInfo StringTruncateMethodInfo String signature where
    overloadedMethod _ = stringTruncate

#endif

-- method String::up
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "string", argType = TInterface (Name {namespace = "GLib", name = "String"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GString", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "String"}))
-- throws : False
-- Skip return : False

foreign import ccall "g_string_up" g_string_up :: 
    Ptr String ->                           -- string : TInterface (Name {namespace = "GLib", name = "String"})
    IO (Ptr String)

{-# DEPRECATED stringUp ["(Since version 2.2)","This function uses the locale-specific","    @/toupper()/@ function, which is almost never the right thing.","    Use 'GI.GLib.Structs.String.stringAsciiUp' or 'GI.GLib.Functions.utf8Strup' instead."] #-}
{- |
Converts a 'GI.GLib.Structs.String.String' to uppercase.
-}
stringUp ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    String
    {- ^ /@string@/: a 'GI.GLib.Structs.String.String' -}
    -> m String
    {- ^ __Returns:__ /@string@/ -}
stringUp :: String -> m String
stringUp string :: String
string = IO String -> m String
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO String -> m String) -> IO String -> m String
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    Ptr String
result <- Ptr String -> IO (Ptr String)
g_string_up Ptr String
string'
    Text -> Ptr String -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL "stringUp" Ptr String
result
    String
result' <- ((ManagedPtr String -> String) -> Ptr String -> IO String
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr String -> String
String) Ptr String
result
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    String -> IO String
forall (m :: * -> *) a. Monad m => a -> m a
return String
result'

#if ENABLE_OVERLOADING
data StringUpMethodInfo
instance (signature ~ (m String), MonadIO m) => O.MethodInfo StringUpMethodInfo String signature where
    overloadedMethod _ = stringUp

#endif

#if ENABLE_OVERLOADING
type family ResolveStringMethod (t :: Symbol) (o :: *) :: * where
    ResolveStringMethod "append" o = StringAppendMethodInfo
    ResolveStringMethod "appendC" o = StringAppendCMethodInfo
    ResolveStringMethod "appendLen" o = StringAppendLenMethodInfo
    ResolveStringMethod "appendUnichar" o = StringAppendUnicharMethodInfo
    ResolveStringMethod "appendUriEscaped" o = StringAppendUriEscapedMethodInfo
    ResolveStringMethod "asciiDown" o = StringAsciiDownMethodInfo
    ResolveStringMethod "asciiUp" o = StringAsciiUpMethodInfo
    ResolveStringMethod "assign" o = StringAssignMethodInfo
    ResolveStringMethod "down" o = StringDownMethodInfo
    ResolveStringMethod "equal" o = StringEqualMethodInfo
    ResolveStringMethod "erase" o = StringEraseMethodInfo
    ResolveStringMethod "free" o = StringFreeMethodInfo
    ResolveStringMethod "freeToBytes" o = StringFreeToBytesMethodInfo
    ResolveStringMethod "hash" o = StringHashMethodInfo
    ResolveStringMethod "insert" o = StringInsertMethodInfo
    ResolveStringMethod "insertC" o = StringInsertCMethodInfo
    ResolveStringMethod "insertLen" o = StringInsertLenMethodInfo
    ResolveStringMethod "insertUnichar" o = StringInsertUnicharMethodInfo
    ResolveStringMethod "overwrite" o = StringOverwriteMethodInfo
    ResolveStringMethod "overwriteLen" o = StringOverwriteLenMethodInfo
    ResolveStringMethod "prepend" o = StringPrependMethodInfo
    ResolveStringMethod "prependC" o = StringPrependCMethodInfo
    ResolveStringMethod "prependLen" o = StringPrependLenMethodInfo
    ResolveStringMethod "prependUnichar" o = StringPrependUnicharMethodInfo
    ResolveStringMethod "truncate" o = StringTruncateMethodInfo
    ResolveStringMethod "up" o = StringUpMethodInfo
    ResolveStringMethod "setSize" o = StringSetSizeMethodInfo
    ResolveStringMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveStringMethod t String, O.MethodInfo info String p) => O.IsLabelProxy t (String -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveStringMethod t String, O.MethodInfo info String p) => O.IsLabel t (String -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif
#endif

#endif