<?xml version="1.0"?>
<page xmlns="http://projectmallard.org/1.0/"
      type="topic"
      style="function"
      xmlns:api="http://projectmallard.org/experimental/api/"
      xmlns:ui="http://projectmallard.org/experimental/ui/"
      id="bson_reader_read">
  <info>
    <link type="guide" xref="bson_reader_t" group="function"/>
  </info>
  <title>bson_reader_read()</title>

  <section id="synopsis">
    <title>Synopsis</title>
    <synopsis><code mime="text/x-csrc"><![CDATA[const bson_t *
bson_reader_read (bson_reader_t *reader,
                  bool          *reached_eof);
]]></code></synopsis>
  </section>

  <section id="parameters">
    <title>Parameters</title>
    <table>
      <tr><td><p><code>reader</code></p></td><td><p>A <link xref="bson_reader_t">bson_reader_t</link>.</p></td></tr>
      <tr><td><p><code>reached_eof</code></p></td><td><p>A UNKNOWN.</p></td></tr>
    </table>
  </section>

  <section id="description">
    <title>Description</title>
    <p>The <link xref="bson_reader_read">bson_reader_read()</link> function shall read the next document from the underlying file-descriptor or buffer.</p>
    <p>If there are no further documents or a failure was detected, then NULL is returned.</p>
    <p>If we reached the end of the sequence, <code>reached_eof</code> is set to true.</p>
    <p>To detect an error, check for NULL and <code>reached_of</code> is false.</p>
  </section>

  <section id="return">
    <title>Returns</title>
    <p>A <link xref="bson_t">bson_t</link> that should not be modified or freed.</p>
  </section>

  <section id="example">
    <title>Example</title>
    <synopsis><code mime="text/x-csrc"><![CDATA[
const bson_t *doc;
bool reached_eof = false;

while ((doc = bson_reader_read (reader, &reached_eof))) {
	/* do something */
}

if (!reached_eof) {
	fprintf (stderr, "Failed to read all documents.\n");
}
]]></code></synopsis>
  </section>
</page>
