<!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&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  <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&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&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&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 "<a class="el" href="a00227_source.html">boxread.h</a>"</code><br /> <code>#include <string.h></code><br /> <code>#include "<a class="el" href="a00503_source.html">fileerr.h</a>"</code><br /> <code>#include "<a class="el" href="a00401_source.html">rect.h</a>"</code><br /> <code>#include "<a class="el" href="a00593_source.html">strngs.h</a>"</code><br /> <code>#include "<a class="el" href="a00608_source.html">tprintf.h</a>"</code><br /> <code>#include "<a class="el" href="a00614_source.html">unichar.h</a>"</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 * </td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#af8f00c0aa1951fff65cff5802879a91d">OpenBoxFile</a> (const <a class="el" href="a02929.html">STRING</a> &fname)</td></tr> <tr class="separator:af8f00c0aa1951fff65cff5802879a91d"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ab3161d7c887ead295045650e34d690fc"><td class="memItemLeft" align="right" valign="top">bool </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> &filename, <a class="el" href="a02297.html">GenericVector</a>< <a class="el" href="a02713.html">TBOX</a> > *boxes, <a class="el" href="a02297.html">GenericVector</a>< <a class="el" href="a02929.html">STRING</a> > *texts, <a class="el" href="a02297.html">GenericVector</a>< <a class="el" href="a02929.html">STRING</a> > *box_texts, <a class="el" href="a02297.html">GenericVector</a>< int > *pages)</td></tr> <tr class="separator:ab3161d7c887ead295045650e34d690fc"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:ae4e029cbe1a7c0f7902eae69bfc729e0"><td class="memItemLeft" align="right" valign="top">bool </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>< <a class="el" href="a02713.html">TBOX</a> > *boxes, <a class="el" href="a02297.html">GenericVector</a>< <a class="el" href="a02929.html">STRING</a> > *texts, <a class="el" href="a02297.html">GenericVector</a>< <a class="el" href="a02929.html">STRING</a> > *box_texts, <a class="el" href="a02297.html">GenericVector</a>< int > *pages)</td></tr> <tr class="separator:ae4e029cbe1a7c0f7902eae69bfc729e0"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:af8465e130ce34e31d743881d41ecba78"><td class="memItemLeft" align="right" valign="top"><a class="el" href="a02929.html">STRING</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="a00224.html#af8465e130ce34e31d743881d41ecba78">BoxFileName</a> (const <a class="el" href="a02929.html">STRING</a> &image_filename)</td></tr> <tr class="separator:af8465e130ce34e31d743881d41ecba78"><td class="memSeparator" colspan="2"> </td></tr> <tr class="memitem:a8236e051549f8174e263196602edadc5"><td class="memItemLeft" align="right" valign="top">bool </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"> </td></tr> <tr class="memitem:a566c682100d2b5f0a20f39bf99ad2d30"><td class="memItemLeft" align="right" valign="top">bool </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"> </td></tr> <tr class="memitem:acd464bb54397318c2f6fb8db9e644fd0"><td class="memItemLeft" align="right" valign="top">bool </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"> </td></tr> <tr class="memitem:a12d56f93e661ff006a382fb8d7314898"><td class="memItemLeft" align="right" valign="top">void </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> &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"> </td></tr> </table> <h2 class="groupheader">Function Documentation</h2> <a id="af8465e130ce34e31d743881d41ecba78"></a> <h2 class="memtitle"><span class="permalink"><a href="#af8465e130ce34e31d743881d41ecba78">◆ </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> & </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>  {</div><div class="line"><a name="l00099"></a><span class="lineno"> 99</span>  <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>  <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">'.'</span>);</div><div class="line"><a name="l00101"></a><span class="lineno"> 101</span>  <span class="keywordflow">if</span> (lastdot != NULL)</div><div class="line"><a name="l00102"></a><span class="lineno"> 102</span>  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> </div><div class="line"><a name="l00104"></a><span class="lineno"> 104</span>  box_filename += <span class="stringliteral">".box"</span>;</div><div class="line"><a name="l00105"></a><span class="lineno"> 105</span>  <span class="keywordflow">return</span> box_filename;</div><div class="line"><a name="l00106"></a><span class="lineno"> 106</span> }</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">◆ </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 * </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> & </td> <td class="paramname"><em>box</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int </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> * </td> <td class="paramname"><em>box_str</em> </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>  {</div><div class="line"><a name="l00228"></a><span class="lineno"> 228</span>  *box_str = unichar_str;</div><div class="line"><a name="l00229"></a><span class="lineno"> 229</span>  box_str-><a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">" "</span>, box.<a class="code" href="a02713.html#affd18574697b2b707cee416f7cdccb1f">left</a>());</div><div class="line"><a name="l00230"></a><span class="lineno"> 230</span>  box_str-><a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">" "</span>, box.<a class="code" href="a02713.html#ae20440e936439218b9dfe267b8a37b4a">bottom</a>());</div><div class="line"><a name="l00231"></a><span class="lineno"> 231</span>  box_str-><a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">" "</span>, box.<a class="code" href="a02713.html#a54de49d8654e35d5221c7cdc20e2662f">right</a>());</div><div class="line"><a name="l00232"></a><span class="lineno"> 232</span>  box_str-><a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">" "</span>, box.<a class="code" href="a02713.html#ac5ecdfbd33963eac601ccb67ac63dd2a">top</a>());</div><div class="line"><a name="l00233"></a><span class="lineno"> 233</span>  box_str-><a class="code" href="a02929.html#a779cd637dd42d58d5500a3a657077e84">add_str_int</a>(<span class="stringliteral">" "</span>, page_num);</div><div class="line"><a name="l00234"></a><span class="lineno"> 234</span> }</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">◆ </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> & </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>  {</div><div class="line"><a name="l00034"></a><span class="lineno"> 34</span>  <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>  FILE* box_file = NULL;</div><div class="line"><a name="l00036"></a><span class="lineno"> 36</span>  <span class="keywordflow">if</span> (!(box_file = fopen(<a class="code" href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">filename</a>.string(), <span class="stringliteral">"rb"</span>))) {</div><div class="line"><a name="l00037"></a><span class="lineno"> 37</span>  <a class="code" href="a00503.html#a33ffba120713106d14f1e425559ac571">CANTOPENFILE</a>.<a class="code" href="a02813.html#adba51110893a3527402dabadc89c0c62">error</a>(<span class="stringliteral">"read_next_box"</span>, <a class="code" href="a00500.html#a8a3a2e51383909b357fcdf8eda803637a5e74e236a50519c41cbbcecea29add63">TESSEXIT</a>, <span class="stringliteral">"Can't open box file %s"</span>,</div><div class="line"><a name="l00038"></a><span class="lineno"> 38</span>  <a class="code" href="a01739.html#ab85cc7ce156038d7a91fc6b51085c72e">filename</a>.string());</div><div class="line"><a name="l00039"></a><span class="lineno"> 39</span>  }</div><div class="line"><a name="l00040"></a><span class="lineno"> 40</span>  <span class="keywordflow">return</span> box_file;</div><div class="line"><a name="l00041"></a><span class="lineno"> 41</span> }</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 &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">◆ </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 * </td> <td class="paramname"><em>boxfile_str</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int * </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> * </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> * </td> <td class="paramname"><em>bounding_box</em> </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>  {</div><div class="line"><a name="l00168"></a><span class="lineno"> 168</span>  *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>  *utf8_str = <span class="stringliteral">""</span>;</div><div class="line"><a name="l00170"></a><span class="lineno"> 170</span>  <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>  <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>  <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>  <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>  <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>  <span class="comment">// ascii space and tab.</span></div><div class="line"><a name="l00176"></a><span class="lineno"> 176</span>  <span class="keywordtype">int</span> uch_len = 0;</div><div class="line"><a name="l00177"></a><span class="lineno"> 177</span>  <span class="comment">// Skip unicode file designation, if present.</span></div><div class="line"><a name="l00178"></a><span class="lineno"> 178</span>  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ubuf = <span class="keyword">reinterpret_cast<</span><span class="keyword">const </span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*<span class="keyword">></span>(buffptr);</div><div class="line"><a name="l00179"></a><span class="lineno"> 179</span>  <span class="keywordflow">if</span> (ubuf[0] == 0xef && ubuf[1] == 0xbb && ubuf[2] == 0xbf)</div><div class="line"><a name="l00180"></a><span class="lineno"> 180</span>  buffptr += 3;</div><div class="line"><a name="l00181"></a><span class="lineno"> 181</span>  <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>  <span class="comment">// then blindly eat the first character.</span></div><div class="line"><a name="l00183"></a><span class="lineno"> 183</span>  <span class="keywordflow">if</span> (*buffptr == <span class="charliteral">'\0'</span>) <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00184"></a><span class="lineno"> 184</span>  <span class="keywordflow">do</span> {</div><div class="line"><a name="l00185"></a><span class="lineno"> 185</span>  uch[uch_len++] = *buffptr++;</div><div class="line"><a name="l00186"></a><span class="lineno"> 186</span>  } <span class="keywordflow">while</span> (*buffptr != <span class="charliteral">'\0'</span> && *buffptr != <span class="charliteral">' '</span> && *buffptr != <span class="charliteral">'\t'</span> &&</div><div class="line"><a name="l00187"></a><span class="lineno"> 187</span>  uch_len < <a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a> - 1);</div><div class="line"><a name="l00188"></a><span class="lineno"> 188</span>  uch[uch_len] = <span class="charliteral">'\0'</span>;</div><div class="line"><a name="l00189"></a><span class="lineno"> 189</span>  <span class="keywordflow">if</span> (*buffptr != <span class="charliteral">'\0'</span>) ++buffptr;</div><div class="line"><a name="l00190"></a><span class="lineno"> 190</span>  <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>  *page_number = 0;</div><div class="line"><a name="l00192"></a><span class="lineno"> 192</span>  <span class="keywordtype">int</span> <a class="code" href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a> = sscanf(buffptr, <span class="stringliteral">"%d %d %d %d %d"</span>,</div><div class="line"><a name="l00193"></a><span class="lineno"> 193</span>  &x_min, &y_min, &x_max, &y_max, page_number);</div><div class="line"><a name="l00194"></a><span class="lineno"> 194</span>  <span class="keywordflow">if</span> (<a class="code" href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a> != 5 && <a class="code" href="a01121.html#acd4ea858d7133e40518e0832ff9d94b2">count</a> != 4) {</div><div class="line"><a name="l00195"></a><span class="lineno"> 195</span>  <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">"Bad box coordinates in boxfile string! %s\n"</span>, ubuf);</div><div class="line"><a name="l00196"></a><span class="lineno"> 196</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00197"></a><span class="lineno"> 197</span>  }</div><div class="line"><a name="l00198"></a><span class="lineno"> 198</span>  <span class="comment">// Test for long space-delimited string label.</span></div><div class="line"><a name="l00199"></a><span class="lineno"> 199</span>  <span class="keywordflow">if</span> (strcmp(uch, kMultiBlobLabelCode) == 0 &&</div><div class="line"><a name="l00200"></a><span class="lineno"> 200</span>  (buffptr = strchr(buffptr, <span class="charliteral">'#'</span>)) != NULL) {</div><div class="line"><a name="l00201"></a><span class="lineno"> 201</span>  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>  uch[<a class="code" href="a00227.html#a6a24b858ccf4e9eb9e163b5bcc04b682">kBoxReadBufSize</a> - 1] = <span class="charliteral">'\0'</span>; <span class="comment">// Prevent buffer overrun.</span></div><div class="line"><a name="l00203"></a><span class="lineno"> 203</span>  <a class="code" href="a00521.html#a31bec0ef73dd383e256fa462e9fa7e1f">chomp_string</a>(uch);</div><div class="line"><a name="l00204"></a><span class="lineno"> 204</span>  uch_len = strlen(uch);</div><div class="line"><a name="l00205"></a><span class="lineno"> 205</span>  }</div><div class="line"><a name="l00206"></a><span class="lineno"> 206</span>  <span class="comment">// Validate UTF8 by making unichars with it.</span></div><div class="line"><a name="l00207"></a><span class="lineno"> 207</span>  <span class="keywordtype">int</span> used = 0;</div><div class="line"><a name="l00208"></a><span class="lineno"> 208</span>  <span class="keywordflow">while</span> (used < uch_len) {</div><div class="line"><a name="l00209"></a><span class="lineno"> 209</span>  <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>  <span class="keywordtype">int</span> new_used = ch.utf8_len();</div><div class="line"><a name="l00211"></a><span class="lineno"> 211</span>  <span class="keywordflow">if</span> (new_used == 0) {</div><div class="line"><a name="l00212"></a><span class="lineno"> 212</span>  <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">"Bad UTF-8 str %s starts with 0x%02x at col %d\n"</span>,</div><div class="line"><a name="l00213"></a><span class="lineno"> 213</span>  uch + used, uch[used], used + 1);</div><div class="line"><a name="l00214"></a><span class="lineno"> 214</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00215"></a><span class="lineno"> 215</span>  }</div><div class="line"><a name="l00216"></a><span class="lineno"> 216</span>  used += new_used;</div><div class="line"><a name="l00217"></a><span class="lineno"> 217</span>  }</div><div class="line"><a name="l00218"></a><span class="lineno"> 218</span>  *utf8_str = uch;</div><div class="line"><a name="l00219"></a><span class="lineno"> 219</span>  <span class="keywordflow">if</span> (x_min > x_max) <a class="code" href="a00521.html#ae8b7e3bea137bea50dc1ceb158ddf0ac">Swap</a>(&x_min, &x_max);</div><div class="line"><a name="l00220"></a><span class="lineno"> 220</span>  <span class="keywordflow">if</span> (y_min > y_max) <a class="code" href="a00521.html#ae8b7e3bea137bea50dc1ceb158ddf0ac">Swap</a>(&y_min, &y_max);</div><div class="line"><a name="l00221"></a><span class="lineno"> 221</span>  bounding_box-><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>  <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> }</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">◆ </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 </td> <td class="paramname"><em>target_page</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">bool </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> & </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>< <a class="el" href="a02713.html">TBOX</a> > * </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>< <a class="el" href="a02929.html">STRING</a> > * </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>< <a class="el" href="a02929.html">STRING</a> > * </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>< int > * </td> <td class="paramname"><em>pages</em> </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>  {</div><div class="line"><a name="l00055"></a><span class="lineno"> 55</span>  <a class="code" href="a02297.html">GenericVector<char></a> box_data;</div><div class="line"><a name="l00056"></a><span class="lineno"> 56</span>  <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>), &box_data))</div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keywordflow">return</span> <span class="keyword">false</span>;</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span>  <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>  box_data.<a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(<span class="charliteral">'\0'</span>);</div><div class="line"><a name="l00060"></a><span class="lineno"> 60</span>  <span class="keywordflow">return</span> <a class="code" href="a00224.html#ae4e029cbe1a7c0f7902eae69bfc729e0">ReadMemBoxes</a>(target_page, skip_blanks, &box_data[0], boxes, texts,</div><div class="line"><a name="l00061"></a><span class="lineno"> 61</span>  box_texts, pages);</div><div class="line"><a name="l00062"></a><span class="lineno"> 62</span> }</div><div class="ttc" id="a02297_html"><div class="ttname"><a href="a02297.html">GenericVector< char ></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 &filename, GenericVector< char > *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 &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< TBOX > *boxes, GenericVector< STRING > *texts, GenericVector< STRING > *box_texts, GenericVector< int > *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">◆ </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 </td> <td class="paramname"><em>target_page</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">bool </td> <td class="paramname"><em>skip_blanks</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">const char * </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>< <a class="el" href="a02713.html">TBOX</a> > * </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>< <a class="el" href="a02929.html">STRING</a> > * </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>< <a class="el" href="a02929.html">STRING</a> > * </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>< int > * </td> <td class="paramname"><em>pages</em> </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>  {</div><div class="line"><a name="l00070"></a><span class="lineno"> 70</span>  <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>  <a class="code" href="a02297.html">GenericVector<STRING></a> lines;</div><div class="line"><a name="l00072"></a><span class="lineno"> 72</span>  box_str.split(<span class="charliteral">'\n'</span>, &lines);</div><div class="line"><a name="l00073"></a><span class="lineno"> 73</span>  <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>  <span class="keywordtype">int</span> num_boxes = 0;</div><div class="line"><a name="l00075"></a><span class="lineno"> 75</span>  <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i = 0; i < lines.<a class="code" href="a02297.html#a20cfad5c58c50cb85a9529d8ddbd96af">size</a>(); ++i) {</div><div class="line"><a name="l00076"></a><span class="lineno"> 76</span>  <span class="keywordtype">int</span> page = 0;</div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <a class="code" href="a02929.html">STRING</a> utf8_str;</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span>  <a class="code" href="a02713.html">TBOX</a> box;</div><div class="line"><a name="l00079"></a><span class="lineno"> 79</span>  <span class="keywordflow">if</span> (!<a class="code" href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a>(lines[i].<span class="keywordtype">string</span>(), &page, &utf8_str, &box)) {</div><div class="line"><a name="l00080"></a><span class="lineno"> 80</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00081"></a><span class="lineno"> 81</span>  }</div><div class="line"><a name="l00082"></a><span class="lineno"> 82</span>  <span class="keywordflow">if</span> (skip_blanks && (utf8_str == <span class="stringliteral">" "</span> || utf8_str == <span class="stringliteral">"\t"</span>)) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00083"></a><span class="lineno"> 83</span>  <span class="keywordflow">if</span> (target_page >= 0 && page != target_page) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keywordflow">if</span> (boxes != NULL) boxes-><a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(box);</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span>  <span class="keywordflow">if</span> (texts != NULL) texts-><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>  <span class="keywordflow">if</span> (box_texts != NULL) {</div><div class="line"><a name="l00087"></a><span class="lineno"> 87</span>  <a class="code" href="a02929.html">STRING</a> full_text;</div><div class="line"><a name="l00088"></a><span class="lineno"> 88</span>  <a class="code" href="a00224.html#a12d56f93e661ff006a382fb8d7314898">MakeBoxFileStr</a>(utf8_str.<a class="code" href="a02929.html#abf0a7b3c6ae39a46e5441f28f61de5de">string</a>(), box, target_page, &full_text);</div><div class="line"><a name="l00089"></a><span class="lineno"> 89</span>  box_texts-><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>  }</div><div class="line"><a name="l00091"></a><span class="lineno"> 91</span>  <span class="keywordflow">if</span> (pages != NULL) pages-><a class="code" href="a02297.html#a0dc89fe2a365b04a61017f9d78c1a303">push_back</a>(page);</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  ++num_boxes;</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  }</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span>  <span class="keywordflow">return</span> num_boxes > 0;</div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span> }</div><div class="ttc" id="a02297_html"><div class="ttname"><a href="a02297.html">GenericVector< STRING ></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 &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">◆ </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 * </td> <td class="paramname"><em>line_number</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">FILE * </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> * </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> * </td> <td class="paramname"><em>bounding_box</em> </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>  {</div><div class="line"><a name="l00121"></a><span class="lineno"> 121</span>  <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> }</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">◆ </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 </td> <td class="paramname"><em>target_page</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">int * </td> <td class="paramname"><em>line_number</em>, </td> </tr> <tr> <td class="paramkey"></td> <td></td> <td class="paramtype">FILE * </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> * </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> * </td> <td class="paramname"><em>bounding_box</em> </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>  {</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  <span class="keywordtype">int</span> page = 0;</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  <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>  <span class="keywordtype">char</span> *buffptr = buff;</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span> </div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <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>  (*line_number)++;</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span> </div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span>  buffptr = buff;</div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  <span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> *ubuf = <span class="keyword">reinterpret_cast<</span><span class="keyword">const </span><span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*<span class="keyword">></span>(buffptr);</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  <span class="keywordflow">if</span> (ubuf[0] == 0xef && ubuf[1] == 0xbb && ubuf[2] == 0xbf)</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  buffptr += 3; <span class="comment">// Skip unicode file designation.</span></div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  <span class="comment">// Check for blank lines in box file</span></div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  <span class="keywordflow">if</span> (*buffptr == <span class="charliteral">'\n'</span> || *buffptr == <span class="charliteral">'\0'</span>) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  <span class="comment">// Skip blank boxes.</span></div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  <span class="keywordflow">if</span> (*buffptr == <span class="charliteral">' '</span> || *buffptr == <span class="charliteral">'\t'</span>) <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  <span class="keywordflow">if</span> (*buffptr != <span class="charliteral">'\0'</span>) {</div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  <span class="keywordflow">if</span> (!<a class="code" href="a00224.html#acd464bb54397318c2f6fb8db9e644fd0">ParseBoxFileStr</a>(buffptr, &page, utf8_str, bounding_box)) {</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span>  <a class="code" href="a00608.html#a02aa7cca2c3857c14716e8cca96ace6c">tprintf</a>(<span class="stringliteral">"Box file format error on line %i; ignored\n"</span>, *line_number);</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span>  <span class="keywordflow">continue</span>;</div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span>  }</div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span>  <span class="keywordflow">if</span> (target_page >= 0 && target_page != page)</div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span>  <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>  <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>  }</div><div class="line"><a name="l00153"></a><span class="lineno"> 153</span>  }</div><div class="line"><a name="l00154"></a><span class="lineno"> 154</span>  fclose(box_file);</div><div class="line"><a name="l00155"></a><span class="lineno"> 155</span>  <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> }</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>