tesseract v5.3.3.20231005
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 70 of file fileio.h.

Constructor & Destructor Documentation

◆ InputBuffer() [1/2]

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

Definition at line 134 of file fileio.cpp.

134: stream_(stream) {}

◆ InputBuffer() [2/2]

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

Definition at line 136 of file fileio.cpp.

136: stream_(stream) {}

◆ ~InputBuffer()

tesseract::InputBuffer::~InputBuffer ( )

Definition at line 138 of file fileio.cpp.

138 {
139 if (stream_ != nullptr) {
140 fclose(stream_);
141 }
142}

Member Function Documentation

◆ CloseFile()

bool tesseract::InputBuffer::CloseFile ( )

Definition at line 158 of file fileio.cpp.

158 {
159 int ret = fclose(stream_);
160 stream_ = nullptr;
161 return ret == 0;
162}

◆ Read()

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

Definition at line 144 of file fileio.cpp.

144 {
145 char buf[BUFSIZ + 1];
146 int l;
147 while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
148 if (ferror(stream_)) {
149 clearerr(stream_);
150 return false;
151 }
152 buf[l] = 0;
153 out->append(buf);
154 }
155 return true;
156}

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