module Data.Bson.Types
( RegexOption(..)
, RegexOptions
, Value(..)
, Binary(..)
, ObjectId(..)
, Document
, Array
, Label
, Field
) where
import Data.Int (Int32, Int64)
import Data.Time.Clock (UTCTime)
import Data.Time.Format ()
import Data.Typeable (Typeable)
import Data.Word (Word32, Word16)
import qualified Data.ByteString as S
import Data.BitSet.Word (BitSet)
import Data.Vector (Vector)
import Data.Word.Word24 (Word24)
import Data.Text (Text)
import Data.UUID (UUID)
import Data.Bson.Document (Document)
data RegexOption = RegexOptionCaseInsensitive
| RegexOptionLocaleDependent
| RegexOptionMultiline
| RegexOptionDotall
| RegexOptionUnicode
| RegexOptionVerbose
deriving (Eq, Show, Typeable, Enum)
type RegexOptions = BitSet RegexOption
data Value = ValueDouble !Double
| ValueString !Text
| ValueDocument !Document
| ValueArray !Array
| ValueBinary !Binary
| ValueObjectId !ObjectId
| ValueBool !Bool
| ValueUtcTime !UTCTime
| ValueNull
| ValueRegex !Text !RegexOptions
| ValueJavascript !Text
| ValueJavascriptWithScope !Text !Document
| ValueInt32 !Int32
| ValueInt64 !Int64
| ValueTimestamp !Int64
| ValueMin
| ValueMax
deriving (Eq, Show, Typeable)
type Label = Text
type Array = Vector Value
type Field = (Label, Value)
data ObjectId = ObjectId
{ objectIdTime :: !Word32
, objectIdMachine :: !Word24
, objectIdPid :: !Word16
, objectIdInc :: !Word24
} deriving (Eq, Show, Typeable)
data Binary = BinaryGeneric !S.ByteString
| BinaryFunction !S.ByteString
| BinaryUuid !UUID
| BinaryMd5 !S.ByteString
| BinaryUserDefined !S.ByteString
deriving (Eq, Show, Typeable)