{-# LINE 1 "src/Database/EJDB2/Options.hsc" #-}
{-# LANGUAGE CPP #-}
module Database.EJDB2.Options
( Options(..), zero, OptionsB, options, build ) where
import Data.ByteString.Char8
import Foreign
import Foreign.C.String
import Foreign.C.Types
import qualified Database.EJDB2.KV as KV
import qualified Database.EJDB2.HTTP as HTTP
data Options = Options { kv :: !KV.Options
, http :: !HTTP.Options
, noWal :: !Bool
, sortBufferSz :: !Word32
, documentBufferSz :: !Word32
}
zero :: Options
zero = Options { kv = KV.zero
, http = HTTP.zero
, noWal = False
, sortBufferSz = 0
, documentBufferSz = 0
}
data OptionsB = OptionsB { options :: Options
, kvB :: !KV.OptionsB
, httpB :: !HTTP.OptionsB
}
build :: Options -> IO OptionsB
build options = do
kvB <- KV.build (kv options)
httpB <- HTTP.build (http options)
return $ OptionsB options kvB httpB
instance Storable OptionsB where
sizeOf _ = (136)
{-# LINE 49 "src/Database/EJDB2/Options.hsc" #-}
alignment _ = 8
{-# LINE 50 "src/Database/EJDB2/Options.hsc" #-}
peek ptr = do
kvB <- (\hsc_ptr -> peekByteOff hsc_ptr 0) ptr
{-# LINE 52 "src/Database/EJDB2/Options.hsc" #-}
let kv = KV.options kvB
httpB <- (\hsc_ptr -> peekByteOff hsc_ptr 72) ptr
{-# LINE 54 "src/Database/EJDB2/Options.hsc" #-}
let http = HTTP.options httpB
(CBool no_wal) <- (\hsc_ptr -> peekByteOff hsc_ptr 120) ptr
{-# LINE 56 "src/Database/EJDB2/Options.hsc" #-}
(CUInt sort_buffer_sz) <- (\hsc_ptr -> peekByteOff hsc_ptr 124) ptr
{-# LINE 57 "src/Database/EJDB2/Options.hsc" #-}
(CUInt document_buffer_sz) <- (\hsc_ptr -> peekByteOff hsc_ptr 128) ptr
{-# LINE 58 "src/Database/EJDB2/Options.hsc" #-}
return $ OptionsB (Options kv http (toBool no_wal) sort_buffer_sz document_buffer_sz) kvB httpB
poke ptr (OptionsB (Options _ http noWal sort_buffer_sz document_buffer_sz) kvB httpB) = do
(\hsc_ptr -> pokeByteOff hsc_ptr 0) ptr kvB
{-# LINE 61 "src/Database/EJDB2/Options.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 72) ptr httpB
{-# LINE 62 "src/Database/EJDB2/Options.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 120) ptr (CBool $ fromBool noWal)
{-# LINE 63 "src/Database/EJDB2/Options.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 124) ptr (CUInt sort_buffer_sz)
{-# LINE 64 "src/Database/EJDB2/Options.hsc" #-}
(\hsc_ptr -> pokeByteOff hsc_ptr 128) ptr (CUInt document_buffer_sz)
{-# LINE 65 "src/Database/EJDB2/Options.hsc" #-}