/usr/share/doc/libghc-tokyocabinet-doc/html/src/Database-TokyoCabinet-TDB.html is in libghc-tokyocabinet-doc 0.0.5-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<!-- Generated by HsColour, http://code.haskell.org/~malcolm/hscolour/ -->
<title>Database/TokyoCabinet/TDB.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>-- | Interface to the table database. See also,</span>
<a name="line-2"></a><span class='hs-comment'>-- <<a href="http://tokyocabinet.sourceforge.net/spex-en.html#tctdbapi">http://tokyocabinet.sourceforge.net/spex-en.html#tctdbapi</a>> for details</span>
<a name="line-3"></a><span class='hs-keyword'>module</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>TDB</span>
<a name="line-4"></a> <span class='hs-layout'>(</span>
<a name="line-5"></a> <span class='hs-comment'>-- $doc</span>
<a name="line-6"></a> <span class='hs-conid'>TDB</span>
<a name="line-7"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>ECODE</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-8"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>OpenMode</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-9"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>TuningOption</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-10"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>IndexType</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-11"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>AssocList</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-12"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>new</span>
<a name="line-13"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>delete</span>
<a name="line-14"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>ecode</span>
<a name="line-15"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>errmsg</span>
<a name="line-16"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>tune</span>
<a name="line-17"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>setcache</span>
<a name="line-18"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>setxmsiz</span>
<a name="line-19"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>open</span>
<a name="line-20"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>close</span>
<a name="line-21"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>put</span>
<a name="line-22"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>put'</span>
<a name="line-23"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>putkeep</span>
<a name="line-24"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>putkeep'</span>
<a name="line-25"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>putcat</span>
<a name="line-26"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>putcat'</span>
<a name="line-27"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>out</span>
<a name="line-28"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>get</span>
<a name="line-29"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>get'</span>
<a name="line-30"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>vsiz</span>
<a name="line-31"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>iterinit</span>
<a name="line-32"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>iternext</span>
<a name="line-33"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fwmkeys</span>
<a name="line-34"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>addint</span>
<a name="line-35"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>adddouble</span>
<a name="line-36"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>sync</span>
<a name="line-37"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>optimize</span>
<a name="line-38"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>vanish</span>
<a name="line-39"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>copy</span>
<a name="line-40"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>tranbegin</span>
<a name="line-41"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>trancommit</span>
<a name="line-42"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>tranabort</span>
<a name="line-43"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>path</span>
<a name="line-44"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>rnum</span>
<a name="line-45"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>fsiz</span>
<a name="line-46"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>setindex</span>
<a name="line-47"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>genuid</span>
<a name="line-48"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-49"></a>
<a name="line-50"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>Map</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span>
<a name="line-51"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>TDB</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span>
<a name="line-52"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>Error</span>
<a name="line-53"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>Internal</span>
<a name="line-54"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>Storable</span>
<a name="line-55"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>Associative</span>
<a name="line-56"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Database</span><span class='hs-varop'>.</span><span class='hs-conid'>TokyoCabinet</span><span class='hs-varop'>.</span><span class='hs-conid'>Sequence</span>
<a name="line-57"></a>
<a name="line-58"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Int</span>
<a name="line-59"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Data</span><span class='hs-varop'>.</span><span class='hs-conid'>Word</span>
<a name="line-60"></a>
<a name="line-61"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Ptr</span>
<a name="line-62"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>ForeignPtr</span>
<a name="line-63"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>Types</span>
<a name="line-64"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span><span class='hs-varop'>.</span><span class='hs-conid'>String</span>
<a name="line-65"></a>
<a name="line-66"></a><span class='hs-comment'>-- $doc</span>
<a name="line-67"></a><span class='hs-comment'>-- Example</span>
<a name="line-68"></a><span class='hs-comment'>--</span>
<a name="line-69"></a><span class='hs-comment'>-- @</span>
<a name="line-70"></a><span class='hs-comment'>-- import Control.Monad (unless)</span>
<a name="line-71"></a><span class='hs-comment'>-- import Database.TokyoCabinet.TDB</span>
<a name="line-72"></a><span class='hs-comment'>-- import Database.TokyoCabinet.TDB.Query hiding (new)</span>
<a name="line-73"></a><span class='hs-comment'>-- import qualified Database.TokyoCabinet.Map as M</span>
<a name="line-74"></a><span class='hs-comment'>-- import qualified Database.TokyoCabinet.TDB.Query as Q (new)</span>
<a name="line-75"></a><span class='hs-comment'>-- @</span>
<a name="line-76"></a><span class='hs-comment'>--</span>
<a name="line-77"></a><span class='hs-comment'>-- @</span>
<a name="line-78"></a><span class='hs-comment'>-- data Profile = Profile { name :: String</span>
<a name="line-79"></a><span class='hs-comment'>-- , age :: Int } deriving Show</span>
<a name="line-80"></a><span class='hs-comment'>-- @</span>
<a name="line-81"></a><span class='hs-comment'>--</span>
<a name="line-82"></a><span class='hs-comment'>-- @</span>
<a name="line-83"></a><span class='hs-comment'>-- insertProfile :: TDB -> Profile -> IO Bool</span>
<a name="line-84"></a><span class='hs-comment'>-- insertProfile tdb profile =</span>
<a name="line-85"></a><span class='hs-comment'>-- do m <- M.new</span>
<a name="line-86"></a><span class='hs-comment'>-- M.put m \"name\" (name profile)</span>
<a name="line-87"></a><span class='hs-comment'>-- M.put m \"age\" (show . age $ profile)</span>
<a name="line-88"></a><span class='hs-comment'>-- Just pk <- genuid tdb</span>
<a name="line-89"></a><span class='hs-comment'>-- put tdb (show pk) m</span>
<a name="line-90"></a><span class='hs-comment'>-- @</span>
<a name="line-91"></a><span class='hs-comment'>--</span>
<a name="line-92"></a><span class='hs-comment'>-- @</span>
<a name="line-93"></a><span class='hs-comment'>-- main :: IO ()</span>
<a name="line-94"></a><span class='hs-comment'>-- main = do t <- new</span>
<a name="line-95"></a><span class='hs-comment'>-- open t \"foo.tct\" [OWRITER, OCREAT] >>= err t</span>
<a name="line-96"></a><span class='hs-comment'>-- @</span>
<a name="line-97"></a><span class='hs-comment'>--</span>
<a name="line-98"></a><span class='hs-comment'>-- @</span>
<a name="line-99"></a><span class='hs-comment'>-- mapM_ (insertProfile t) [ Profile \"tom\" 23</span>
<a name="line-100"></a><span class='hs-comment'>-- , Profile \"bob\" 24</span>
<a name="line-101"></a><span class='hs-comment'>-- , Profile \"alice\" 20 ]</span>
<a name="line-102"></a><span class='hs-comment'>-- @</span>
<a name="line-103"></a><span class='hs-comment'>--</span>
<a name="line-104"></a><span class='hs-comment'>-- @</span>
<a name="line-105"></a><span class='hs-comment'>-- q <- Q.new t</span>
<a name="line-106"></a><span class='hs-comment'>-- addcond q \"age\" QCNUMGE \"23\"</span>
<a name="line-107"></a><span class='hs-comment'>-- setorder q \"name\" QOSTRASC</span>
<a name="line-108"></a><span class='hs-comment'>-- proc q $ \pk cols -> do</span>
<a name="line-109"></a><span class='hs-comment'>-- Just name <- M.get cols \"name\"</span>
<a name="line-110"></a><span class='hs-comment'>-- putStrLn name</span>
<a name="line-111"></a><span class='hs-comment'>-- M.put cols \"name\" (name ++ \"!\")</span>
<a name="line-112"></a><span class='hs-comment'>-- return (QPPUT cols)</span>
<a name="line-113"></a><span class='hs-comment'>-- @</span>
<a name="line-114"></a><span class='hs-comment'>--</span>
<a name="line-115"></a><span class='hs-comment'>-- @</span>
<a name="line-116"></a><span class='hs-comment'>-- close t >>= err t</span>
<a name="line-117"></a><span class='hs-comment'>-- return ()</span>
<a name="line-118"></a><span class='hs-comment'>-- where</span>
<a name="line-119"></a><span class='hs-comment'>-- err tdb = flip unless $ ecode tdb >>= error . show</span>
<a name="line-120"></a><span class='hs-comment'>-- @</span>
<a name="line-121"></a><span class='hs-comment'>--</span>
<a name="line-122"></a>
<a name="line-123"></a><a name="new"></a><span class='hs-comment'>-- | Create the new table database object.</span>
<a name="line-124"></a><span class='hs-definition'>new</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>IO</span> <span class='hs-conid'>TDB</span>
<a name="line-125"></a><span class='hs-definition'>new</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>TDB</span> <span class='hs-varop'>`fmap`</span> <span class='hs-layout'>(</span><span class='hs-varid'>c_tctdbnew</span> <span class='hs-varop'>>>=</span> <span class='hs-varid'>newForeignPtr</span> <span class='hs-varid'>tctdbFinalizer</span><span class='hs-layout'>)</span>
<a name="line-126"></a>
<a name="line-127"></a><a name="delete"></a><span class='hs-comment'>-- | Free object resource forcibly.</span>
<a name="line-128"></a><span class='hs-definition'>delete</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-129"></a><span class='hs-definition'>delete</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>finalizeForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span>
<a name="line-130"></a>
<a name="line-131"></a><a name="ecode"></a><span class='hs-comment'>-- | Get the last happened error code.</span>
<a name="line-132"></a><span class='hs-definition'>ecode</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>ECODE</span>
<a name="line-133"></a><span class='hs-definition'>ecode</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cintToError</span> <span class='hs-varop'>`fmap`</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbecode</span>
<a name="line-134"></a>
<a name="line-135"></a><a name="tune"></a><span class='hs-comment'>-- | Set the tuning parameters.</span>
<a name="line-136"></a><span class='hs-definition'>tune</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-comment'>-- ^ TDB object</span>
<a name="line-137"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int64</span> <span class='hs-comment'>-- ^ the number of elements of the bucket array</span>
<a name="line-138"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int8</span> <span class='hs-comment'>-- ^ the size of record alignment by power of 2</span>
<a name="line-139"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int8</span> <span class='hs-comment'>-- ^ the maximum number of elements of the free block pool by power of 2</span>
<a name="line-140"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>TuningOption</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ options</span>
<a name="line-141"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span> <span class='hs-comment'>-- ^ if successful, the return value is True.</span>
<a name="line-142"></a><span class='hs-definition'>tune</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>bnum</span> <span class='hs-varid'>apow</span> <span class='hs-varid'>fpow</span> <span class='hs-varid'>opts</span> <span class='hs-keyglyph'>=</span>
<a name="line-143"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span>
<a name="line-144"></a> <span class='hs-varid'>c_tctdbtune</span> <span class='hs-varid'>tdb'</span> <span class='hs-varid'>bnum</span> <span class='hs-varid'>apow</span> <span class='hs-varid'>fpow</span> <span class='hs-layout'>(</span><span class='hs-varid'>combineTuningOption</span> <span class='hs-varid'>opts</span><span class='hs-layout'>)</span>
<a name="line-145"></a>
<a name="line-146"></a><a name="setcache"></a><span class='hs-comment'>-- | Set the caching parameters of a table database object.</span>
<a name="line-147"></a><span class='hs-definition'>setcache</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-comment'>-- ^ TDB object</span>
<a name="line-148"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int32</span> <span class='hs-comment'>-- ^ the maximum number of records to be cached</span>
<a name="line-149"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int32</span> <span class='hs-comment'>-- ^ the maximum number of leaf nodes to be cached</span>
<a name="line-150"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int32</span> <span class='hs-comment'>-- ^ the maximum number of non-leaf nodes to be cached</span>
<a name="line-151"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span> <span class='hs-comment'>-- ^ if successful, the return value is True.</span>
<a name="line-152"></a><span class='hs-definition'>setcache</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>rcnum</span> <span class='hs-varid'>lcnum</span> <span class='hs-varid'>ncnum</span> <span class='hs-keyglyph'>=</span>
<a name="line-153"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span>
<a name="line-154"></a> <span class='hs-varid'>c_tctdbsetcache</span> <span class='hs-varid'>tdb'</span> <span class='hs-varid'>rcnum</span> <span class='hs-varid'>lcnum</span> <span class='hs-varid'>ncnum</span>
<a name="line-155"></a>
<a name="line-156"></a><a name="setxmsiz"></a><span class='hs-comment'>-- | Set the size of the extra mapped memory of a table database object.</span>
<a name="line-157"></a><span class='hs-definition'>setxmsiz</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-comment'>-- ^ TDB object</span>
<a name="line-158"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int64</span> <span class='hs-comment'>-- ^ the size of the extra mapped memory</span>
<a name="line-159"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span> <span class='hs-comment'>-- ^ if successful, the return value is True.</span>
<a name="line-160"></a><span class='hs-definition'>setxmsiz</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>xmsiz</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-layout'>(</span><span class='hs-varid'>flip</span> <span class='hs-varid'>c_tctdbsetxmsiz</span> <span class='hs-varid'>xmsiz</span><span class='hs-layout'>)</span>
<a name="line-161"></a>
<a name="line-162"></a><a name="open"></a><span class='hs-comment'>-- | Open the table database file</span>
<a name="line-163"></a><span class='hs-definition'>open</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>OpenMode</span><span class='hs-keyglyph'>]</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-164"></a><span class='hs-definition'>open</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>openHelper</span> <span class='hs-varid'>c_tctdbopen</span> <span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>combineOpenMode</span>
<a name="line-165"></a>
<a name="line-166"></a><a name="close"></a><span class='hs-comment'>-- | Open the database file</span>
<a name="line-167"></a><span class='hs-definition'>close</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-168"></a><span class='hs-definition'>close</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbclose</span>
<a name="line-169"></a>
<a name="line-170"></a><a name="FunPut'"></a><span class='hs-keyword'>type</span> <span class='hs-conid'>FunPut'</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>TDB'</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>Word8</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CInt</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Ptr</span> <span class='hs-conid'>MAP</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-171"></a><a name="putHelper'"></a><span class='hs-definition'>putHelper'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>,</span> <span class='hs-conid'>Associative</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span>
<a name="line-172"></a> <span class='hs-conid'>FunPut'</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>k</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-173"></a><span class='hs-definition'>putHelper'</span> <span class='hs-varid'>c_putfunc</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>key</span> <span class='hs-varid'>vals</span> <span class='hs-keyglyph'>=</span>
<a name="line-174"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span>
<a name="line-175"></a> <span class='hs-varid'>withPtrLen</span> <span class='hs-varid'>key</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>kbuf</span><span class='hs-layout'>,</span> <span class='hs-varid'>ksize</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span>
<a name="line-176"></a> <span class='hs-varid'>withMap</span> <span class='hs-varid'>vals</span> <span class='hs-varop'>$</span> <span class='hs-varid'>c_putfunc</span> <span class='hs-varid'>tdb'</span> <span class='hs-varid'>kbuf</span> <span class='hs-varid'>ksize</span>
<a name="line-177"></a>
<a name="line-178"></a><a name="put"></a><span class='hs-comment'>-- | Store a record into a table database object.</span>
<a name="line-179"></a><span class='hs-definition'>put</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>,</span> <span class='hs-conid'>Associative</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>k</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-180"></a><span class='hs-definition'>put</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>putHelper'</span> <span class='hs-varid'>c_tctdbput</span>
<a name="line-181"></a>
<a name="line-182"></a><a name="put'"></a><span class='hs-comment'>-- | Store a string record into a table database object with a zero</span>
<a name="line-183"></a><span class='hs-comment'>-- separated column string.</span>
<a name="line-184"></a><span class='hs-definition'>put'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-185"></a><span class='hs-definition'>put'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>putHelper</span> <span class='hs-varid'>c_tctdbput2</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-186"></a>
<a name="line-187"></a><a name="putkeep"></a><span class='hs-comment'>-- | Store a new record into a table database object.</span>
<a name="line-188"></a><span class='hs-definition'>putkeep</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>,</span> <span class='hs-conid'>Associative</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>k</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-189"></a><span class='hs-definition'>putkeep</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>putHelper'</span> <span class='hs-varid'>c_tctdbputkeep</span>
<a name="line-190"></a>
<a name="line-191"></a><a name="putkeep'"></a><span class='hs-comment'>-- | Store a new string record into a table database object with a</span>
<a name="line-192"></a><span class='hs-comment'>-- zero separated column string.</span>
<a name="line-193"></a><span class='hs-definition'>putkeep'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-194"></a><span class='hs-definition'>putkeep'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>putHelper</span> <span class='hs-varid'>c_tctdbputkeep2</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-195"></a>
<a name="line-196"></a><a name="putcat"></a><span class='hs-comment'>-- | Concatenate columns of the existing record in a table database object.</span>
<a name="line-197"></a><span class='hs-definition'>putcat</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>,</span> <span class='hs-conid'>Associative</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>m</span> <span class='hs-varid'>k</span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-198"></a><span class='hs-definition'>putcat</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>putHelper'</span> <span class='hs-varid'>c_tctdbputcat</span>
<a name="line-199"></a>
<a name="line-200"></a><a name="putcat'"></a><span class='hs-comment'>-- | Concatenate columns in a table database object with a zero</span>
<a name="line-201"></a><span class='hs-comment'>-- separated column string.</span>
<a name="line-202"></a><span class='hs-definition'>putcat'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-203"></a><span class='hs-definition'>putcat'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>putHelper</span> <span class='hs-varid'>c_tctdbputcat2</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-204"></a>
<a name="line-205"></a><a name="out"></a><span class='hs-comment'>-- | Remove a record of a table database object.</span>
<a name="line-206"></a><span class='hs-definition'>out</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-207"></a><span class='hs-definition'>out</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>outHelper</span> <span class='hs-varid'>c_tctdbout</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-208"></a>
<a name="line-209"></a><a name="get"></a><span class='hs-comment'>-- | Retrieve a record in a table database object.</span>
<a name="line-210"></a><span class='hs-definition'>get</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>,</span> <span class='hs-conid'>Associative</span> <span class='hs-varid'>m</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-varid'>m</span> <span class='hs-varid'>k</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span>
<a name="line-211"></a><span class='hs-definition'>get</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>key</span> <span class='hs-keyglyph'>=</span>
<a name="line-212"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span>
<a name="line-213"></a> <span class='hs-varid'>withPtrLen</span> <span class='hs-varid'>key</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>kbuf</span><span class='hs-layout'>,</span> <span class='hs-varid'>ksize</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span>
<a name="line-214"></a> <span class='hs-varid'>c_tctdbget</span> <span class='hs-varid'>tdb'</span> <span class='hs-varid'>kbuf</span> <span class='hs-varid'>ksize</span> <span class='hs-varop'>>>=</span> <span class='hs-varid'>peekMap'</span>
<a name="line-215"></a>
<a name="line-216"></a><a name="get'"></a><span class='hs-comment'>-- | Retrieve a record in a table database object as a zero separated</span>
<a name="line-217"></a><span class='hs-comment'>-- column string.</span>
<a name="line-218"></a><span class='hs-definition'>get'</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-varid'>v</span><span class='hs-layout'>)</span>
<a name="line-219"></a><span class='hs-definition'>get'</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>getHelper</span> <span class='hs-varid'>c_tctdbget2</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-220"></a>
<a name="line-221"></a><a name="vsiz"></a><span class='hs-comment'>-- | Get the size of the value of a record in a table database object.</span>
<a name="line-222"></a><span class='hs-definition'>vsiz</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>Int</span><span class='hs-layout'>)</span>
<a name="line-223"></a><span class='hs-definition'>vsiz</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>vsizHelper</span> <span class='hs-varid'>c_tctdbvsiz</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-224"></a>
<a name="line-225"></a><a name="iterinit"></a><span class='hs-comment'>-- | Initialize the iterator of a table database object.</span>
<a name="line-226"></a><span class='hs-definition'>iterinit</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-227"></a><span class='hs-definition'>iterinit</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbiterinit</span>
<a name="line-228"></a>
<a name="line-229"></a><a name="iternext"></a><span class='hs-comment'>-- | Get the next primary key of the iterator of a table database object.</span>
<a name="line-230"></a><span class='hs-definition'>iternext</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span>
<a name="line-231"></a><span class='hs-definition'>iternext</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>iternextHelper</span> <span class='hs-varid'>c_tctdbiternext</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-232"></a>
<a name="line-233"></a><a name="fwmkeys"></a><span class='hs-comment'>-- | Get forward matching primary keys in a table database object.</span>
<a name="line-234"></a><span class='hs-definition'>fwmkeys</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k1</span><span class='hs-layout'>,</span> <span class='hs-conid'>Storable</span> <span class='hs-varid'>k2</span><span class='hs-layout'>,</span> <span class='hs-conid'>Sequence</span> <span class='hs-varid'>q</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k1</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-varid'>q</span> <span class='hs-varid'>k2</span><span class='hs-layout'>)</span>
<a name="line-235"></a><span class='hs-definition'>fwmkeys</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>fwmHelper</span> <span class='hs-varid'>c_tctdbfwmkeys</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-236"></a>
<a name="line-237"></a><a name="addint"></a><span class='hs-comment'>-- | Add an integer to a column of a record in a table database object.</span>
<a name="line-238"></a><span class='hs-definition'>addint</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>Int</span><span class='hs-layout'>)</span>
<a name="line-239"></a><span class='hs-definition'>addint</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addHelper</span> <span class='hs-varid'>c_tctdbaddint</span> <span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-layout'>(</span><span class='hs-varop'>==</span> <span class='hs-varid'>cINT_MIN</span><span class='hs-layout'>)</span>
<a name="line-240"></a>
<a name="line-241"></a><a name="adddouble"></a><span class='hs-comment'>-- | Add a real number to a column of a record in a table database object.</span>
<a name="line-242"></a><span class='hs-definition'>adddouble</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>Storable</span> <span class='hs-varid'>k</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=></span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Double</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>Double</span><span class='hs-layout'>)</span>
<a name="line-243"></a><span class='hs-definition'>adddouble</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>addHelper</span> <span class='hs-varid'>c_tctdbadddouble</span> <span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>realToFrac</span> <span class='hs-varid'>realToFrac</span> <span class='hs-varid'>isNaN</span>
<a name="line-244"></a>
<a name="line-245"></a><a name="sync"></a><span class='hs-comment'>-- | Synchronize updated contents of a table database object with the</span>
<a name="line-246"></a><span class='hs-comment'>-- file and the device.</span>
<a name="line-247"></a><span class='hs-definition'>sync</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-248"></a><span class='hs-definition'>sync</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbsync</span>
<a name="line-249"></a>
<a name="line-250"></a><a name="optimize"></a><span class='hs-comment'>-- | Optimize the file of a table database object.</span>
<a name="line-251"></a><span class='hs-definition'>optimize</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-comment'>-- ^ TDB object </span>
<a name="line-252"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int64</span> <span class='hs-comment'>-- ^ the number of elements of the bucket array </span>
<a name="line-253"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int8</span> <span class='hs-comment'>-- ^ the size of record alignment by power of 2 </span>
<a name="line-254"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>Int8</span> <span class='hs-comment'>-- ^ the maximum number of elements of the free block pool by power of 2</span>
<a name="line-255"></a> <span class='hs-keyglyph'>-></span> <span class='hs-keyglyph'>[</span><span class='hs-conid'>TuningOption</span><span class='hs-keyglyph'>]</span> <span class='hs-comment'>-- ^ options</span>
<a name="line-256"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span> <span class='hs-comment'>-- ^ if successful, the return value is True.</span>
<a name="line-257"></a><span class='hs-definition'>optimize</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>bnum</span> <span class='hs-varid'>apow</span> <span class='hs-varid'>fpow</span> <span class='hs-varid'>opts</span> <span class='hs-keyglyph'>=</span>
<a name="line-258"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span>
<a name="line-259"></a> <span class='hs-varid'>c_tctdboptimize</span> <span class='hs-varid'>tdb'</span> <span class='hs-varid'>bnum</span> <span class='hs-varid'>apow</span> <span class='hs-varid'>fpow</span> <span class='hs-layout'>(</span><span class='hs-varid'>combineTuningOption</span> <span class='hs-varid'>opts</span><span class='hs-layout'>)</span>
<a name="line-260"></a>
<a name="line-261"></a><a name="vanish"></a><span class='hs-comment'>-- | Remove all records of a table database object.</span>
<a name="line-262"></a><span class='hs-definition'>vanish</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-263"></a><span class='hs-definition'>vanish</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbvanish</span>
<a name="line-264"></a>
<a name="line-265"></a><a name="copy"></a><span class='hs-comment'>-- | Copy the database file of a table database object.</span>
<a name="line-266"></a><span class='hs-definition'>copy</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-comment'>-- ^ TDB object</span>
<a name="line-267"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-comment'>-- ^ new file path</span>
<a name="line-268"></a> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span> <span class='hs-comment'>-- ^ if successful, the return value is True</span>
<a name="line-269"></a><span class='hs-definition'>copy</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>copyHelper</span> <span class='hs-varid'>c_tctdbcopy</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-270"></a>
<a name="line-271"></a><a name="tranbegin"></a><span class='hs-comment'>-- | Begin the transaction of a table database object.</span>
<a name="line-272"></a><span class='hs-definition'>tranbegin</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-273"></a><span class='hs-definition'>tranbegin</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbtranbegin</span>
<a name="line-274"></a>
<a name="line-275"></a><a name="trancommit"></a><span class='hs-comment'>-- | Commit the transaction of a table database object.</span>
<a name="line-276"></a><span class='hs-definition'>trancommit</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-277"></a><span class='hs-definition'>trancommit</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbtrancommit</span>
<a name="line-278"></a>
<a name="line-279"></a><a name="tranabort"></a><span class='hs-comment'>-- | Abort the transaction of a table database object.</span>
<a name="line-280"></a><span class='hs-definition'>tranabort</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-281"></a><span class='hs-definition'>tranabort</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbtranabort</span>
<a name="line-282"></a>
<a name="line-283"></a><a name="path"></a><span class='hs-comment'>-- | Get the file path of a table database object.</span>
<a name="line-284"></a><span class='hs-definition'>path</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>String</span><span class='hs-layout'>)</span>
<a name="line-285"></a><span class='hs-definition'>path</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>pathHelper</span> <span class='hs-varid'>c_tctdbpath</span> <span class='hs-varid'>unTCTDB</span>
<a name="line-286"></a>
<a name="line-287"></a><a name="rnum"></a><span class='hs-comment'>-- | Get the number of records of a table database object.</span>
<a name="line-288"></a><span class='hs-definition'>rnum</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Word64</span>
<a name="line-289"></a><span class='hs-definition'>rnum</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbrnum</span>
<a name="line-290"></a>
<a name="line-291"></a><a name="fsiz"></a><span class='hs-comment'>-- | Get the size of the database file of a table database object.</span>
<a name="line-292"></a><span class='hs-definition'>fsiz</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Word64</span>
<a name="line-293"></a><span class='hs-definition'>fsiz</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tctdbfsiz</span>
<a name="line-294"></a>
<a name="line-295"></a><a name="setindex"></a><span class='hs-comment'>-- | Set a column index to a table database object.</span>
<a name="line-296"></a><span class='hs-definition'>setindex</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>String</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IndexType</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-297"></a><span class='hs-definition'>setindex</span> <span class='hs-varid'>tdb</span> <span class='hs-varid'>name</span> <span class='hs-varid'>itype</span> <span class='hs-keyglyph'>=</span>
<a name="line-298"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span>
<a name="line-299"></a> <span class='hs-varid'>withCString</span> <span class='hs-varid'>name</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>c_name</span> <span class='hs-keyglyph'>-></span>
<a name="line-300"></a> <span class='hs-varid'>c_tctdbsetindex</span> <span class='hs-varid'>tdb'</span> <span class='hs-varid'>c_name</span> <span class='hs-layout'>(</span><span class='hs-varid'>indexTypeToCInt</span> <span class='hs-varid'>itype</span><span class='hs-layout'>)</span>
<a name="line-301"></a>
<a name="line-302"></a><a name="genuid"></a><span class='hs-comment'>-- | Generate a unique ID number of a table database object.</span>
<a name="line-303"></a><span class='hs-definition'>genuid</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>TDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-layout'>(</span><span class='hs-conid'>Maybe</span> <span class='hs-conid'>Int64</span><span class='hs-layout'>)</span>
<a name="line-304"></a><span class='hs-definition'>genuid</span> <span class='hs-varid'>tdb</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCTDB</span> <span class='hs-varid'>tdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>tdb'</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
<a name="line-305"></a> <span class='hs-varid'>uid</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_tctdbgenuid</span> <span class='hs-varid'>tdb'</span>
<a name="line-306"></a> <span class='hs-varid'>return</span> <span class='hs-varop'>$</span> <span class='hs-keyword'>if</span> <span class='hs-varid'>uid</span> <span class='hs-varop'>==</span> <span class='hs-layout'>(</span><span class='hs-comment'>-</span><span class='hs-num'>1</span><span class='hs-layout'>)</span> <span class='hs-keyword'>then</span> <span class='hs-conid'>Nothing</span> <span class='hs-keyword'>else</span> <span class='hs-conid'>Just</span> <span class='hs-varid'>uid</span>
</pre></body>
</html>
|