module Rattletrap.Decode.Header
( decodeHeader
)
where
import Rattletrap.Decode.Common
import Rattletrap.Decode.Dictionary
import Rattletrap.Decode.Property
import Rattletrap.Decode.Str
import Rattletrap.Decode.Word32le
import Rattletrap.Type.Header
import Rattletrap.Type.Word32le
decodeHeader :: Decode Header
= do
(Word32le
major, Word32le
minor) <- (,) (Word32le -> Word32le -> (Word32le, Word32le))
-> Get Word32le -> Get (Word32le -> (Word32le, Word32le))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get Word32le
decodeWord32le Get (Word32le -> (Word32le, Word32le))
-> Get Word32le -> Get (Word32le, Word32le)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Word32le
decodeWord32le
Word32le
-> Word32le
-> Maybe Word32le
-> Str
-> Dictionary Property
-> Header
Header Word32le
major Word32le
minor
(Maybe Word32le -> Str -> Dictionary Property -> Header)
-> Get (Maybe Word32le)
-> Get (Str -> Dictionary Property -> Header)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Bool -> Get Word32le -> Get (Maybe Word32le)
forall (m :: * -> *) (f :: * -> *) a.
(Applicative m, Alternative f) =>
Bool -> m a -> m (f a)
decodeWhen
(Word32le
major Word32le -> Word32le -> Bool
forall a. Ord a => a -> a -> Bool
>= Word32 -> Word32le
Word32le Word32
868 Bool -> Bool -> Bool
&& Word32le
minor Word32le -> Word32le -> Bool
forall a. Ord a => a -> a -> Bool
>= Word32 -> Word32le
Word32le Word32
18)
Get Word32le
decodeWord32le
Get (Str -> Dictionary Property -> Header)
-> Get Str -> Get (Dictionary Property -> Header)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Get Str
decodeStr
Get (Dictionary Property -> Header)
-> Get (Dictionary Property) -> Decode Header
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Decode Property -> Get (Dictionary Property)
forall a. Decode a -> Decode (Dictionary a)
decodeDictionary Decode Property
decodeProperty