/usr/share/doc/libghc-tokyocabinet-doc/html/src/Database-TokyoCabinet-BDB-Cursor.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 | <?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/BDB/Cursor.hs</title>
<link type='text/css' rel='stylesheet' href='hscolour.css' />
</head>
<body>
<pre><a name="line-1"></a><span class='hs-comment'>{-# LANGUAGE ForeignFunctionInterface, EmptyDataDecls #-}</span>
<a name="line-2"></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'>BDB</span><span class='hs-varop'>.</span><span class='hs-conid'>Cursor</span>
<a name="line-3"></a> <span class='hs-layout'>(</span>
<a name="line-4"></a> <span class='hs-conid'>CursorPutMode</span><span class='hs-layout'>(</span><span class='hs-keyglyph'>..</span><span class='hs-layout'>)</span>
<a name="line-5"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>new</span>
<a name="line-6"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>delete</span>
<a name="line-7"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>first</span>
<a name="line-8"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>last</span>
<a name="line-9"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>jump</span>
<a name="line-10"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>prev</span>
<a name="line-11"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>next</span>
<a name="line-12"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>put</span>
<a name="line-13"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>out</span>
<a name="line-14"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>key</span>
<a name="line-15"></a> <span class='hs-layout'>,</span> <span class='hs-varid'>val</span>
<a name="line-16"></a> <span class='hs-layout'>,</span> <span class='hs-conid'>BDBCUR</span>
<a name="line-17"></a> <span class='hs-layout'>)</span> <span class='hs-keyword'>where</span>
<a name="line-18"></a>
<a name="line-19"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Prelude</span> <span class='hs-varid'>hiding</span> <span class='hs-layout'>(</span><span class='hs-varid'>last</span><span class='hs-layout'>)</span>
<a name="line-20"></a>
<a name="line-21"></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'>BDB</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span>
<a name="line-22"></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'>BDB</span><span class='hs-varop'>.</span><span class='hs-conid'>Cursor</span><span class='hs-varop'>.</span><span class='hs-conid'>C</span>
<a name="line-23"></a><span class='hs-keyword'>import</span> <span class='hs-keyword'>qualified</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> <span class='hs-keyword'>as</span> <span class='hs-conid'>S</span>
<a name="line-24"></a>
<a name="line-25"></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-26"></a>
<a name="line-27"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Marshal</span> <span class='hs-layout'>(</span><span class='hs-varid'>alloca</span><span class='hs-layout'>)</span>
<a name="line-28"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Storable</span> <span class='hs-layout'>(</span><span class='hs-varid'>peek</span><span class='hs-layout'>)</span>
<a name="line-29"></a><span class='hs-keyword'>import</span> <span class='hs-conid'>Foreign</span><span class='hs-varop'>.</span><span class='hs-conid'>Marshal</span><span class='hs-varop'>.</span><span class='hs-conid'>Utils</span> <span class='hs-layout'>(</span><span class='hs-varid'>maybePeek</span><span class='hs-layout'>)</span>
<a name="line-30"></a>
<a name="line-31"></a><a name="BDBCUR"></a><span class='hs-keyword'>data</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>=</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-varop'>!</span><span class='hs-layout'>(</span><span class='hs-conid'>ForeignPtr</span> <span class='hs-conid'>CUR</span><span class='hs-layout'>)</span> <span class='hs-conid'>BDB</span>
<a name="line-32"></a>
<a name="line-33"></a><a name="unTCBDBCUR"></a><span class='hs-definition'>unTCBDBCUR</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>ForeignPtr</span> <span class='hs-conid'>CUR</span>
<a name="line-34"></a><span class='hs-definition'>unTCBDBCUR</span> <span class='hs-layout'>(</span><span class='hs-conid'>BDBCUR</span> <span class='hs-varid'>cur</span> <span class='hs-keyword'>_</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>cur</span>
<a name="line-35"></a>
<a name="line-36"></a><a name="new"></a><span class='hs-definition'>new</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDB</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>BDBCUR</span>
<a name="line-37"></a><span class='hs-definition'>new</span> <span class='hs-varid'>bdb</span> <span class='hs-keyglyph'>=</span>
<a name="line-38"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDB</span> <span class='hs-varid'>bdb</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>bdb'</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
<a name="line-39"></a> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_tcbdbcurnew</span> <span class='hs-varid'>bdb'</span>
<a name="line-40"></a> <span class='hs-varid'>flip</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-varid'>bdb</span> <span class='hs-varop'>`fmap`</span> <span class='hs-varid'>newForeignPtr</span> <span class='hs-varid'>tcbdbcurFinalizer</span> <span class='hs-varid'>cur</span>
<a name="line-41"></a>
<a name="line-42"></a><a name="delete"></a><span class='hs-definition'>delete</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>()</span>
<a name="line-43"></a><span class='hs-definition'>delete</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>finalizeForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span>
<a name="line-44"></a>
<a name="line-45"></a><a name="first"></a><span class='hs-definition'>first</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-46"></a><span class='hs-definition'>first</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tcbdbcurfirst</span>
<a name="line-47"></a>
<a name="line-48"></a><a name="last"></a><span class='hs-definition'>last</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-49"></a><span class='hs-definition'>last</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tcbdbcurlast</span>
<a name="line-50"></a>
<a name="line-51"></a><a name="jump"></a><span class='hs-definition'>jump</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>S</span><span class='hs-varop'>.</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'>BDBCUR</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-52"></a><span class='hs-definition'>jump</span> <span class='hs-varid'>cur</span> <span class='hs-varid'>k</span> <span class='hs-keyglyph'>=</span>
<a name="line-53"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>cur'</span> <span class='hs-keyglyph'>-></span>
<a name="line-54"></a> <span class='hs-conid'>S</span><span class='hs-varop'>.</span><span class='hs-varid'>withPtrLen</span> <span class='hs-varid'>k</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'>ksiz</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span>
<a name="line-55"></a> <span class='hs-varid'>c_tcbdbcurjump</span> <span class='hs-varid'>cur'</span> <span class='hs-varid'>kbuf</span> <span class='hs-varid'>ksiz</span>
<a name="line-56"></a>
<a name="line-57"></a><a name="prev"></a><span class='hs-definition'>prev</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-58"></a><span class='hs-definition'>prev</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tcbdbcurprev</span>
<a name="line-59"></a>
<a name="line-60"></a><a name="next"></a><span class='hs-definition'>next</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-61"></a><span class='hs-definition'>next</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tcbdbcurnext</span>
<a name="line-62"></a>
<a name="line-63"></a><a name="put"></a><span class='hs-definition'>put</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>S</span><span class='hs-varop'>.</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'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-varid'>v</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>CursorPutMode</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-64"></a><span class='hs-definition'>put</span> <span class='hs-varid'>cur</span> <span class='hs-varid'>v</span> <span class='hs-varid'>mode</span> <span class='hs-keyglyph'>=</span>
<a name="line-65"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>cur'</span> <span class='hs-keyglyph'>-></span>
<a name="line-66"></a> <span class='hs-conid'>S</span><span class='hs-varop'>.</span><span class='hs-varid'>withPtrLen</span> <span class='hs-varid'>v</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-layout'>(</span><span class='hs-varid'>vbuf</span><span class='hs-layout'>,</span> <span class='hs-varid'>vsiz</span><span class='hs-layout'>)</span> <span class='hs-keyglyph'>-></span>
<a name="line-67"></a> <span class='hs-varid'>c_tcbdbcurput</span> <span class='hs-varid'>cur'</span> <span class='hs-varid'>vbuf</span> <span class='hs-varid'>vsiz</span> <span class='hs-layout'>(</span><span class='hs-varid'>cpToCInt</span> <span class='hs-varid'>mode</span><span class='hs-layout'>)</span>
<a name="line-68"></a>
<a name="line-69"></a><a name="out"></a><span class='hs-definition'>out</span> <span class='hs-keyglyph'>::</span> <span class='hs-conid'>BDBCUR</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>IO</span> <span class='hs-conid'>Bool</span>
<a name="line-70"></a><span class='hs-definition'>out</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varid'>c_tcbdbcurout</span>
<a name="line-71"></a>
<a name="line-72"></a><a name="key"></a><span class='hs-definition'>key</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>S</span><span class='hs-varop'>.</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'>BDBCUR</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-73"></a><span class='hs-definition'>key</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span>
<a name="line-74"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>cur'</span> <span class='hs-keyglyph'>-></span>
<a name="line-75"></a> <span class='hs-varid'>alloca</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>sizbuf</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
<a name="line-76"></a> <span class='hs-varid'>vbuf</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_tcbdbcurkey</span> <span class='hs-varid'>cur'</span> <span class='hs-varid'>sizbuf</span>
<a name="line-77"></a> <span class='hs-varid'>vsiz</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varop'>`fmap`</span> <span class='hs-varid'>peek</span> <span class='hs-varid'>sizbuf</span>
<a name="line-78"></a> <span class='hs-varid'>flip</span> <span class='hs-varid'>maybePeek</span> <span class='hs-varid'>vbuf</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>vbuf'</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>S</span><span class='hs-varop'>.</span><span class='hs-varid'>peekPtrLen</span> <span class='hs-layout'>(</span><span class='hs-varid'>vbuf'</span><span class='hs-layout'>,</span> <span class='hs-varid'>vsiz</span><span class='hs-layout'>)</span>
<a name="line-79"></a>
<a name="line-80"></a><a name="val"></a><span class='hs-definition'>val</span> <span class='hs-keyglyph'>::</span> <span class='hs-layout'>(</span><span class='hs-conid'>S</span><span class='hs-varop'>.</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'>BDBCUR</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-81"></a><span class='hs-definition'>val</span> <span class='hs-varid'>cur</span> <span class='hs-keyglyph'>=</span>
<a name="line-82"></a> <span class='hs-varid'>withForeignPtr</span> <span class='hs-layout'>(</span><span class='hs-varid'>unTCBDBCUR</span> <span class='hs-varid'>cur</span><span class='hs-layout'>)</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>cur'</span> <span class='hs-keyglyph'>-></span>
<a name="line-83"></a> <span class='hs-varid'>alloca</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>sizbuf</span> <span class='hs-keyglyph'>-></span> <span class='hs-keyword'>do</span>
<a name="line-84"></a> <span class='hs-varid'>vbuf</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>c_tcbdbcurval</span> <span class='hs-varid'>cur'</span> <span class='hs-varid'>sizbuf</span>
<a name="line-85"></a> <span class='hs-varid'>vsiz</span> <span class='hs-keyglyph'><-</span> <span class='hs-varid'>fromIntegral</span> <span class='hs-varop'>`fmap`</span> <span class='hs-varid'>peek</span> <span class='hs-varid'>sizbuf</span>
<a name="line-86"></a> <span class='hs-varid'>flip</span> <span class='hs-varid'>maybePeek</span> <span class='hs-varid'>vbuf</span> <span class='hs-varop'>$</span> <span class='hs-keyglyph'>\</span><span class='hs-varid'>vbuf'</span> <span class='hs-keyglyph'>-></span> <span class='hs-conid'>S</span><span class='hs-varop'>.</span><span class='hs-varid'>peekPtrLen</span> <span class='hs-layout'>(</span><span class='hs-varid'>vbuf'</span><span class='hs-layout'>,</span> <span class='hs-varid'>vsiz</span><span class='hs-layout'>)</span>
</pre></body>
</html>
|