{-# 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 { IndexMode -> CUChar
unIndexMode :: CUChar }
uniqueIndexMode :: IndexMode
uniqueIndexMode = CUChar -> IndexMode
IndexMode 1
{-# LINE 17 "src/Database/EJDB2/IndexMode.hsc" #-}
strIndexMode :: IndexMode
strIndexMode = CUChar -> IndexMode
IndexMode 4
{-# LINE 21 "src/Database/EJDB2/IndexMode.hsc" #-}
i64IndexMode :: IndexMode
i64IndexMode = CUChar -> IndexMode
IndexMode 8
{-# LINE 25 "src/Database/EJDB2/IndexMode.hsc" #-}
f64IndexMode :: IndexMode
f64IndexMode = CUChar -> IndexMode
IndexMode 16
{-# LINE 28 "src/Database/EJDB2/IndexMode.hsc" #-}
allIndexMode :: [IndexMode]
allIndexMode :: [IndexMode]
allIndexMode = [IndexMode
uniqueIndexMode, IndexMode
strIndexMode, IndexMode
i64IndexMode , IndexMode
f64IndexMode]
combineIndexMode :: [IndexMode] -> IndexMode
combineIndexMode :: [IndexMode] -> IndexMode
combineIndexMode = CUChar -> IndexMode
IndexMode (CUChar -> IndexMode)
-> ([IndexMode] -> CUChar) -> [IndexMode] -> IndexMode
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (IndexMode -> CUChar -> CUChar) -> CUChar -> [IndexMode] -> CUChar
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr (CUChar -> CUChar -> CUChar
forall a. Bits a => a -> a -> a
(.|.) (CUChar -> CUChar -> CUChar)
-> (IndexMode -> CUChar) -> IndexMode -> CUChar -> CUChar
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IndexMode -> CUChar
unIndexMode) 0
unCombineIndexMode :: IndexMode -> [IndexMode]
unCombineIndexMode :: IndexMode -> [IndexMode]
unCombineIndexMode (IndexMode (CUChar oflags :: Word8
oflags)) = (IndexMode -> Bool) -> [IndexMode] -> [IndexMode]
forall a. (a -> Bool) -> [a] -> [a]
filter IndexMode -> Bool
f [IndexMode]
allIndexMode
where
f :: IndexMode -> Bool
f = \(IndexMode (CUChar value :: Word8
value)) -> Word8
value Word8 -> Word8 -> Word8
forall a. Bits a => a -> a -> a
.&. Word8
oflags Word8 -> Word8 -> Bool
forall a. Eq a => a -> a -> Bool
/= 0