tesseract 4.1.1
Loading...
Searching...
No Matches
tesseract::InputBuffer Class Reference

#include <fileio.h>

Public Member Functions

 InputBuffer (FILE *stream)
 
 InputBuffer (FILE *stream, size_t size)
 
 ~InputBuffer ()
 
bool Read (std::string *out)
 
bool CloseFile ()
 

Detailed Description

Definition at line 69 of file fileio.h.

Constructor & Destructor Documentation

◆ InputBuffer() [1/2]

tesseract::InputBuffer::InputBuffer ( FILE *  stream)
explicit

Definition at line 138 of file fileio.cpp.

139 : stream_(stream) {
140}

◆ InputBuffer() [2/2]

tesseract::InputBuffer::InputBuffer ( FILE *  stream,
size_t  size 
)

Definition at line 142 of file fileio.cpp.

143 : stream_(stream) {
144}

◆ ~InputBuffer()

tesseract::InputBuffer::~InputBuffer ( )

Definition at line 146 of file fileio.cpp.

146 {
147 if (stream_ != nullptr) {
148 fclose(stream_);
149 }
150}

Member Function Documentation

◆ CloseFile()

bool tesseract::InputBuffer::CloseFile ( )

Definition at line 166 of file fileio.cpp.

166 {
167 int ret = fclose(stream_);
168 stream_ = nullptr;
169 return ret == 0;
170}

◆ Read()

bool tesseract::InputBuffer::Read ( std::string *  out)

Definition at line 152 of file fileio.cpp.

152 {
153 char buf[BUFSIZ + 1];
154 int l;
155 while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
156 if (ferror(stream_)) {
157 clearerr(stream_);
158 return false;
159 }
160 buf[l] = 0;
161 out->append(buf);
162 }
163 return true;
164}

The documentation for this class was generated from the following files: