module TesML.Data.RecordData (RecordData
                            , getDecoder)

where

import Data.Binary.Get (Get
                      , skip)

import TesML.Data.Types
import qualified TesML.Data.Records as RECS
import Control.Monad.Trans.Except


data RecordData = TES4 RECS.TES4
                | MOVT RECS.MOVT
                | GENERIC
                deriving Show


getDecoder :: EntryType -> TESDecoder RecordData
getDecoder "TES4" = mapExceptT ((fmap . fmap) TES4) RECS.decoderTES4
getDecoder "MOVT" = mapExceptT ((fmap . fmap) MOVT) RECS.decoderMOVT
getDecoder typ = throwE $ "Unsupported entry type: " ++ typ

