-- This file is part of Qtah.
--
-- Copyright 2015-2021 The Qtah Authors.
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU Lesser General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU Lesser General Public License for more details.
--
-- You should have received a copy of the GNU Lesser General Public License
-- along with this program.  If not, see <http://www.gnu.org/licenses/>.

module Graphics.UI.Qtah.Generator.Interface.Core.QFileDevice (
  aModule,
  c_QFileDevice,
  e_FileError,
  e_FileHandleFlag,
  fl_FileHandleFlags,
  e_FileTime,
  e_MemoryMapFlags,
  e_Permission,
  fl_Permissions,
  ) where

import Foreign.Hoppy.Generator.Spec (
  addReqIncludes,
  classSetEntityPrefix,
  ident,
  ident1,
  includeStd,
  makeClass,
  mkConstMethod,
  mkMethod,
  mkMethod',
  np,
  )
import Foreign.Hoppy.Generator.Types (ucharT, boolT, intT, objT, voidT, enumT, ptrT)
import Foreign.Hoppy.Generator.Version (collect, just, test)
import Graphics.UI.Qtah.Generator.Config (qtVersion)
import Graphics.UI.Qtah.Generator.Flags (flagsT)
import Graphics.UI.Qtah.Generator.Interface.Core.QDateTime (c_QDateTime)
import Graphics.UI.Qtah.Generator.Interface.Core.QIODevice (c_QIODevice)
import Graphics.UI.Qtah.Generator.Interface.Core.QString (c_QString)
import Graphics.UI.Qtah.Generator.Module (AModule (AQtModule), makeQtModuleWithMinVersion)
import Graphics.UI.Qtah.Generator.Types
import Graphics.UI.Qtah.Generator.Interface.Core.Types (qlonglong)

{-# ANN module "HLint: ignore Use camelCase" #-}

aModule :: AModule
aModule =
  QtModule -> AModule
AQtModule (QtModule -> AModule) -> QtModule -> AModule
forall a b. (a -> b) -> a -> b
$
  [String] -> Version -> [QtExport] -> QtModule
makeQtModuleWithMinVersion [String
"Core", String
"QFileDevice"] [Int
5, Int
0] ([QtExport] -> QtModule) -> [QtExport] -> QtModule
forall a b. (a -> b) -> a -> b
$
  [Filtered QtExport] -> [QtExport]
forall a. [Filtered a] -> [a]
collect ([Filtered QtExport] -> [QtExport])
-> [Filtered QtExport] -> [QtExport]
forall a b. (a -> b) -> a -> b
$
  [ QtExport -> Filtered QtExport
forall a. a -> Filtered a
just (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ Class -> QtExport
forall a. Exportable a => a -> QtExport
qtExport Class
c_QFileDevice
  , Bool -> QtExport -> Filtered QtExport
forall a. Bool -> a -> Filtered a
test (Version
qtVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
5, Int
10]) (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_FileTime
  , Bool -> QtExport -> Filtered QtExport
forall a. Bool -> a -> Filtered a
test (Version
qtVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
4, Int
4]) (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_MemoryMapFlags
  , QtExport -> Filtered QtExport
forall a. a -> Filtered a
just (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_FileError
  , QtExport -> Filtered QtExport
forall a. a -> Filtered a
just (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_FileHandleFlag
  , QtExport -> Filtered QtExport
forall a. a -> Filtered a
just (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ Flags -> QtExport
forall a. Exportable a => a -> QtExport
qtExport Flags
fl_FileHandleFlags
  , QtExport -> Filtered QtExport
forall a. a -> Filtered a
just (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ CppEnum -> QtExport
forall a. Exportable a => a -> QtExport
qtExport CppEnum
e_Permission
  , QtExport -> Filtered QtExport
forall a. a -> Filtered a
just (QtExport -> Filtered QtExport) -> QtExport -> Filtered QtExport
forall a b. (a -> b) -> a -> b
$ Flags -> QtExport
forall a. Exportable a => a -> QtExport
qtExport Flags
fl_Permissions
  ]

c_QFileDevice :: Class
c_QFileDevice =
  [Include] -> Class -> Class
forall a. HasReqs a => [Include] -> a -> a
addReqIncludes [String -> Include
includeStd String
"QFileDevice"] (Class -> Class) -> Class -> Class
forall a b. (a -> b) -> a -> b
$
  String -> Class -> Class
classSetEntityPrefix String
"" (Class -> Class) -> Class -> Class
forall a b. (a -> b) -> a -> b
$
  Identifier -> Maybe ExtName -> [Class] -> [ClassEntity] -> Class
makeClass (String -> Identifier
ident String
"QFileDevice") Maybe ExtName
forall a. Maybe a
Nothing [Class
c_QIODevice] ([ClassEntity] -> Class) -> [ClassEntity] -> Class
forall a b. (a -> b) -> a -> b
$
  [Filtered ClassEntity] -> [ClassEntity]
forall a. [Filtered a] -> [a]
collect
  [ ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"error" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ CppEnum -> Type
enumT CppEnum
e_FileError
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"fileName" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QString
  , Bool -> ClassEntity -> Filtered ClassEntity
forall a. Bool -> a -> Filtered a
test (Version
qtVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
5, Int
10]) (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"fileTime" [CppEnum -> Type
enumT CppEnum
e_FileTime] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Class -> Type
objT Class
c_QDateTime
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"flush" [Parameter]
np Type
boolT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"handle" [Parameter]
np Type
intT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"map" String
"map" [Type
qlonglong, Type
qlonglong] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Type -> Type
ptrT Type
ucharT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> String -> [p] -> Type -> ClassEntity
mkMethod' String
"map" String
"mapWithFlags" [Type
qlonglong, Type
qlonglong, CppEnum -> Type
enumT CppEnum
e_MemoryMapFlags] (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Type -> Type
ptrT Type
ucharT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkConstMethod String
"permissions" [Parameter]
np (Type -> ClassEntity) -> Type -> ClassEntity
forall a b. (a -> b) -> a -> b
$ Flags -> Type
flagsT Flags
fl_Permissions
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"resize" [Type
qlonglong] Type
boolT
  , Bool -> ClassEntity -> Filtered ClassEntity
forall a. Bool -> a -> Filtered a
test (Version
qtVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
5, Int
10]) (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$
    String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"setFileTime" [Class -> Type
objT Class
c_QDateTime, CppEnum -> Type
enumT CppEnum
e_FileTime] Type
boolT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"setPermissions" [Flags -> Type
flagsT Flags
fl_Permissions] Type
boolT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Type] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"unmap" [Type -> Type
ptrT Type
ucharT] Type
boolT
  , ClassEntity -> Filtered ClassEntity
forall a. a -> Filtered a
just (ClassEntity -> Filtered ClassEntity)
-> ClassEntity -> Filtered ClassEntity
forall a b. (a -> b) -> a -> b
$ String -> [Parameter] -> Type -> ClassEntity
forall name p.
(IsFnName String name, IsParameter p) =>
name -> [p] -> Type -> ClassEntity
mkMethod String
"unsetError" [Parameter]
np Type
voidT
  ]

e_FileError :: CppEnum
e_FileError =
  Identifier -> [Include] -> [String] -> CppEnum
makeQtEnum (String -> String -> Identifier
ident1 String
"QFileDevice" String
"FileError") [String -> Include
includeStd String
"QFileDevice"]
  [ String
"NoError"
  , String
"ReadError"
  , String
"WriteError"
  , String
"FatalError"
  , String
"ResourceError"
  , String
"OpenError"
  , String
"AbortError"
  , String
"TimeOutError"
  , String
"UnspecifiedError"
  , String
"RemoveError"
  , String
"RenameError"
  , String
"PositionError"
  , String
"ResizeError"
  , String
"PermissionsError"
  , String
"CopyError"
  ]

(CppEnum
e_FileHandleFlag, Flags
fl_FileHandleFlags) =
  Identifier -> String -> [Include] -> [String] -> (CppEnum, Flags)
makeQtEnumAndFlags (String -> String -> Identifier
ident1 String
"QFileDevice" String
"FileHandleFlag") String
"FileHandleFlags" [String -> Include
includeStd String
"QFileDevice"]
  [ String
"DontCloseHandle"
  , String
"AutoCloseHandle"
  ]

e_FileTime :: CppEnum
e_FileTime =
  Identifier -> [Include] -> [String] -> CppEnum
makeQtEnum (String -> String -> Identifier
ident1 String
"QFileDevice" String
"FileTime") [String -> Include
includeStd String
"QFileDevice"]
  [ String
"FileAccessTime"
  , String
"FileBirthTime"
  , String
"FileMetadataChangeTime"
  , String
"FileModificationTime"
  ]

e_MemoryMapFlags :: CppEnum
e_MemoryMapFlags =
  Identifier -> [Include] -> [String] -> CppEnum
makeQtEnum (String -> String -> Identifier
ident1 String
"QFileDevice" String
"MemoryMapFlags") [String -> Include
includeStd String
"QFileDevice"] ([String] -> CppEnum) -> [String] -> CppEnum
forall a b. (a -> b) -> a -> b
$
  [Filtered String] -> [String]
forall a. [Filtered a] -> [a]
collect
  [ String -> Filtered String
forall a. a -> Filtered a
just String
"NoOptions"
  , Bool -> String -> Filtered String
forall a. Bool -> a -> Filtered a
test (Version
qtVersion Version -> Version -> Bool
forall a. Ord a => a -> a -> Bool
>= [Int
5, Int
4]) String
"MapPrivateOption"
  ]

(CppEnum
e_Permission, Flags
fl_Permissions) =
  Identifier -> String -> [Include] -> [String] -> (CppEnum, Flags)
makeQtEnumAndFlags (String -> String -> Identifier
ident1 String
"QFileDevice" String
"Permission") String
"Permissions" [String -> Include
includeStd String
"QFileDevice"]
  [ String
"ReadOwner"
  , String
"WriteOwner"
  , String
"ExeOwner"
  , String
"ReadUser"
  , String
"WriteUser"
  , String
"ExeUser"
  , String
"ReadGroup"
  , String
"WriteGroup"
  , String
"ExeGroup"
  , String
"ReadOther"
  , String
"WriteOther"
  , String
"ExeOther"
  ]