<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.14"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>tesseract: ccstruct/boxread.cpp File Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(initResizable);
/* @license-end */</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">tesseract
   &#160;<span id="projectnumber">3.05.02</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.14 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('a00224.html','');});
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">boxread.cpp File Reference</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><code>#include &quot;<a class="el" href="a00227_source.html">boxread.h</a>&quot;</code><br />
<code>#include &lt;string.h&gt;</code><br />
<code>#include &quot;<a class="el" href="a00503_source.html">fileerr.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="a00401_source.html">rect.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="a00593_source.html">strngs.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="a00608_source.html">tprintf.h</a>&quot;</code><br />
<code>#include &quot;<a class="el" href="a00614_source.html">unichar.h</a>&quot;</code><br />
</div>
<p><a href="a00224_source.html">Go to the source code of this file.</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:af8f00c0aa1951fff65cff5802879a91d"><td class="memItemLeft" align="right" valign="top">FILE *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#af8f00c0aa1951fff65cff5802879a91d">OpenBoxFile</a> (const <a class="el" href="a02929.html">STRING</a> &amp;fname)</td></tr>
<tr class="separator:af8f00c0aa1951fff65cff5802879a91d"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab3161d7c887ead295045650e34d690fc"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#ab3161d7c887ead295045650e34d690fc">ReadAllBoxes</a> (int target_page, bool skip_blanks, const <a class="el" href="a02929.html">STRING</a> &amp;filename, <a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02713.html">TBOX</a> &gt; *boxes, <a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *texts, <a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *box_texts, <a class="el" href="a02297.html">GenericVector</a>&lt; int &gt; *pages)</td></tr>
<tr class="separator:ab3161d7c887ead295045650e34d690fc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae4e029cbe1a7c0f7902eae69bfc729e0"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#ae4e029cbe1a7c0f7902eae69bfc729e0">ReadMemBoxes</a> (int target_page, bool skip_blanks, const char *box_data, <a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02713.html">TBOX</a> &gt; *boxes, <a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *texts, <a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *box_texts, <a class="el" href="a02297.html">GenericVector</a>&lt; int &gt; *pages)</td></tr>
<tr class="separator:ae4e029cbe1a7c0f7902eae69bfc729e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8465e130ce34e31d743881d41ecba78"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a02929.html">STRING</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#af8465e130ce34e31d743881d41ecba78">BoxFileName</a> (const <a class="el" href="a02929.html">STRING</a> &amp;image_filename)</td></tr>
<tr class="separator:af8465e130ce34e31d743881d41ecba78"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a8236e051549f8174e263196602edadc5"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#a8236e051549f8174e263196602edadc5">ReadNextBox</a> (int *line_number, FILE *box_file, <a class="el" href="a02929.html">STRING</a> *utf8_str, <a class="el" href="a02713.html">TBOX</a> *bounding_box)</td></tr>
<tr class="separator:a8236e051549f8174e263196602edadc5"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a566c682100d2b5f0a20f39bf99ad2d30"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#a566c682100d2b5f0a20f39bf99ad2d30">ReadNextBox</a> (int target_page, int *line_number, FILE *box_file, <a class="el" href="a02929.html">STRING</a> *utf8_str, <a class="el" href="a02713.html">TBOX</a> *bounding_box)</td></tr>
<tr class="separator:a566c682100d2b5f0a20f39bf99ad2d30"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:acd464bb54397318c2f6fb8db9e644fd0"><td class="memItemLeft" align="right" valign="top">bool&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a> (const char *boxfile_str, int *page_number, <a class="el" href="a02929.html">STRING</a> *utf8_str, <a class="el" href="a02713.html">TBOX</a> *bounding_box)</td></tr>
<tr class="separator:acd464bb54397318c2f6fb8db9e644fd0"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a12d56f93e661ff006a382fb8d7314898"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#a12d56f93e661ff006a382fb8d7314898">MakeBoxFileStr</a> (const char *unichar_str, const <a class="el" href="a02713.html">TBOX</a> &amp;box, int page_num, <a class="el" href="a02929.html">STRING</a> *box_str)</td></tr>
<tr class="separator:a12d56f93e661ff006a382fb8d7314898"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="af8465e130ce34e31d743881d41ecba78"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af8465e130ce34e31d743881d41ecba78">&#9670;&nbsp;</a></span>BoxFileName()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="a02929.html">STRING</a> BoxFileName </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a02929.html">STRING</a> &amp;&#160;</td>
          <td class="paramname"><em>image_filename</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00098">98</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;                                                 {</div><div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;  <a class="code" href="a02929.html">STRING</a> box_filename = image_filename;</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  <span class="keyword">const</span> <span class="keywordtype">char</span> *lastdot = strrchr(box_filename.<a class="code" href="a02929.html#abf0a7b3c6ae39a46e5441f28f61de5de">string</a>(), <span class="charliteral">&#39;.&#39;</span>);</div><div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;  <span class="keywordflow">if</span> (lastdot != NULL)</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    box_filename.<a class="code" href="a02929.html#a0d5a6c456f8e3ef4b4a5077031573df8">truncate_at</a>(lastdot - box_filename.<a class="code" href="a02929.html#abf0a7b3c6ae39a46e5441f28f61de5de">string</a>());</div><div class="line"><a name="l00103"></a><span class="lineno">  103</span>&#160;</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;  box_filename += <span class="stringliteral">&quot;.box&quot;</span>;</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;  <span class="keywordflow">return</span> box_filename;</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;}</div><div class="ttc" id="a02929_html_a0d5a6c456f8e3ef4b4a5077031573df8"><div class="ttname"><a href="a02929.html#a0d5a6c456f8e3ef4b4a5077031573df8">STRING::truncate_at</a></div><div class="ttdeci">void truncate_at(inT32 index)</div><div class="ttdef"><b>Definition:</b> <a href="a00590_source.html#l00272">strngs.cpp:272</a></div></div>
<div class="ttc" id="a02929_html_abf0a7b3c6ae39a46e5441f28f61de5de"><div class="ttname"><a href="a02929.html#abf0a7b3c6ae39a46e5441f28f61de5de">STRING::string</a></div><div class="ttdeci">const char * string() const</div><div class="ttdef"><b>Definition:</b> <a href="a00590_source.html#l00201">strngs.cpp:201</a></div></div>
<div class="ttc" id="a02929_html"><div class="ttname"><a href="a02929.html">STRING</a></div><div class="ttdef"><b>Definition:</b> <a href="a00593_source.html#l00044">strngs.h:44</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a12d56f93e661ff006a382fb8d7314898"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a12d56f93e661ff006a382fb8d7314898">&#9670;&nbsp;</a></span>MakeBoxFileStr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void MakeBoxFileStr </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>unichar_str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="a02713.html">TBOX</a> &amp;&#160;</td>
          <td class="paramname"><em>box</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>page_num</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02929.html">STRING</a> *&#160;</td>
          <td class="paramname"><em>box_str</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00226">226</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;                                     {</div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;  *box_str = unichar_str;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;  box_str-&gt;<a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">&quot; &quot;</span>, box.<a class="code" href="a02713.html#affd18574697b2b707cee416f7cdccb1f">left</a>());</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;  box_str-&gt;<a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">&quot; &quot;</span>, box.<a class="code" href="a02713.html#ae20440e936439218b9dfe267b8a37b4a">bottom</a>());</div><div class="line"><a name="l00231"></a><span class="lineno">  231</span>&#160;  box_str-&gt;<a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">&quot; &quot;</span>, box.<a class="code" href="a02713.html#a54de49d8654e35d5221c7cdc20e2662f">right</a>());</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;  box_str-&gt;<a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">&quot; &quot;</span>, box.<a class="code" href="a02713.html#ac5ecdfbd33963eac601ccb67ac63dd2a">top</a>());</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;  box_str-&gt;<a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">&quot; &quot;</span>, page_num);</div><div class="line"><a name="l00234"></a><span class="lineno">  234</span>&#160;}</div><div class="ttc" id="a02929_html_a779cd637dd42d58d5500a3a657077e84"><div class="ttname"><a href="a02929.html#a779cd637dd42d58d5500a3a657077e84">STRING::add_str_int</a></div><div class="ttdeci">void add_str_int(const char *str, int number)</div><div class="ttdef"><b>Definition:</b> <a href="a00590_source.html#l00384">strngs.cpp:384</a></div></div>
<div class="ttc" id="a02713_html_ae20440e936439218b9dfe267b8a37b4a"><div class="ttname"><a href="a02713.html#ae20440e936439218b9dfe267b8a37b4a">TBOX::bottom</a></div><div class="ttdeci">inT16 bottom() const</div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00061">rect.h:61</a></div></div>
<div class="ttc" id="a02713_html_affd18574697b2b707cee416f7cdccb1f"><div class="ttname"><a href="a02713.html#affd18574697b2b707cee416f7cdccb1f">TBOX::left</a></div><div class="ttdeci">inT16 left() const</div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00068">rect.h:68</a></div></div>
<div class="ttc" id="a02713_html_ac5ecdfbd33963eac601ccb67ac63dd2a"><div class="ttname"><a href="a02713.html#ac5ecdfbd33963eac601ccb67ac63dd2a">TBOX::top</a></div><div class="ttdeci">inT16 top() const</div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00054">rect.h:54</a></div></div>
<div class="ttc" id="a02713_html_a54de49d8654e35d5221c7cdc20e2662f"><div class="ttname"><a href="a02713.html#a54de49d8654e35d5221c7cdc20e2662f">TBOX::right</a></div><div class="ttdeci">inT16 right() const</div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00075">rect.h:75</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="af8f00c0aa1951fff65cff5802879a91d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af8f00c0aa1951fff65cff5802879a91d">&#9670;&nbsp;</a></span>OpenBoxFile()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">FILE* OpenBoxFile </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="a02929.html">STRING</a> &amp;&#160;</td>
          <td class="paramname"><em>fname</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00033">33</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;                                       {</div><div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160;  <a class="code" href="a02929.html">STRING</a> <a class="code" href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">filename</a> = <a class="code" href="a00224.html#af8465e130ce34e31d743881d41ecba78">BoxFileName</a>(fname);</div><div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;  FILE* box_file = NULL;</div><div class="line"><a name="l00036"></a><span class="lineno">   36</span>&#160;  <span class="keywordflow">if</span> (!(box_file = fopen(<a class="code" href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">filename</a>.string(), <span class="stringliteral">&quot;rb&quot;</span>))) {</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    <a class="code" href="a00503.html#a33ffba120713106d14f1e425559ac571">CANTOPENFILE</a>.<a class="code" href="a02813.html#adba51110893a3527402dabadc89c0c62">error</a>(<span class="stringliteral">&quot;read_next_box&quot;</span>, <a class="code" href="a00500.html#a8a3a2e51383909b357fcdf8eda803637a5e74e236a50519c41cbbcecea29add63">TESSEXIT</a>, <span class="stringliteral">&quot;Can&#39;t open box file %s&quot;</span>,</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;                       <a class="code" href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">filename</a>.string());</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;  }</div><div class="line"><a name="l00040"></a><span class="lineno">   40</span>&#160;  <span class="keywordflow">return</span> box_file;</div><div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;}</div><div class="ttc" id="a00500_html_a8a3a2e51383909b357fcdf8eda803637a5e74e236a50519c41cbbcecea29add63"><div class="ttname"><a href="a00500.html#a8a3a2e51383909b357fcdf8eda803637a5e74e236a50519c41cbbcecea29add63">TESSEXIT</a></div><div class="ttdef"><b>Definition:</b> <a href="a00500_source.html#l00029">errcode.h:29</a></div></div>
<div class="ttc" id="a01739_html_ab85cc7ce156038d7a91fc6b51085c72e"><div class="ttname"><a href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">tesseract-c_api-demo.filename</a></div><div class="ttdeci">string filename</div><div class="ttdef"><b>Definition:</b> <a href="a00854_source.html#l00029">tesseract-c_api-demo.py:29</a></div></div>
<div class="ttc" id="a00224_html_af8465e130ce34e31d743881d41ecba78"><div class="ttname"><a href="a00224.html#af8465e130ce34e31d743881d41ecba78">BoxFileName</a></div><div class="ttdeci">STRING BoxFileName(const STRING &amp;image_filename)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00098">boxread.cpp:98</a></div></div>
<div class="ttc" id="a00503_html_a33ffba120713106d14f1e425559ac571"><div class="ttname"><a href="a00503.html#a33ffba120713106d14f1e425559ac571">CANTOPENFILE</a></div><div class="ttdeci">const ERRCODE CANTOPENFILE</div><div class="ttdef"><b>Definition:</b> <a href="a00503_source.html#l00025">fileerr.h:25</a></div></div>
<div class="ttc" id="a02813_html_adba51110893a3527402dabadc89c0c62"><div class="ttname"><a href="a02813.html#adba51110893a3527402dabadc89c0c62">ERRCODE::error</a></div><div class="ttdeci">void error(const char *caller, TessErrorLogCode action, const char *format,...) const</div><div class="ttdef"><b>Definition:</b> <a href="a00497_source.html#l00040">errcode.cpp:40</a></div></div>
<div class="ttc" id="a02929_html"><div class="ttname"><a href="a02929.html">STRING</a></div><div class="ttdef"><b>Definition:</b> <a href="a00593_source.html#l00044">strngs.h:44</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="acd464bb54397318c2f6fb8db9e644fd0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#acd464bb54397318c2f6fb8db9e644fd0">&#9670;&nbsp;</a></span>ParseBoxFileStr()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ParseBoxFileStr </td>
          <td>(</td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>boxfile_str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>page_number</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02929.html">STRING</a> *&#160;</td>
          <td class="paramname"><em>utf8_str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02713.html">TBOX</a> *&#160;</td>
          <td class="paramname"><em>bounding_box</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00166">166</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;                                                           {</div><div class="line"><a name="l00168"></a><span class="lineno">  168</span>&#160;  *bounding_box = <a class="code" href="a02713.html">TBOX</a>();       <span class="comment">// Initialize it to empty.</span></div><div class="line"><a name="l00169"></a><span class="lineno">  169</span>&#160;  *utf8_str = <span class="stringliteral">&quot;&quot;</span>;</div><div class="line"><a name="l00170"></a><span class="lineno">  170</span>&#160;  <span class="keywordtype">char</span> uch[<a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a>];</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;  <span class="keyword">const</span> <span class="keywordtype">char</span> *buffptr = boxfile_str;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;  <span class="comment">// Read the unichar without messing up on Tibetan.</span></div><div class="line"><a name="l00173"></a><span class="lineno">  173</span>&#160;  <span class="comment">// According to issue 253 the utf-8 surrogates 85 and A0 are treated</span></div><div class="line"><a name="l00174"></a><span class="lineno">  174</span>&#160;  <span class="comment">// as whitespace by sscanf, so it is more reliable to just find</span></div><div class="line"><a name="l00175"></a><span class="lineno">  175</span>&#160;  <span class="comment">// ascii space and tab.</span></div><div class="line"><a name="l00176"></a><span class="lineno">  176</span>&#160;  <span class="keywordtype">int</span> uch_len = 0;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;  <span class="comment">// Skip unicode file designation, if present.</span></div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ubuf = <span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*<span class="keyword">&gt;</span>(buffptr);</div><div class="line"><a name="l00179"></a><span class="lineno">  179</span>&#160;  <span class="keywordflow">if</span> (ubuf[0] == 0xef &amp;&amp; ubuf[1] == 0xbb &amp;&amp; ubuf[2] == 0xbf)</div><div class="line"><a name="l00180"></a><span class="lineno">  180</span>&#160;      buffptr += 3;</div><div class="line"><a name="l00181"></a><span class="lineno">  181</span>&#160;  <span class="comment">// Allow a single blank as the UTF-8 string. Check for empty string and</span></div><div class="line"><a name="l00182"></a><span class="lineno">  182</span>&#160;  <span class="comment">// then blindly eat the first character.</span></div><div class="line"><a name="l00183"></a><span class="lineno">  183</span>&#160;  <span class="keywordflow">if</span> (*buffptr == <span class="charliteral">&#39;\0&#39;</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;  <span class="keywordflow">do</span> {</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    uch[uch_len++] = *buffptr++;</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;  } <span class="keywordflow">while</span> (*buffptr != <span class="charliteral">&#39;\0&#39;</span> &amp;&amp; *buffptr != <span class="charliteral">&#39; &#39;</span> &amp;&amp; *buffptr != <span class="charliteral">&#39;\t&#39;</span> &amp;&amp;</div><div class="line"><a name="l00187"></a><span class="lineno">  187</span>&#160;           uch_len &lt; <a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a> - 1);</div><div class="line"><a name="l00188"></a><span class="lineno">  188</span>&#160;  uch[uch_len] = <span class="charliteral">&#39;\0&#39;</span>;</div><div class="line"><a name="l00189"></a><span class="lineno">  189</span>&#160;  <span class="keywordflow">if</span> (*buffptr != <span class="charliteral">&#39;\0&#39;</span>) ++buffptr;</div><div class="line"><a name="l00190"></a><span class="lineno">  190</span>&#160;  <span class="keywordtype">int</span> x_min, y_min, x_max, y_max;</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;  *page_number = 0;</div><div class="line"><a name="l00192"></a><span class="lineno">  192</span>&#160;  <span class="keywordtype">int</span> <a class="code" href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a> = sscanf(buffptr, <span class="stringliteral">&quot;%d %d %d %d %d&quot;</span>,</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;                 &amp;x_min, &amp;y_min, &amp;x_max, &amp;y_max, page_number);</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;  <span class="keywordflow">if</span> (<a class="code" href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a> != 5 &amp;&amp; <a class="code" href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a> != 4) {</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;    <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">&quot;Bad box coordinates in boxfile string! %s\n&quot;</span>, ubuf);</div><div class="line"><a name="l00196"></a><span class="lineno">  196</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00197"></a><span class="lineno">  197</span>&#160;  }</div><div class="line"><a name="l00198"></a><span class="lineno">  198</span>&#160;  <span class="comment">// Test for long space-delimited string label.</span></div><div class="line"><a name="l00199"></a><span class="lineno">  199</span>&#160;  <span class="keywordflow">if</span> (strcmp(uch, kMultiBlobLabelCode) == 0 &amp;&amp;</div><div class="line"><a name="l00200"></a><span class="lineno">  200</span>&#160;      (buffptr = strchr(buffptr, <span class="charliteral">&#39;#&#39;</span>)) != NULL) {</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;    strncpy(uch, buffptr + 1, <a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a> - 1);</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    uch[<a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a> - 1] = <span class="charliteral">&#39;\0&#39;</span>;  <span class="comment">// Prevent buffer overrun.</span></div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;    <a class="code" href="a00521.html#a31bec0ef73dd383e256fa462e9fa7e1f">chomp_string</a>(uch);</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;    uch_len = strlen(uch);</div><div class="line"><a name="l00205"></a><span class="lineno">  205</span>&#160;  }</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;  <span class="comment">// Validate UTF8 by making unichars with it.</span></div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;  <span class="keywordtype">int</span> used = 0;</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;  <span class="keywordflow">while</span> (used &lt; uch_len) {</div><div class="line"><a name="l00209"></a><span class="lineno">  209</span>&#160;    <a class="code" href="a04013.html">UNICHAR</a> ch(uch + used, uch_len - used);</div><div class="line"><a name="l00210"></a><span class="lineno">  210</span>&#160;    <span class="keywordtype">int</span> new_used = ch.utf8_len();</div><div class="line"><a name="l00211"></a><span class="lineno">  211</span>&#160;    <span class="keywordflow">if</span> (new_used == 0) {</div><div class="line"><a name="l00212"></a><span class="lineno">  212</span>&#160;      <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">&quot;Bad UTF-8 str %s starts with 0x%02x at col %d\n&quot;</span>,</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;              uch + used, uch[used], used + 1);</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00215"></a><span class="lineno">  215</span>&#160;    }</div><div class="line"><a name="l00216"></a><span class="lineno">  216</span>&#160;    used += new_used;</div><div class="line"><a name="l00217"></a><span class="lineno">  217</span>&#160;  }</div><div class="line"><a name="l00218"></a><span class="lineno">  218</span>&#160;  *utf8_str = uch;</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;  <span class="keywordflow">if</span> (x_min &gt; x_max) <a class="code" href="a00521.html#ae8b7e3bea137bea50dc1ceb158ddf0ac">Swap</a>(&amp;x_min, &amp;x_max);</div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;  <span class="keywordflow">if</span> (y_min &gt; y_max) <a class="code" href="a00521.html#ae8b7e3bea137bea50dc1ceb158ddf0ac">Swap</a>(&amp;y_min, &amp;y_max);</div><div class="line"><a name="l00221"></a><span class="lineno">  221</span>&#160;  bounding_box-&gt;<a class="code" href="a02713.html#ad61db4030d2a99fb107bb9679a055bed">set_to_given_coords</a>(x_min, y_min, x_max, y_max);</div><div class="line"><a name="l00222"></a><span class="lineno">  222</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">true</span>;  <span class="comment">// Successfully read a box.</span></div><div class="line"><a name="l00223"></a><span class="lineno">  223</span>&#160;}</div><div class="ttc" id="a00227_html_a6a24b858ccf4e9eb9e163b5bcc04b682"><div class="ttname"><a href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a></div><div class="ttdeci">const int kBoxReadBufSize</div><div class="ttdef"><b>Definition:</b> <a href="a00227_source.html#l00031">boxread.h:31</a></div></div>
<div class="ttc" id="a01121_html_acd4ea858d7133e40518e0832ff9d94b2"><div class="ttname"><a href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a></div><div class="ttdeci">int count(LIST var_list)</div><div class="ttdef"><b>Definition:</b> <a href="a01121_source.html#l00103">oldlist.cpp:103</a></div></div>
<div class="ttc" id="a02713_html_ad61db4030d2a99fb107bb9679a055bed"><div class="ttname"><a href="a02713.html#ad61db4030d2a99fb107bb9679a055bed">TBOX::set_to_given_coords</a></div><div class="ttdeci">void set_to_given_coords(int x_min, int y_min, int x_max, int y_max)</div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00263">rect.h:263</a></div></div>
<div class="ttc" id="a00608_html_a02aa7cca2c3857c14716e8cca96ace6c"><div class="ttname"><a href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a></div><div class="ttdeci">#define tprintf(...)</div><div class="ttdef"><b>Definition:</b> <a href="a00608_source.html#l00031">tprintf.h:31</a></div></div>
<div class="ttc" id="a04013_html"><div class="ttname"><a href="a04013.html">UNICHAR</a></div><div class="ttdef"><b>Definition:</b> <a href="a00614_source.html#l00052">unichar.h:52</a></div></div>
<div class="ttc" id="a02713_html"><div class="ttname"><a href="a02713.html">TBOX</a></div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00030">rect.h:30</a></div></div>
<div class="ttc" id="a00521_html_a31bec0ef73dd383e256fa462e9fa7e1f"><div class="ttname"><a href="a00521.html#a31bec0ef73dd383e256fa462e9fa7e1f">chomp_string</a></div><div class="ttdeci">void chomp_string(char *str)</div><div class="ttdef"><b>Definition:</b> <a href="a00521_source.html#l00075">helpers.h:75</a></div></div>
<div class="ttc" id="a00521_html_ae8b7e3bea137bea50dc1ceb158ddf0ac"><div class="ttname"><a href="a00521.html#ae8b7e3bea137bea50dc1ceb158ddf0ac">Swap</a></div><div class="ttdeci">void Swap(T *p1, T *p2)</div><div class="ttdef"><b>Definition:</b> <a href="a00521_source.html#l00090">helpers.h:90</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ab3161d7c887ead295045650e34d690fc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab3161d7c887ead295045650e34d690fc">&#9670;&nbsp;</a></span>ReadAllBoxes()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ReadAllBoxes </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target_page</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>skip_blanks</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="a02929.html">STRING</a> &amp;&#160;</td>
          <td class="paramname"><em>filename</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02713.html">TBOX</a> &gt; *&#160;</td>
          <td class="paramname"><em>boxes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *&#160;</td>
          <td class="paramname"><em>texts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *&#160;</td>
          <td class="paramname"><em>box_texts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; int &gt; *&#160;</td>
          <td class="paramname"><em>pages</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00050">50</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;                                             {</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;  <a class="code" href="a02297.html">GenericVector&lt;char&gt;</a> box_data;</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;  <span class="keywordflow">if</span> (!<a class="code" href="a01738.html#a3a2334d9500f5b9f41f2f33f106f4171">tesseract::LoadDataFromFile</a>(<a class="code" href="a00224.html#af8465e130ce34e31d743881d41ecba78">BoxFileName</a>(<a class="code" href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">filename</a>), &amp;box_data))</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;    <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;  <span class="comment">// Convert the array of bytes to a string, so it can be used by the parser.</span></div><div class="line"><a name="l00059"></a><span class="lineno">   59</span>&#160;  box_data.<a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(<span class="charliteral">&#39;\0&#39;</span>);</div><div class="line"><a name="l00060"></a><span class="lineno">   60</span>&#160;  <span class="keywordflow">return</span> <a class="code" href="a00224.html#ae4e029cbe1a7c0f7902eae69bfc729e0">ReadMemBoxes</a>(target_page, skip_blanks, &amp;box_data[0], boxes, texts,</div><div class="line"><a name="l00061"></a><span class="lineno">   61</span>&#160;                      box_texts, pages);</div><div class="line"><a name="l00062"></a><span class="lineno">   62</span>&#160;}</div><div class="ttc" id="a02297_html"><div class="ttname"><a href="a02297.html">GenericVector&lt; char &gt;</a></div></div>
<div class="ttc" id="a01739_html_ab85cc7ce156038d7a91fc6b51085c72e"><div class="ttname"><a href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">tesseract-c_api-demo.filename</a></div><div class="ttdeci">string filename</div><div class="ttdef"><b>Definition:</b> <a href="a00854_source.html#l00029">tesseract-c_api-demo.py:29</a></div></div>
<div class="ttc" id="a02297_html_a0dc89fe2a365b04a61017f9d78c1a303"><div class="ttname"><a href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">GenericVector::push_back</a></div><div class="ttdeci">int push_back(T object)</div><div class="ttdef"><b>Definition:</b> <a href="a00509_source.html#l00766">genericvector.h:766</a></div></div>
<div class="ttc" id="a01738_html_a3a2334d9500f5b9f41f2f33f106f4171"><div class="ttname"><a href="a01738.html#a3a2334d9500f5b9f41f2f33f106f4171">tesseract::LoadDataFromFile</a></div><div class="ttdeci">bool LoadDataFromFile(const STRING &amp;filename, GenericVector&lt; char &gt; *data)</div><div class="ttdef"><b>Definition:</b> <a href="a00509_source.html#l00359">genericvector.h:359</a></div></div>
<div class="ttc" id="a00224_html_af8465e130ce34e31d743881d41ecba78"><div class="ttname"><a href="a00224.html#af8465e130ce34e31d743881d41ecba78">BoxFileName</a></div><div class="ttdeci">STRING BoxFileName(const STRING &amp;image_filename)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00098">boxread.cpp:98</a></div></div>
<div class="ttc" id="a00224_html_ae4e029cbe1a7c0f7902eae69bfc729e0"><div class="ttname"><a href="a00224.html#ae4e029cbe1a7c0f7902eae69bfc729e0">ReadMemBoxes</a></div><div class="ttdeci">bool ReadMemBoxes(int target_page, bool skip_blanks, const char *box_data, GenericVector&lt; TBOX &gt; *boxes, GenericVector&lt; STRING &gt; *texts, GenericVector&lt; STRING &gt; *box_texts, GenericVector&lt; int &gt; *pages)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00065">boxread.cpp:65</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="ae4e029cbe1a7c0f7902eae69bfc729e0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae4e029cbe1a7c0f7902eae69bfc729e0">&#9670;&nbsp;</a></span>ReadMemBoxes()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ReadMemBoxes </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target_page</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>skip_blanks</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const char *&#160;</td>
          <td class="paramname"><em>box_data</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02713.html">TBOX</a> &gt; *&#160;</td>
          <td class="paramname"><em>boxes</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *&#160;</td>
          <td class="paramname"><em>texts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; <a class="el" href="a02929.html">STRING</a> &gt; *&#160;</td>
          <td class="paramname"><em>box_texts</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02297.html">GenericVector</a>&lt; int &gt; *&#160;</td>
          <td class="paramname"><em>pages</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00065">65</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00069"></a><span class="lineno">   69</span>&#160;                                             {</div><div class="line"><a name="l00070"></a><span class="lineno">   70</span>&#160;  <a class="code" href="a02929.html">STRING</a> box_str(box_data);</div><div class="line"><a name="l00071"></a><span class="lineno">   71</span>&#160;  <a class="code" href="a02297.html">GenericVector&lt;STRING&gt;</a> lines;</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;  box_str.split(<span class="charliteral">&#39;\n&#39;</span>, &amp;lines);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;  <span class="keywordflow">if</span> (lines.<a class="code" href="a02297.html#a172c4aa23ba397e24319ae095281cbcc">empty</a>()) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00074"></a><span class="lineno">   74</span>&#160;  <span class="keywordtype">int</span> num_boxes = 0;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i &lt; lines.<a class="code" href="a02297.html#a20cfad5c58c50cb85a9529d8ddbd96af">size</a>(); ++i) {</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;    <span class="keywordtype">int</span> page = 0;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;    <a class="code" href="a02929.html">STRING</a> utf8_str;</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <a class="code" href="a02713.html">TBOX</a> box;</div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    <span class="keywordflow">if</span> (!<a class="code" href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a>(lines[i].<span class="keywordtype">string</span>(), &amp;page, &amp;utf8_str, &amp;box)) {</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;      <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    }</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <span class="keywordflow">if</span> (skip_blanks &amp;&amp; (utf8_str == <span class="stringliteral">&quot; &quot;</span> || utf8_str == <span class="stringliteral">&quot;\t&quot;</span>)) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;    <span class="keywordflow">if</span> (target_page &gt;= 0 &amp;&amp; page != target_page) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keywordflow">if</span> (boxes != NULL) boxes-&gt;<a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(box);</div><div class="line"><a name="l00085"></a><span class="lineno">   85</span>&#160;    <span class="keywordflow">if</span> (texts != NULL) texts-&gt;<a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(utf8_str);</div><div class="line"><a name="l00086"></a><span class="lineno">   86</span>&#160;    <span class="keywordflow">if</span> (box_texts != NULL) {</div><div class="line"><a name="l00087"></a><span class="lineno">   87</span>&#160;      <a class="code" href="a02929.html">STRING</a> full_text;</div><div class="line"><a name="l00088"></a><span class="lineno">   88</span>&#160;      <a class="code" href="a00224.html#a12d56f93e661ff006a382fb8d7314898">MakeBoxFileStr</a>(utf8_str.<a class="code" href="a02929.html#abf0a7b3c6ae39a46e5441f28f61de5de">string</a>(), box, target_page, &amp;full_text);</div><div class="line"><a name="l00089"></a><span class="lineno">   89</span>&#160;      box_texts-&gt;<a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(full_text);</div><div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    }</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;    <span class="keywordflow">if</span> (pages != NULL) pages-&gt;<a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(page);</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;    ++num_boxes;</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;  }</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;  <span class="keywordflow">return</span> num_boxes &gt; 0;</div><div class="line"><a name="l00095"></a><span class="lineno">   95</span>&#160;}</div><div class="ttc" id="a02297_html"><div class="ttname"><a href="a02297.html">GenericVector&lt; STRING &gt;</a></div></div>
<div class="ttc" id="a02297_html_a0dc89fe2a365b04a61017f9d78c1a303"><div class="ttname"><a href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">GenericVector::push_back</a></div><div class="ttdeci">int push_back(T object)</div><div class="ttdef"><b>Definition:</b> <a href="a00509_source.html#l00766">genericvector.h:766</a></div></div>
<div class="ttc" id="a02929_html_abf0a7b3c6ae39a46e5441f28f61de5de"><div class="ttname"><a href="a02929.html#abf0a7b3c6ae39a46e5441f28f61de5de">STRING::string</a></div><div class="ttdeci">const char * string() const</div><div class="ttdef"><b>Definition:</b> <a href="a00590_source.html#l00201">strngs.cpp:201</a></div></div>
<div class="ttc" id="a00224_html_a12d56f93e661ff006a382fb8d7314898"><div class="ttname"><a href="a00224.html#a12d56f93e661ff006a382fb8d7314898">MakeBoxFileStr</a></div><div class="ttdeci">void MakeBoxFileStr(const char *unichar_str, const TBOX &amp;box, int page_num, STRING *box_str)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00226">boxread.cpp:226</a></div></div>
<div class="ttc" id="a00224_html_acd464bb54397318c2f6fb8db9e644fd0"><div class="ttname"><a href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a></div><div class="ttdeci">bool ParseBoxFileStr(const char *boxfile_str, int *page_number, STRING *utf8_str, TBOX *bounding_box)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00166">boxread.cpp:166</a></div></div>
<div class="ttc" id="a02929_html"><div class="ttname"><a href="a02929.html">STRING</a></div><div class="ttdef"><b>Definition:</b> <a href="a00593_source.html#l00044">strngs.h:44</a></div></div>
<div class="ttc" id="a02297_html_a20cfad5c58c50cb85a9529d8ddbd96af"><div class="ttname"><a href="a02297.html#a20cfad5c58c50cb85a9529d8ddbd96af">GenericVector::size</a></div><div class="ttdeci">int size() const</div><div class="ttdef"><b>Definition:</b> <a href="a00509_source.html#l00072">genericvector.h:72</a></div></div>
<div class="ttc" id="a02713_html"><div class="ttname"><a href="a02713.html">TBOX</a></div><div class="ttdef"><b>Definition:</b> <a href="a00401_source.html#l00030">rect.h:30</a></div></div>
<div class="ttc" id="a02297_html_a172c4aa23ba397e24319ae095281cbcc"><div class="ttname"><a href="a02297.html#a172c4aa23ba397e24319ae095281cbcc">GenericVector::empty</a></div><div class="ttdeci">bool empty() const</div><div class="ttdef"><b>Definition:</b> <a href="a00509_source.html#l00084">genericvector.h:84</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a8236e051549f8174e263196602edadc5"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a8236e051549f8174e263196602edadc5">&#9670;&nbsp;</a></span>ReadNextBox() <span class="overload">[1/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ReadNextBox </td>
          <td>(</td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>line_number</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>box_file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02929.html">STRING</a> *&#160;</td>
          <td class="paramname"><em>utf8_str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02713.html">TBOX</a> *&#160;</td>
          <td class="paramname"><em>bounding_box</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00119">119</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00120"></a><span class="lineno">  120</span>&#160;                                                       {</div><div class="line"><a name="l00121"></a><span class="lineno">  121</span>&#160;  <span class="keywordflow">return</span> <a class="code" href="a00224.html#a8236e051549f8174e263196602edadc5">ReadNextBox</a>(-1, line_number, box_file, utf8_str, bounding_box);</div><div class="line"><a name="l00122"></a><span class="lineno">  122</span>&#160;}</div><div class="ttc" id="a00224_html_a8236e051549f8174e263196602edadc5"><div class="ttname"><a href="a00224.html#a8236e051549f8174e263196602edadc5">ReadNextBox</a></div><div class="ttdeci">bool ReadNextBox(int *line_number, FILE *box_file, STRING *utf8_str, TBOX *bounding_box)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00119">boxread.cpp:119</a></div></div>
</div><!-- fragment -->
</div>
</div>
<a id="a566c682100d2b5f0a20f39bf99ad2d30"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a566c682100d2b5f0a20f39bf99ad2d30">&#9670;&nbsp;</a></span>ReadNextBox() <span class="overload">[2/2]</span></h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">bool ReadNextBox </td>
          <td>(</td>
          <td class="paramtype">int&#160;</td>
          <td class="paramname"><em>target_page</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">int *&#160;</td>
          <td class="paramname"><em>line_number</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">FILE *&#160;</td>
          <td class="paramname"><em>box_file</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02929.html">STRING</a> *&#160;</td>
          <td class="paramname"><em>utf8_str</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="a02713.html">TBOX</a> *&#160;</td>
          <td class="paramname"><em>bounding_box</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="a00224_source.html#l00127">127</a> of file <a class="el" href="a00224_source.html">boxread.cpp</a>.</p>
<div class="fragment"><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;                                                       {</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;  <span class="keywordtype">int</span> page = 0;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;  <span class="keywordtype">char</span> buff[<a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a>];   <span class="comment">// boxfile read buffer</span></div><div class="line"><a name="l00131"></a><span class="lineno">  131</span>&#160;  <span class="keywordtype">char</span> *buffptr = buff;</div><div class="line"><a name="l00132"></a><span class="lineno">  132</span>&#160;</div><div class="line"><a name="l00133"></a><span class="lineno">  133</span>&#160;  <span class="keywordflow">while</span> (fgets(buff, <span class="keyword">sizeof</span>(buff) - 1, box_file)) {</div><div class="line"><a name="l00134"></a><span class="lineno">  134</span>&#160;    (*line_number)++;</div><div class="line"><a name="l00135"></a><span class="lineno">  135</span>&#160;</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    buffptr = buff;</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;    <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ubuf = <span class="keyword">reinterpret_cast&lt;</span><span class="keyword">const </span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*<span class="keyword">&gt;</span>(buffptr);</div><div class="line"><a name="l00138"></a><span class="lineno">  138</span>&#160;    <span class="keywordflow">if</span> (ubuf[0] == 0xef &amp;&amp; ubuf[1] == 0xbb &amp;&amp; ubuf[2] == 0xbf)</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;      buffptr += 3;  <span class="comment">// Skip unicode file designation.</span></div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;    <span class="comment">// Check for blank lines in box file</span></div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;    <span class="keywordflow">if</span> (*buffptr == <span class="charliteral">&#39;\n&#39;</span> || *buffptr == <span class="charliteral">&#39;\0&#39;</span>) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;    <span class="comment">// Skip blank boxes.</span></div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keywordflow">if</span> (*buffptr == <span class="charliteral">&#39; &#39;</span> || *buffptr == <span class="charliteral">&#39;\t&#39;</span>) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;    <span class="keywordflow">if</span> (*buffptr != <span class="charliteral">&#39;\0&#39;</span>) {</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;      <span class="keywordflow">if</span> (!<a class="code" href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a>(buffptr, &amp;page, utf8_str, bounding_box)) {</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;        <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">&quot;Box file format error on line %i; ignored\n&quot;</span>, *line_number);</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;        <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;      }</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;      <span class="keywordflow">if</span> (target_page &gt;= 0 &amp;&amp; target_page != page)</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;        <span class="keywordflow">continue</span>;  <span class="comment">// Not on the appropriate page.</span></div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;      <span class="keywordflow">return</span> <span class="keyword">true</span>;  <span class="comment">// Successfully read a box.</span></div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;    }</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;  }</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;  fclose(box_file);</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;  <span class="keywordflow">return</span> <span class="keyword">false</span>;  <span class="comment">// EOF</span></div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;}</div><div class="ttc" id="a00227_html_a6a24b858ccf4e9eb9e163b5bcc04b682"><div class="ttname"><a href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a></div><div class="ttdeci">const int kBoxReadBufSize</div><div class="ttdef"><b>Definition:</b> <a href="a00227_source.html#l00031">boxread.h:31</a></div></div>
<div class="ttc" id="a00224_html_acd464bb54397318c2f6fb8db9e644fd0"><div class="ttname"><a href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a></div><div class="ttdeci">bool ParseBoxFileStr(const char *boxfile_str, int *page_number, STRING *utf8_str, TBOX *bounding_box)</div><div class="ttdef"><b>Definition:</b> <a href="a00224_source.html#l00166">boxread.cpp:166</a></div></div>
<div class="ttc" id="a00608_html_a02aa7cca2c3857c14716e8cca96ace6c"><div class="ttname"><a href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a></div><div class="ttdeci">#define tprintf(...)</div><div class="ttdef"><b>Definition:</b> <a href="a00608_source.html#l00031">tprintf.h:31</a></div></div>
</div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="dir_1ed6c82765748b8cdb8405b19ff0bfcb.html">ccstruct</a></li><li class="navelem"><a class="el" href="a00224.html">boxread.cpp</a></li>
    <li class="footer">Generated on Mon Oct 29 2018 11:27:52 for tesseract by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.14 </li>
  </ul>
</div>
</body>
</html>