{-# LINE 1 "src/Database/EJDB2/IndexMode.hsc" #-}
{-# LANGUAGE CPP #-}
module Database.EJDB2.IndexMode where
import Foreign
import Foreign.C.String
import Foreign.C.Types
newtype IndexMode = IndexMode { unIndexMode :: CUChar }
uniqueIndexMode = IndexMode 1
{-# LINE 17 "src/Database/EJDB2/IndexMode.hsc" #-}
strIndexMode = IndexMode 4
{-# LINE 21 "src/Database/EJDB2/IndexMode.hsc" #-}
i64IndexMode = IndexMode 8
{-# LINE 25 "src/Database/EJDB2/IndexMode.hsc" #-}
f64IndexMode = IndexMode 16
{-# LINE 28 "src/Database/EJDB2/IndexMode.hsc" #-}
allIndexMode :: [IndexMode]
allIndexMode = [uniqueIndexMode, strIndexMode, i64IndexMode , f64IndexMode]
combineIndexMode :: [IndexMode] -> IndexMode
combineIndexMode = IndexMode . foldr ((.|.) . unIndexMode) 0
unCombineIndexMode :: IndexMode -> [IndexMode]
unCombineIndexMode (IndexMode (CUChar oflags)) = filter f allIndexMode
where
f = \(IndexMode (CUChar value)) -> value .&. oflags /= 0