tesseract 3.04.01

tesseract::InputBuffer Class Reference

#include <fileio.h>

List of all members.

Public Member Functions

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

Detailed Description

Definition at line 58 of file fileio.h.


Constructor & Destructor Documentation

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

Definition at line 135 of file fileio.cpp.

  : stream_(stream) {
    fseek(stream_, 0, SEEK_END);
    filesize_ = ftell(stream_);
    fseek(stream_, 0, SEEK_SET);
}
tesseract::InputBuffer::InputBuffer ( FILE *  stream,
size_t  size 
)

Definition at line 142 of file fileio.cpp.

  : stream_(stream) {
    fseek(stream_, 0, SEEK_END);
    filesize_ = ftell(stream_);
    fseek(stream_, 0, SEEK_SET);
}
tesseract::InputBuffer::~InputBuffer ( )

Definition at line 149 of file fileio.cpp.

                          {
  if (stream_ != NULL) {
    fclose(stream_);
  }
}

Member Function Documentation

bool tesseract::InputBuffer::CloseFile ( )

Definition at line 169 of file fileio.cpp.

                            {
  int ret = fclose(stream_);
  stream_ = NULL;
  return ret == 0;
}
bool tesseract::InputBuffer::Read ( string *  out)

Definition at line 155 of file fileio.cpp.

                                  {
  char buf[BUFSIZ + 1];
  int l;
  while ((l = fread(buf, 1, BUFSIZ, stream_)) > 0) {
    if (ferror(stream_)) {
      clearerr(stream_);
      return false;
    }
    buf[l] = 0;
    out->append(buf);
  }
  return true;
}

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines