{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.GLib.Structs.StringChunk
(
StringChunk(..) ,
#if defined(ENABLE_OVERLOADING)
ResolveStringChunkMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
StringChunkClearMethodInfo ,
#endif
stringChunkClear ,
#if defined(ENABLE_OVERLOADING)
StringChunkFreeMethodInfo ,
#endif
stringChunkFree ,
#if defined(ENABLE_OVERLOADING)
StringChunkInsertMethodInfo ,
#endif
stringChunkInsert ,
#if defined(ENABLE_OVERLOADING)
StringChunkInsertConstMethodInfo ,
#endif
stringChunkInsertConst ,
#if defined(ENABLE_OVERLOADING)
StringChunkInsertLenMethodInfo ,
#endif
stringChunkInsertLen ,
) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
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.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
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 qualified GHC.OverloadedLabels as OL
newtype StringChunk = StringChunk (SP.ManagedPtr StringChunk)
deriving (StringChunk -> StringChunk -> Bool
(StringChunk -> StringChunk -> Bool)
-> (StringChunk -> StringChunk -> Bool) -> Eq StringChunk
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StringChunk -> StringChunk -> Bool
$c/= :: StringChunk -> StringChunk -> Bool
== :: StringChunk -> StringChunk -> Bool
$c== :: StringChunk -> StringChunk -> Bool
Eq)
instance SP.ManagedPtrNewtype StringChunk where
toManagedPtr :: StringChunk -> ManagedPtr StringChunk
toManagedPtr (StringChunk ManagedPtr StringChunk
p) = ManagedPtr StringChunk
p
instance BoxedPtr StringChunk where
boxedPtrCopy :: StringChunk -> IO StringChunk
boxedPtrCopy = StringChunk -> IO StringChunk
forall (m :: * -> *) a. Monad m => a -> m a
return
boxedPtrFree :: StringChunk -> IO ()
boxedPtrFree = \StringChunk
_x -> () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList StringChunk
type instance O.AttributeList StringChunk = StringChunkAttributeList
type StringChunkAttributeList = ('[ ] :: [(Symbol, *)])
#endif
foreign import ccall "g_string_chunk_clear" g_string_chunk_clear ::
Ptr StringChunk ->
IO ()
stringChunkClear ::
(B.CallStack.HasCallStack, MonadIO m) =>
StringChunk
-> m ()
stringChunkClear :: StringChunk -> m ()
stringChunkClear StringChunk
chunk = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr StringChunk
chunk' <- StringChunk -> IO (Ptr StringChunk)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StringChunk
chunk
Ptr StringChunk -> IO ()
g_string_chunk_clear Ptr StringChunk
chunk'
StringChunk -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StringChunk
chunk
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data StringChunkClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo StringChunkClearMethodInfo StringChunk signature where
overloadedMethod = stringChunkClear
#endif
foreign import ccall "g_string_chunk_free" g_string_chunk_free ::
Ptr StringChunk ->
IO ()
stringChunkFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
StringChunk
-> m ()
stringChunkFree :: StringChunk -> m ()
stringChunkFree StringChunk
chunk = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
Ptr StringChunk
chunk' <- StringChunk -> IO (Ptr StringChunk)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StringChunk
chunk
Ptr StringChunk -> IO ()
g_string_chunk_free Ptr StringChunk
chunk'
StringChunk -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StringChunk
chunk
() -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
#if defined(ENABLE_OVERLOADING)
data StringChunkFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo StringChunkFreeMethodInfo StringChunk signature where
overloadedMethod = stringChunkFree
#endif
foreign import ccall "g_string_chunk_insert" g_string_chunk_insert ::
Ptr StringChunk ->
CString ->
IO CString
stringChunkInsert ::
(B.CallStack.HasCallStack, MonadIO m) =>
StringChunk
-> T.Text
-> m T.Text
stringChunkInsert :: StringChunk -> Text -> m Text
stringChunkInsert StringChunk
chunk Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr StringChunk
chunk' <- StringChunk -> IO (Ptr StringChunk)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StringChunk
chunk
CString
string' <- Text -> IO CString
textToCString Text
string
CString
result <- Ptr StringChunk -> CString -> IO CString
g_string_chunk_insert Ptr StringChunk
chunk' CString
string'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"stringChunkInsert" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
StringChunk -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StringChunk
chunk
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data StringChunkInsertMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m) => O.MethodInfo StringChunkInsertMethodInfo StringChunk signature where
overloadedMethod = stringChunkInsert
#endif
foreign import ccall "g_string_chunk_insert_const" g_string_chunk_insert_const ::
Ptr StringChunk ->
CString ->
IO CString
stringChunkInsertConst ::
(B.CallStack.HasCallStack, MonadIO m) =>
StringChunk
-> T.Text
-> m T.Text
stringChunkInsertConst :: StringChunk -> Text -> m Text
stringChunkInsertConst StringChunk
chunk Text
string = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr StringChunk
chunk' <- StringChunk -> IO (Ptr StringChunk)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StringChunk
chunk
CString
string' <- Text -> IO CString
textToCString Text
string
CString
result <- Ptr StringChunk -> CString -> IO CString
g_string_chunk_insert_const Ptr StringChunk
chunk' CString
string'
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"stringChunkInsertConst" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
StringChunk -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StringChunk
chunk
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data StringChunkInsertConstMethodInfo
instance (signature ~ (T.Text -> m T.Text), MonadIO m) => O.MethodInfo StringChunkInsertConstMethodInfo StringChunk signature where
overloadedMethod = stringChunkInsertConst
#endif
foreign import ccall "g_string_chunk_insert_len" g_string_chunk_insert_len ::
Ptr StringChunk ->
CString ->
Int64 ->
IO CString
stringChunkInsertLen ::
(B.CallStack.HasCallStack, MonadIO m) =>
StringChunk
-> T.Text
-> Int64
-> m T.Text
stringChunkInsertLen :: StringChunk -> Text -> Int64 -> m Text
stringChunkInsertLen StringChunk
chunk Text
string Int64
len = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
Ptr StringChunk
chunk' <- StringChunk -> IO (Ptr StringChunk)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr StringChunk
chunk
CString
string' <- Text -> IO CString
textToCString Text
string
CString
result <- Ptr StringChunk -> CString -> Int64 -> IO CString
g_string_chunk_insert_len Ptr StringChunk
chunk' CString
string' Int64
len
Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"stringChunkInsertLen" CString
result
Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
StringChunk -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr StringChunk
chunk
CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
string'
Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
#if defined(ENABLE_OVERLOADING)
data StringChunkInsertLenMethodInfo
instance (signature ~ (T.Text -> Int64 -> m T.Text), MonadIO m) => O.MethodInfo StringChunkInsertLenMethodInfo StringChunk signature where
overloadedMethod = stringChunkInsertLen
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveStringChunkMethod (t :: Symbol) (o :: *) :: * where
ResolveStringChunkMethod "clear" o = StringChunkClearMethodInfo
ResolveStringChunkMethod "free" o = StringChunkFreeMethodInfo
ResolveStringChunkMethod "insert" o = StringChunkInsertMethodInfo
ResolveStringChunkMethod "insertConst" o = StringChunkInsertConstMethodInfo
ResolveStringChunkMethod "insertLen" o = StringChunkInsertLenMethodInfo
ResolveStringChunkMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveStringChunkMethod t StringChunk, O.MethodInfo info StringChunk p) => OL.IsLabel t (StringChunk -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif