{-# LANGUAGE EmptyDataDecls, FlexibleInstances,
  MultiParamTypeClasses, TypeFamilies #-}
module STD.Map.Template where
import Foreign.C.Types
import Foreign.Ptr
import FFICXX.Runtime.Cast
import STD.MapIterator.Template
import STD.Pair.Template

data RawMap tpk tpv

newtype Map tpk tpv = Map (Ptr (RawMap tpk tpv))

class () => IMap tpk tpv where
        newMap :: IO (Map tpk tpv)
        
        begin :: Map tpk tpv -> IO (MapIterator tpk tpv)
        
        end :: Map tpk tpv -> IO (MapIterator tpk tpv)
        
        insert :: Map tpk tpv -> Pair tpk tpv -> IO ()
        
        size :: Map tpk tpv -> IO CInt
        
        deleteMap :: Map tpk tpv -> IO ()

instance () => FPtr (Map tpk tpv) where
        type Raw (Map tpk tpv) = RawMap tpk tpv
        get_fptr :: Map tpk tpv -> Ptr (Raw (Map tpk tpv))
get_fptr (Map Ptr (RawMap tpk tpv)
ptr) = Ptr (RawMap tpk tpv)
ptr
        cast_fptr_to_obj :: Ptr (Raw (Map tpk tpv)) -> Map tpk tpv
cast_fptr_to_obj = forall tpk tpv. Ptr (RawMap tpk tpv) -> Map tpk tpv
Map

instance () => Castable (Map tpk tpv) (Ptr (RawMap tpk tpv)) where
        cast :: forall r. Map tpk tpv -> (Ptr (RawMap tpk tpv) -> IO r) -> IO r
cast Map tpk tpv
x Ptr (RawMap tpk tpv) -> IO r
f = Ptr (RawMap tpk tpv) -> IO r
f (forall a b. Ptr a -> Ptr b
castPtr (forall a. FPtr a => a -> Ptr (Raw a)
get_fptr Map tpk tpv
x))
        uncast :: forall r. Ptr (RawMap tpk tpv) -> (Map tpk tpv -> IO r) -> IO r
uncast Ptr (RawMap tpk tpv)
x Map tpk tpv -> IO r
f = Map tpk tpv -> IO r
f (forall a. FPtr a => Ptr (Raw a) -> a
cast_fptr_to_obj (forall a b. Ptr a -> Ptr b
castPtr Ptr (RawMap tpk tpv)
x))