-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
1,069 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IO (iter.Iter.IO)</title><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta charset="utf-8"/><meta name="generator" content="odoc 2.2.1"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">iter</a> » <a href="../index.html">Iter</a> » IO</nav><header class="odoc-preamble"><h1>Module <code><span>Iter.IO</span></code></h1><p>Basic IO</p><p>Very basic interface to manipulate files as iterator of chunks/lines. The iterators take care of opening and closing files properly; every time one iterates over an iterator, the file is opened/closed again.</p><p>Example: copy a file <code>"a"</code> into file <code>"b"</code>, removing blank lines:</p><pre class="language-ocaml"><code>Iterator.(IO.lines_of "a" |> filter (fun l-> l<> "") |> IO.write_lines "b");;</code></pre><p>By chunks of <code>4096</code> bytes:</p><pre class="language-ocaml"><code>Iterator.IO.(chunks_of ~size:4096 "a" |> write_to "b");;</code></pre><p>Read the lines of a file into a list:</p><pre class="language-ocaml"><code>Iterator.IO.lines "a" |> Iterator.to_list</code></pre><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.5.1</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-lines_of"><a href="#val-lines_of" class="anchor"></a><code><span><span class="keyword">val</span> lines_of : <span>?mode:int <span class="arrow">-></span></span> <span>?flags:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> <span>string <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>lines_of filename</code> reads all lines of the given file. It raises the same exception as would opening the file and read from it, except from <code>End_of_file</code> (which is caught). The file is <b>always</b> properly closed. Every time the iterator is iterated on, the file is opened again, so different iterations might return different results</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">mode</span> <p>default <code>0o644</code></p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">flags</span> <p>default: <code>[Open_rdonly]</code></p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-chunks_of"><a href="#val-chunks_of" class="anchor"></a><code><span><span class="keyword">val</span> chunks_of : | ||
<span>?mode:int <span class="arrow">-></span></span> | ||
<span>?flags:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span>?size:int <span class="arrow">-></span></span> | ||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>IO (iter.Iter.IO)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../odoc.support/odoc.css"/><meta name="generator" content="odoc 2.4.3"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../odoc.support/highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../index.html">iter</a> » <a href="../index.html">Iter</a> » IO</nav><header class="odoc-preamble"><h1>Module <code><span>Iter.IO</span></code></h1><p>Basic IO</p><p>Very basic interface to manipulate files as iterator of chunks/lines. The iterators take care of opening and closing files properly; every time one iterates over an iterator, the file is opened/closed again.</p><p>Example: copy a file <code>"a"</code> into file <code>"b"</code>, removing blank lines:</p><pre class="language-ocaml"><code>Iterator.(IO.lines_of "a" |> filter (fun l-> l<> "") |> IO.write_lines "b");;</code></pre><p>By chunks of <code>4096</code> bytes:</p><pre class="language-ocaml"><code>Iterator.IO.(chunks_of ~size:4096 "a" |> write_to "b");;</code></pre><p>Read the lines of a file into a list:</p><pre class="language-ocaml"><code>Iterator.IO.lines "a" |> Iterator.to_list</code></pre><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.5.1</li></ul></header><div class="odoc-content"><div class="odoc-spec"><div class="spec value anchored" id="val-lines_of"><a href="#val-lines_of" class="anchor"></a><code><span><span class="keyword">val</span> lines_of : <span><span class="optlabel">?mode</span>:int <span class="arrow">-></span></span> <span><span class="optlabel">?flags</span>:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> <span>string <span class="arrow">-></span></span> <span>string <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p><code>lines_of filename</code> reads all lines of the given file. It raises the same exception as would opening the file and read from it, except from <code>End_of_file</code> (which is caught). The file is <b>always</b> properly closed. Every time the iterator is iterated on, the file is opened again, so different iterations might return different results</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">mode</span> <p>default <code>0o644</code></p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">flags</span> <p>default: <code>[Open_rdonly]</code></p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-chunks_of"><a href="#val-chunks_of" class="anchor"></a><code><span><span class="keyword">val</span> chunks_of : | ||
<span><span class="optlabel">?mode</span>:int <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?flags</span>:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?size</span>:int <span class="arrow">-></span></span> | ||
<span>string <span class="arrow">-></span></span> | ||
<span>string <a href="../index.html#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Read chunks of the given <code>size</code> from the file. The last chunk might be smaller. Behaves like <a href="#val-lines_of"><code>lines_of</code></a> regarding errors and options. Every time the iterator is iterated on, the file is opened again, so different iterations might return different results</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_to"><a href="#val-write_to" class="anchor"></a><code><span><span class="keyword">val</span> write_to : | ||
<span>?mode:int <span class="arrow">-></span></span> | ||
<span>?flags:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?mode</span>:int <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?flags</span>:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span>string <span class="arrow">-></span></span> | ||
<span><span>string <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> | ||
unit</span></code></div><div class="spec-doc"><p><code>write_to filename seq</code> writes all strings from <code>seq</code> into the given file. It takes care of opening and closing the file.</p><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">mode</span> <p>default <code>0o644</code></p></li></ul><ul class="at-tags"><li class="parameter"><span class="at-tag">parameter</span> <span class="value">flags</span> <p>used by <code>open_out_gen</code>. Default: <code>[Open_creat;Open_wronly]</code>.</p></li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_bytes_to"><a href="#val-write_bytes_to" class="anchor"></a><code><span><span class="keyword">val</span> write_bytes_to : | ||
<span>?mode:int <span class="arrow">-></span></span> | ||
<span>?flags:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?mode</span>:int <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?flags</span>:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span>string <span class="arrow">-></span></span> | ||
<span><span><span class="xref-unresolved">Stdlib</span>.Bytes.t <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> | ||
unit</span></code></div><div class="spec-doc"><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.5.4</li></ul></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_lines"><a href="#val-write_lines" class="anchor"></a><code><span><span class="keyword">val</span> write_lines : | ||
<span>?mode:int <span class="arrow">-></span></span> | ||
<span>?flags:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?mode</span>:int <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?flags</span>:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span>string <span class="arrow">-></span></span> | ||
<span><span>string <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> | ||
unit</span></code></div><div class="spec-doc"><p>Same as <a href="#val-write_to"><code>write_to</code></a>, but intercales <code>'\n'</code> between each string</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-write_bytes_lines"><a href="#val-write_bytes_lines" class="anchor"></a><code><span><span class="keyword">val</span> write_bytes_lines : | ||
<span>?mode:int <span class="arrow">-></span></span> | ||
<span>?flags:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?mode</span>:int <span class="arrow">-></span></span> | ||
<span><span class="optlabel">?flags</span>:<span><span class="xref-unresolved">Stdlib</span>.open_flag list</span> <span class="arrow">-></span></span> | ||
<span>string <span class="arrow">-></span></span> | ||
<span><span><span class="xref-unresolved">Stdlib</span>.Bytes.t <a href="../index.html#type-t">t</a></span> <span class="arrow">-></span></span> | ||
unit</span></code></div><div class="spec-doc"><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.5.4</li></ul></div></div></div></body></html> | ||
unit</span></code></div><div class="spec-doc"><ul class="at-tags"><li class="since"><span class="at-tag">since</span> 0.5.4</li></ul></div></div></div></body></html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.