mongoDB 0.4.1 → 0.4.2
raw patch · 3 files changed
+10/−6 lines, 3 filesdep −convertible
Dependencies removed: convertible
Files
- Database/MongoDB/BSON.hs +7/−2
- Database/MongoDB/Util.hs +2/−2
- mongoDB.cabal +1/−2
Database/MongoDB/BSON.hs view
@@ -67,7 +67,7 @@ import System.IO.Unsafe import System.Posix.Process --- | BsonValue is the type that can be used as a key in a 'BsonDoc'.+-- | BsonValue is the type that can be used as a value in a 'BsonDoc'. data BsonValue = BsonDouble Double | BsonString L8.ByteString@@ -155,12 +155,15 @@ {-# NOINLINE globalObjectIdInc #-} globalObjectIdInc = unsafePerformIO (newIORef 0) +-- | Create a new 'ObjectIdGen', the structure that must be passed to+-- genObjectId to create a 'ObjectId'. mkObjectIdGen :: IO ObjectIdGen mkObjectIdGen = do host <- liftM (fst . (!! 0) . readHex . List.take 6 . md5sum . C8.pack) getHostName return ObjectIdGen {oigMachine = host, oigInc = globalObjectIdInc} +-- | Create a new 'ObjectId'. genObjectId :: ObjectIdGen -> IO BsonValue genObjectId oig = do now <- liftM (truncate . (realToFrac :: POSIXTime -> Double)) getPOSIXTime@@ -172,9 +175,11 @@ (0xffff .&. pid) `shiftL` 24 .|. (inc `div` 0x100) `shiftL` 8 .|. (inc `rem` 0x100)) +-- | Decode binary bytes into 'BsonDoc'. getBsonDoc :: Get BsonDoc getBsonDoc = liftM snd getDoc +-- | Encode 'BsonDoc' into binary bytes. putBsonDoc :: BsonDoc -> Put putBsonDoc = putObj @@ -310,7 +315,7 @@ putByteString $ pack $ List.sort opt putNull putVal (BsonJSCode c) = putStrSz c-putVal (BsonSymbol s) = putI32 (fromIntegral $ 1 + L8.length s) >> putS s+putVal (BsonSymbol s) = putStrSz s putVal (BsonJSCodeWScope q s) = let bytes = runPut (putStrSz q >> putObj s) in putI32 ((+4) $ fromIntegral $ L.length bytes) >> putLazyByteString bytes
Database/MongoDB/Util.hs view
@@ -79,5 +79,5 @@ putS :: L8.ByteString -> Put putS s = putLazyByteString s >> putNull -putStrSz :: L.ByteString -> Put-putStrSz s = putI32 (fromIntegral $ 1 + L8.length s) >> putS s+putStrSz :: L8.ByteString -> Put+putStrSz s = putI32 (fromIntegral $ 1 + L.length s) >> putS s
mongoDB.cabal view
@@ -1,5 +1,5 @@ Name: mongoDB-Version: 0.4.1+Version: 0.4.2 License: MIT Maintainer: Scott Parish <srp@srparish.net> Author: Scott Parish <srp@srparish.net>@@ -16,7 +16,6 @@ binary, bytestring, containers,- convertible, data-binary-ieee754, network, random,