{- |
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 GTree struct is an opaque data structure representing a
[balanced binary tree][glib-Balanced-Binary-Trees]. It should be
accessed only by using the following functions.
-}

module GI.GLib.Structs.Tree
    ( 

-- * Exported types
    Tree(..)                                ,
    noTree                                  ,


 -- * Methods
-- ** treeDestroy
    treeDestroy                             ,


-- ** treeHeight
    treeHeight                              ,


-- ** treeInsert
    treeInsert                              ,


-- ** treeLookupExtended
    treeLookupExtended                      ,


-- ** treeNnodes
    treeNnodes                              ,


-- ** treeRemove
    treeRemove                              ,


-- ** treeReplace
    treeReplace                             ,


-- ** treeSteal
    treeSteal                               ,


-- ** treeUnref
    treeUnref                               ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.GLib.Types
import GI.GLib.Callbacks

newtype Tree = Tree (ForeignPtr Tree)
noTree :: Maybe Tree
noTree = Nothing

-- method Tree::destroy
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_destroy" g_tree_destroy :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    IO ()


treeDestroy ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    m ()
treeDestroy _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_tree_destroy _obj'
    touchManagedPtr _obj
    return ()

-- method Tree::height
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_height" g_tree_height :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    IO Int32


treeHeight ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    m Int32
treeHeight _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_tree_height _obj'
    touchManagedPtr _obj
    return result

-- method Tree::insert
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_insert" g_tree_insert :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    Ptr () ->                               -- key : TBasicType TVoid
    Ptr () ->                               -- value : TBasicType TVoid
    IO ()


treeInsert ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    Ptr () ->                               -- key
    Ptr () ->                               -- value
    m ()
treeInsert _obj key value = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_tree_insert _obj' key value
    touchManagedPtr _obj
    return ()

-- method Tree::lookup_extended
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "lookup_key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "orig_key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "lookup_key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "orig_key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_lookup_extended" g_tree_lookup_extended :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    Ptr () ->                               -- lookup_key : TBasicType TVoid
    Ptr () ->                               -- orig_key : TBasicType TVoid
    Ptr () ->                               -- value : TBasicType TVoid
    IO CInt


treeLookupExtended ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    Ptr () ->                               -- lookup_key
    Ptr () ->                               -- orig_key
    Ptr () ->                               -- value
    m Bool
treeLookupExtended _obj lookup_key orig_key value = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_tree_lookup_extended _obj' lookup_key orig_key value
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Tree::nnodes
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_nnodes" g_tree_nnodes :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    IO Int32


treeNnodes ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    m Int32
treeNnodes _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_tree_nnodes _obj'
    touchManagedPtr _obj
    return result

-- method Tree::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_remove" g_tree_remove :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    Ptr () ->                               -- key : TBasicType TVoid
    IO CInt


treeRemove ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    Ptr () ->                               -- key
    m Bool
treeRemove _obj key = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_tree_remove _obj' key
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Tree::replace
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_replace" g_tree_replace :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    Ptr () ->                               -- key : TBasicType TVoid
    Ptr () ->                               -- value : TBasicType TVoid
    IO ()


treeReplace ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    Ptr () ->                               -- key
    Ptr () ->                               -- value
    m ()
treeReplace _obj key value = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_tree_replace _obj' key value
    touchManagedPtr _obj
    return ()

-- method Tree::steal
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_steal" g_tree_steal :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    Ptr () ->                               -- key : TBasicType TVoid
    IO CInt


treeSteal ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    Ptr () ->                               -- key
    m Bool
treeSteal _obj key = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    result <- g_tree_steal _obj' key
    let result' = (/= 0) result
    touchManagedPtr _obj
    return result'

-- method Tree::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "Tree", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_tree_unref" g_tree_unref :: 
    Ptr Tree ->                             -- _obj : TInterface "GLib" "Tree"
    IO ()


treeUnref ::
    (MonadIO m) =>
    Tree ->                                 -- _obj
    m ()
treeUnref _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_tree_unref _obj'
    touchManagedPtr _obj
    return ()