packages feed

hdf5-lite-0.1.0.0: src/Data/HDF5/Internal/Types.hs

-- GENERATED by C->Haskell Compiler, version 0.28.1 Switcheroo, 1 April 2016 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "src/Data/HDF5/Internal/Types.chs" #-}
{-# language CPP, DeriveAnyClass #-}
module Data.HDF5.Internal.Types where
import qualified Foreign.C.Types as C2HSImp



import Foreign.Storable




-- | HDF5 integer error codes
type Herr = (C2HSImp.CInt) 

-- | HDF Type of atoms to return to users
type Hid = (C2HSImp.CLLong) 

-- | HDF5 file object sizes (64 bits by default i.e. an unsigned CLLong)
type Hsize = (C2HSImp.CULLong) 

-- | HDF5 "ternary" Boolean type. Functions that return `htri_t' return zero (false), positive (true), or negative (failure).
type Htri = (C2HSImp.CInt)
{-# LINE 19 "src/Data/HDF5/Internal/Types.chs" #-}




-- | HDF5 native datatypes : https://support.hdfgroup.org/HDF5/doc/RM/PredefDTypes.html
  
-- type HNativeDouble = {#type H5T_NATIVE_DOUBLE #}



-- /* These are the various classes of datatypes */
-- /* If this goes over 16 types (0-15), the file format will need to change) */
-- typedef enum H5T_class_t {
--     H5T_NO_CLASS         = -1,  /*error                                      */
--     H5T_INTEGER          = 0,   /*integer types                              */
--     H5T_FLOAT            = 1,   /*floating-point types                       */
--     H5T_TIME             = 2,   /*date and time types                        */
--     H5T_STRING           = 3,   /*character string types                     */
--     H5T_BITFIELD         = 4,   /*bit field types                            */
--     H5T_OPAQUE           = 5,   /*opaque types                               */
--     H5T_COMPOUND         = 6,   /*compound types                             */
--     H5T_REFERENCE        = 7,   /*reference types                            */
--     H5T_ENUM		 = 8,	/*enumeration types                          */
--     H5T_VLEN		 = 9,	/*Variable-Length types                      */
--     H5T_ARRAY	         = 10,	/*Array types                                */

--     H5T_NCLASSES                /*this must be last                          */
-- } H5T_class_t;

data H5T_class_t = H5tNoClass
                 | H5tInteger
                 | H5tFloat
                 | H5tTime
                 | H5tString
                 | H5tBitfield
                 | H5tOpaque
                 | H5tCompound
                 | H5tReference
                 | H5tEnum
                 | H5tVlen
                 | H5tArray
                 | H5tNclasses
  deriving (Eq,Storable)
instance Enum H5T_class_t where
  succ H5tNoClass = H5tInteger
  succ H5tInteger = H5tFloat
  succ H5tFloat = H5tTime
  succ H5tTime = H5tString
  succ H5tString = H5tBitfield
  succ H5tBitfield = H5tOpaque
  succ H5tOpaque = H5tCompound
  succ H5tCompound = H5tReference
  succ H5tReference = H5tEnum
  succ H5tEnum = H5tVlen
  succ H5tVlen = H5tArray
  succ H5tArray = H5tNclasses
  succ H5tNclasses = error "H5T_class_t.succ: H5tNclasses has no successor"

  pred H5tInteger = H5tNoClass
  pred H5tFloat = H5tInteger
  pred H5tTime = H5tFloat
  pred H5tString = H5tTime
  pred H5tBitfield = H5tString
  pred H5tOpaque = H5tBitfield
  pred H5tCompound = H5tOpaque
  pred H5tReference = H5tCompound
  pred H5tEnum = H5tReference
  pred H5tVlen = H5tEnum
  pred H5tArray = H5tVlen
  pred H5tNclasses = H5tArray
  pred H5tNoClass = error "H5T_class_t.pred: H5tNoClass has no predecessor"

  enumFromTo from to = go from
    where
      end = fromEnum to
      go v = case compare (fromEnum v) end of
                 LT -> v : go (succ v)
                 EQ -> [v]
                 GT -> []

  enumFrom from = enumFromTo from H5tNclasses

  fromEnum H5tNoClass = (-1)
  fromEnum H5tInteger = 0
  fromEnum H5tFloat = 1
  fromEnum H5tTime = 2
  fromEnum H5tString = 3
  fromEnum H5tBitfield = 4
  fromEnum H5tOpaque = 5
  fromEnum H5tCompound = 6
  fromEnum H5tReference = 7
  fromEnum H5tEnum = 8
  fromEnum H5tVlen = 9
  fromEnum H5tArray = 10
  fromEnum H5tNclasses = 11

  toEnum (-1) = H5tNoClass
  toEnum 0 = H5tInteger
  toEnum 1 = H5tFloat
  toEnum 2 = H5tTime
  toEnum 3 = H5tString
  toEnum 4 = H5tBitfield
  toEnum 5 = H5tOpaque
  toEnum 6 = H5tCompound
  toEnum 7 = H5tReference
  toEnum 8 = H5tEnum
  toEnum 9 = H5tVlen
  toEnum 10 = H5tArray
  toEnum 11 = H5tNclasses
  toEnum unmatched = error ("H5T_class_t.toEnum: Cannot match " ++ show unmatched)

{-# LINE 48 "src/Data/HDF5/Internal/Types.chs" #-}




-- | flags