{-# LINE 1 "src/Squeather/Internal/Bindings.hsc" #-}
module Squeather.Internal.Bindings where
import Data.Bits ((.|.))
import Data.ByteString (ByteString)
import Data.Int (Int64)
import Data.Text (Text)
import Foreign.C.Types (CInt)
import Squeather.Internal.Types
data ParseErrorResult
= ParseErrorOk
| ParseErrorStep StepResult
| ParseErrorError ErrorFlag
| ParseErrorNotFound
deriving (Eq, Ord, Show)
parseError :: (Integral a, Show a) => a -> ParseErrorResult
parseError n = case n of
0 -> ParseErrorOk
{-# LINE 27 "src/Squeather/Internal/Bindings.hsc" #-}
100 -> ParseErrorStep Row
{-# LINE 28 "src/Squeather/Internal/Bindings.hsc" #-}
101 -> ParseErrorStep Done
{-# LINE 29 "src/Squeather/Internal/Bindings.hsc" #-}
1 -> ParseErrorError SQLITE_ERROR
{-# LINE 30 "src/Squeather/Internal/Bindings.hsc" #-}
2 -> ParseErrorError SQLITE_INTERNAL
{-# LINE 31 "src/Squeather/Internal/Bindings.hsc" #-}
3 -> ParseErrorError SQLITE_PERM
{-# LINE 32 "src/Squeather/Internal/Bindings.hsc" #-}
4 -> ParseErrorError SQLITE_ABORT
{-# LINE 33 "src/Squeather/Internal/Bindings.hsc" #-}
5 -> ParseErrorError SQLITE_BUSY
{-# LINE 34 "src/Squeather/Internal/Bindings.hsc" #-}
6 -> ParseErrorError SQLITE_LOCKED
{-# LINE 35 "src/Squeather/Internal/Bindings.hsc" #-}
7 -> ParseErrorError SQLITE_NOMEM
{-# LINE 36 "src/Squeather/Internal/Bindings.hsc" #-}
8 -> ParseErrorError SQLITE_READONLY
{-# LINE 37 "src/Squeather/Internal/Bindings.hsc" #-}
9 -> ParseErrorError SQLITE_INTERRUPT
{-# LINE 38 "src/Squeather/Internal/Bindings.hsc" #-}
10 -> ParseErrorError SQLITE_IOERR
{-# LINE 39 "src/Squeather/Internal/Bindings.hsc" #-}
11 -> ParseErrorError SQLITE_CORRUPT
{-# LINE 40 "src/Squeather/Internal/Bindings.hsc" #-}
12 -> ParseErrorError SQLITE_NOTFOUND
{-# LINE 41 "src/Squeather/Internal/Bindings.hsc" #-}
13 -> ParseErrorError SQLITE_FULL
{-# LINE 42 "src/Squeather/Internal/Bindings.hsc" #-}
14 -> ParseErrorError SQLITE_CANTOPEN
{-# LINE 43 "src/Squeather/Internal/Bindings.hsc" #-}
15 -> ParseErrorError SQLITE_PROTOCOL
{-# LINE 44 "src/Squeather/Internal/Bindings.hsc" #-}
16 -> ParseErrorError SQLITE_EMPTY
{-# LINE 45 "src/Squeather/Internal/Bindings.hsc" #-}
17 -> ParseErrorError SQLITE_SCHEMA
{-# LINE 46 "src/Squeather/Internal/Bindings.hsc" #-}
18 -> ParseErrorError SQLITE_TOOBIG
{-# LINE 47 "src/Squeather/Internal/Bindings.hsc" #-}
19 -> ParseErrorError SQLITE_CONSTRAINT
{-# LINE 48 "src/Squeather/Internal/Bindings.hsc" #-}
20 -> ParseErrorError SQLITE_MISMATCH
{-# LINE 49 "src/Squeather/Internal/Bindings.hsc" #-}
21 -> ParseErrorError SQLITE_MISUSE
{-# LINE 50 "src/Squeather/Internal/Bindings.hsc" #-}
22 -> ParseErrorError SQLITE_NOLFS
{-# LINE 51 "src/Squeather/Internal/Bindings.hsc" #-}
23 -> ParseErrorError SQLITE_AUTH
{-# LINE 52 "src/Squeather/Internal/Bindings.hsc" #-}
24 -> ParseErrorError SQLITE_FORMAT
{-# LINE 53 "src/Squeather/Internal/Bindings.hsc" #-}
25 -> ParseErrorError SQLITE_RANGE
{-# LINE 54 "src/Squeather/Internal/Bindings.hsc" #-}
26 -> ParseErrorError SQLITE_NOTADB
{-# LINE 55 "src/Squeather/Internal/Bindings.hsc" #-}
27 -> ParseErrorError SQLITE_NOTICE
{-# LINE 56 "src/Squeather/Internal/Bindings.hsc" #-}
28 -> ParseErrorError SQLITE_WARNING
{-# LINE 57 "src/Squeather/Internal/Bindings.hsc" #-}
257 -> ParseErrorError SQLITE_ERROR_MISSING_COLLSEQ
{-# LINE 58 "src/Squeather/Internal/Bindings.hsc" #-}
513 -> ParseErrorError SQLITE_ERROR_RETRY
{-# LINE 59 "src/Squeather/Internal/Bindings.hsc" #-}
769 -> ParseErrorError SQLITE_ERROR_SNAPSHOT
{-# LINE 60 "src/Squeather/Internal/Bindings.hsc" #-}
266 -> ParseErrorError SQLITE_IOERR_READ
{-# LINE 61 "src/Squeather/Internal/Bindings.hsc" #-}
522 -> ParseErrorError SQLITE_IOERR_SHORT_READ
{-# LINE 62 "src/Squeather/Internal/Bindings.hsc" #-}
778 -> ParseErrorError SQLITE_IOERR_WRITE
{-# LINE 63 "src/Squeather/Internal/Bindings.hsc" #-}
1034 -> ParseErrorError SQLITE_IOERR_FSYNC
{-# LINE 64 "src/Squeather/Internal/Bindings.hsc" #-}
1290 -> ParseErrorError SQLITE_IOERR_DIR_FSYNC
{-# LINE 65 "src/Squeather/Internal/Bindings.hsc" #-}
1546 -> ParseErrorError SQLITE_IOERR_TRUNCATE
{-# LINE 66 "src/Squeather/Internal/Bindings.hsc" #-}
1802 -> ParseErrorError SQLITE_IOERR_FSTAT
{-# LINE 67 "src/Squeather/Internal/Bindings.hsc" #-}
2058 -> ParseErrorError SQLITE_IOERR_UNLOCK
{-# LINE 68 "src/Squeather/Internal/Bindings.hsc" #-}
2314 -> ParseErrorError SQLITE_IOERR_RDLOCK
{-# LINE 69 "src/Squeather/Internal/Bindings.hsc" #-}
2570 -> ParseErrorError SQLITE_IOERR_DELETE
{-# LINE 70 "src/Squeather/Internal/Bindings.hsc" #-}
2826 -> ParseErrorError SQLITE_IOERR_BLOCKED
{-# LINE 71 "src/Squeather/Internal/Bindings.hsc" #-}
3082 -> ParseErrorError SQLITE_IOERR_NOMEM
{-# LINE 72 "src/Squeather/Internal/Bindings.hsc" #-}
3338 -> ParseErrorError SQLITE_IOERR_ACCESS
{-# LINE 73 "src/Squeather/Internal/Bindings.hsc" #-}
3594 -> ParseErrorError SQLITE_IOERR_CHECKRESERVEDLOCK
{-# LINE 74 "src/Squeather/Internal/Bindings.hsc" #-}
3850 -> ParseErrorError SQLITE_IOERR_LOCK
{-# LINE 75 "src/Squeather/Internal/Bindings.hsc" #-}
4106 -> ParseErrorError SQLITE_IOERR_CLOSE
{-# LINE 76 "src/Squeather/Internal/Bindings.hsc" #-}
4362 -> ParseErrorError SQLITE_IOERR_DIR_CLOSE
{-# LINE 77 "src/Squeather/Internal/Bindings.hsc" #-}
4618 -> ParseErrorError SQLITE_IOERR_SHMOPEN
{-# LINE 78 "src/Squeather/Internal/Bindings.hsc" #-}
4874 -> ParseErrorError SQLITE_IOERR_SHMSIZE
{-# LINE 79 "src/Squeather/Internal/Bindings.hsc" #-}
5130 -> ParseErrorError SQLITE_IOERR_SHMLOCK
{-# LINE 80 "src/Squeather/Internal/Bindings.hsc" #-}
5386 -> ParseErrorError SQLITE_IOERR_SHMMAP
{-# LINE 81 "src/Squeather/Internal/Bindings.hsc" #-}
5642 -> ParseErrorError SQLITE_IOERR_SEEK
{-# LINE 82 "src/Squeather/Internal/Bindings.hsc" #-}
5898 -> ParseErrorError SQLITE_IOERR_DELETE_NOENT
{-# LINE 83 "src/Squeather/Internal/Bindings.hsc" #-}
6154 -> ParseErrorError SQLITE_IOERR_MMAP
{-# LINE 84 "src/Squeather/Internal/Bindings.hsc" #-}
6410 -> ParseErrorError SQLITE_IOERR_GETTEMPPATH
{-# LINE 85 "src/Squeather/Internal/Bindings.hsc" #-}
6666 -> ParseErrorError SQLITE_IOERR_CONVPATH
{-# LINE 86 "src/Squeather/Internal/Bindings.hsc" #-}
6922 -> ParseErrorError SQLITE_IOERR_VNODE
{-# LINE 87 "src/Squeather/Internal/Bindings.hsc" #-}
7178 -> ParseErrorError SQLITE_IOERR_AUTH
{-# LINE 88 "src/Squeather/Internal/Bindings.hsc" #-}
7434 -> ParseErrorError SQLITE_IOERR_BEGIN_ATOMIC
{-# LINE 89 "src/Squeather/Internal/Bindings.hsc" #-}
7690 -> ParseErrorError SQLITE_IOERR_COMMIT_ATOMIC
{-# LINE 90 "src/Squeather/Internal/Bindings.hsc" #-}
7946 -> ParseErrorError SQLITE_IOERR_ROLLBACK_ATOMIC
{-# LINE 91 "src/Squeather/Internal/Bindings.hsc" #-}
262 -> ParseErrorError SQLITE_LOCKED_SHAREDCACHE
{-# LINE 92 "src/Squeather/Internal/Bindings.hsc" #-}
518 -> ParseErrorError SQLITE_LOCKED_VTAB
{-# LINE 93 "src/Squeather/Internal/Bindings.hsc" #-}
261 -> ParseErrorError SQLITE_BUSY_RECOVERY
{-# LINE 94 "src/Squeather/Internal/Bindings.hsc" #-}
517 -> ParseErrorError SQLITE_BUSY_SNAPSHOT
{-# LINE 95 "src/Squeather/Internal/Bindings.hsc" #-}
270 -> ParseErrorError SQLITE_CANTOPEN_NOTEMPDIR
{-# LINE 96 "src/Squeather/Internal/Bindings.hsc" #-}
526 -> ParseErrorError SQLITE_CANTOPEN_ISDIR
{-# LINE 97 "src/Squeather/Internal/Bindings.hsc" #-}
782 -> ParseErrorError SQLITE_CANTOPEN_FULLPATH
{-# LINE 98 "src/Squeather/Internal/Bindings.hsc" #-}
1038 -> ParseErrorError SQLITE_CANTOPEN_CONVPATH
{-# LINE 99 "src/Squeather/Internal/Bindings.hsc" #-}
1294 -> ParseErrorError SQLITE_CANTOPEN_DIRTYWAL
{-# LINE 100 "src/Squeather/Internal/Bindings.hsc" #-}
1550 -> ParseErrorError SQLITE_CANTOPEN_SYMLINK
{-# LINE 101 "src/Squeather/Internal/Bindings.hsc" #-}
267 -> ParseErrorError SQLITE_CORRUPT_VTAB
{-# LINE 102 "src/Squeather/Internal/Bindings.hsc" #-}
523 -> ParseErrorError SQLITE_CORRUPT_SEQUENCE
{-# LINE 103 "src/Squeather/Internal/Bindings.hsc" #-}
264 -> ParseErrorError SQLITE_READONLY_RECOVERY
{-# LINE 104 "src/Squeather/Internal/Bindings.hsc" #-}
520 -> ParseErrorError SQLITE_READONLY_CANTLOCK
{-# LINE 105 "src/Squeather/Internal/Bindings.hsc" #-}
776 -> ParseErrorError SQLITE_READONLY_ROLLBACK
{-# LINE 106 "src/Squeather/Internal/Bindings.hsc" #-}
1032 -> ParseErrorError SQLITE_READONLY_DBMOVED
{-# LINE 107 "src/Squeather/Internal/Bindings.hsc" #-}
1288 -> ParseErrorError SQLITE_READONLY_CANTINIT
{-# LINE 108 "src/Squeather/Internal/Bindings.hsc" #-}
1544 -> ParseErrorError SQLITE_READONLY_DIRECTORY
{-# LINE 109 "src/Squeather/Internal/Bindings.hsc" #-}
516 -> ParseErrorError SQLITE_ABORT_ROLLBACK
{-# LINE 110 "src/Squeather/Internal/Bindings.hsc" #-}
275 -> ParseErrorError SQLITE_CONSTRAINT_CHECK
{-# LINE 111 "src/Squeather/Internal/Bindings.hsc" #-}
531 -> ParseErrorError SQLITE_CONSTRAINT_COMMITHOOK
{-# LINE 112 "src/Squeather/Internal/Bindings.hsc" #-}
787 -> ParseErrorError SQLITE_CONSTRAINT_FOREIGNKEY
{-# LINE 113 "src/Squeather/Internal/Bindings.hsc" #-}
1043 -> ParseErrorError SQLITE_CONSTRAINT_FUNCTION
{-# LINE 114 "src/Squeather/Internal/Bindings.hsc" #-}
1299 -> ParseErrorError SQLITE_CONSTRAINT_NOTNULL
{-# LINE 115 "src/Squeather/Internal/Bindings.hsc" #-}
1555 -> ParseErrorError SQLITE_CONSTRAINT_PRIMARYKEY
{-# LINE 116 "src/Squeather/Internal/Bindings.hsc" #-}
1811 -> ParseErrorError SQLITE_CONSTRAINT_TRIGGER
{-# LINE 117 "src/Squeather/Internal/Bindings.hsc" #-}
2067 -> ParseErrorError SQLITE_CONSTRAINT_UNIQUE
{-# LINE 118 "src/Squeather/Internal/Bindings.hsc" #-}
2323 -> ParseErrorError SQLITE_CONSTRAINT_VTAB
{-# LINE 119 "src/Squeather/Internal/Bindings.hsc" #-}
2579 -> ParseErrorError SQLITE_CONSTRAINT_ROWID
{-# LINE 120 "src/Squeather/Internal/Bindings.hsc" #-}
2835 -> ParseErrorError SQLITE_CONSTRAINT_PINNED
{-# LINE 121 "src/Squeather/Internal/Bindings.hsc" #-}
283 -> ParseErrorError SQLITE_NOTICE_RECOVER_WAL
{-# LINE 122 "src/Squeather/Internal/Bindings.hsc" #-}
539 -> ParseErrorError SQLITE_NOTICE_RECOVER_ROLLBACK
{-# LINE 123 "src/Squeather/Internal/Bindings.hsc" #-}
284 -> ParseErrorError SQLITE_WARNING_AUTOINDEX
{-# LINE 124 "src/Squeather/Internal/Bindings.hsc" #-}
279 -> ParseErrorError SQLITE_AUTH_USER
{-# LINE 125 "src/Squeather/Internal/Bindings.hsc" #-}
256 -> ParseErrorError SQLITE_OK_LOAD_PERMANENTLY
{-# LINE 130 "src/Squeather/Internal/Bindings.hsc" #-}
512 -> ParseErrorError SQLITE_OK_SYMLINK
{-# LINE 131 "src/Squeather/Internal/Bindings.hsc" #-}
_ -> ParseErrorNotFound
c'SQLITE_VERSION :: String
c'SQLITE_VERSION = "3.31.1"
{-# LINE 135 "src/Squeather/Internal/Bindings.hsc" #-}
c'SQLITE_VERSION_NUMBER :: Integral a => a
c'SQLITE_VERSION_NUMBER = 3031001
{-# LINE 138 "src/Squeather/Internal/Bindings.hsc" #-}
c'SQLITE_SOURCE_ID :: String
c'SQLITE_SOURCE_ID = "2020-01-27 19:55:54 3bfa9cc97da10598521b342961df8f5f68c7388fa117345eeb516eaa837bb4d6"
{-# LINE 141 "src/Squeather/Internal/Bindings.hsc" #-}
c'SQLITE_STATIC :: Integral a => a
c'SQLITE_STATIC = 0
{-# LINE 144 "src/Squeather/Internal/Bindings.hsc" #-}
c'SQLITE_TRANSIENT :: Integral a => a
c'SQLITE_TRANSIENT = 18446744073709551615
{-# LINE 147 "src/Squeather/Internal/Bindings.hsc" #-}
data SQLData
= SQLNull
| SQLText Text
| SQLFloat Double
| SQLInteger Int64
| SQLBlob ByteString
deriving (Eq, Ord, Show)
flagsToInt :: OpenFlags -> CInt
flagsToInt (OpenFlags fWrite furi fmemory fthread fcache fnoFollow)
= 0
.|. writeModeToInt fWrite
.|. iff furi 64
{-# LINE 163 "src/Squeather/Internal/Bindings.hsc" #-}
.|. iff fmemory 128
{-# LINE 164 "src/Squeather/Internal/Bindings.hsc" #-}
.|. threadModeToInt fthread
.|. cacheModeToInt fcache
.|. iff fnoFollow 16777216
{-# LINE 167 "src/Squeather/Internal/Bindings.hsc" #-}
where
iff b n = if b then n else 0
cacheModeToInt :: CacheMode -> CInt
cacheModeToInt c = case c of
Shared -> 131072
{-# LINE 173 "src/Squeather/Internal/Bindings.hsc" #-}
Private -> 262144
{-# LINE 174 "src/Squeather/Internal/Bindings.hsc" #-}
threadModeToInt :: ThreadMode -> CInt
threadModeToInt t = case t of
MultiThread -> 32768
{-# LINE 178 "src/Squeather/Internal/Bindings.hsc" #-}
Serialized -> 65536
{-# LINE 179 "src/Squeather/Internal/Bindings.hsc" #-}
writeModeToInt :: WriteMode -> CInt
writeModeToInt w = case w of
ReadOnly -> 1
{-# LINE 183 "src/Squeather/Internal/Bindings.hsc" #-}
ReadWrite c -> 2 .|. case c of
{-# LINE 184 "src/Squeather/Internal/Bindings.hsc" #-}
Create -> 4
{-# LINE 185 "src/Squeather/Internal/Bindings.hsc" #-}
NoCreate -> 0
convertCColumnType :: Integral a => a -> Maybe SQLData
convertCColumnType x = case x of
1 -> Just $ SQLInteger undefined
{-# LINE 193 "src/Squeather/Internal/Bindings.hsc" #-}
2 -> Just $ SQLFloat undefined
{-# LINE 194 "src/Squeather/Internal/Bindings.hsc" #-}
4 -> Just $ SQLBlob undefined
{-# LINE 195 "src/Squeather/Internal/Bindings.hsc" #-}
5 -> Just SQLNull
{-# LINE 196 "src/Squeather/Internal/Bindings.hsc" #-}
3 -> Just $ SQLText undefined
{-# LINE 197 "src/Squeather/Internal/Bindings.hsc" #-}
_ -> Nothing