All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
tesseract::DocumentData Class Reference

#include <imagedata.h>

Public Member Functions

 DocumentData (const STRING &name)
 
 ~DocumentData ()
 
bool LoadDocument (const char *filename, const char *lang, int start_page, inT64 max_memory, FileReader reader)
 
bool SaveDocument (const char *filename, FileWriter writer)
 
bool SaveToBuffer (GenericVector< char > *buffer)
 
void AddPageToDocument (ImageData *page)
 
const STRINGdocument_name () const
 
int NumPages () const
 
inT64 memory_used () const
 
const ImageDataGetPage (int index)
 
ImageDataTakePage (int index)
 

Detailed Description

Definition at line 186 of file imagedata.h.

Constructor & Destructor Documentation

tesseract::DocumentData::DocumentData ( const STRING name)
explicit

Definition at line 339 of file imagedata.cpp.

340  : document_name_(name), pages_offset_(0), total_pages_(0),
341  memory_used_(0), max_memory_(0), reader_(NULL) {}
#define NULL
Definition: host.h:144
tesseract::DocumentData::~DocumentData ( )

Definition at line 343 of file imagedata.cpp.

343 {}

Member Function Documentation

void tesseract::DocumentData::AddPageToDocument ( ImageData page)

Definition at line 429 of file imagedata.cpp.

429  {
430  pages_.push_back(page);
431  memory_used_ += page->MemoryUsed();
432 }
const STRING& tesseract::DocumentData::document_name ( ) const
inline

Definition at line 202 of file imagedata.h.

202  {
203  return document_name_;
204  }
const ImageData * tesseract::DocumentData::GetPage ( int  index)

Definition at line 376 of file imagedata.cpp.

376  {
377  index = Modulo(index, total_pages_);
378  if (index < pages_offset_ || index >= pages_offset_ + pages_.size()) {
379  pages_offset_ = index;
380  if (!ReCachePages()) return NULL;
381  }
382  return pages_[index - pages_offset_];
383 }
int Modulo(int a, int b)
Definition: helpers.h:157
#define NULL
Definition: host.h:144
bool tesseract::DocumentData::LoadDocument ( const char *  filename,
const char *  lang,
int  start_page,
inT64  max_memory,
FileReader  reader 
)

Definition at line 347 of file imagedata.cpp.

349  {
350  document_name_ = filename;
351  lang_ = lang;
352  pages_offset_ = start_page;
353  max_memory_ = max_memory;
354  reader_ = reader;
355  return ReCachePages();
356 }
inT64 tesseract::DocumentData::memory_used ( ) const
inline

Definition at line 208 of file imagedata.h.

208  {
209  return memory_used_;
210  }
int tesseract::DocumentData::NumPages ( ) const
inline

Definition at line 205 of file imagedata.h.

205  {
206  return total_pages_;
207  }
bool tesseract::DocumentData::SaveDocument ( const char *  filename,
FileWriter  writer 
)

Definition at line 359 of file imagedata.cpp.

359  {
360  TFile fp;
361  fp.OpenWrite(NULL);
362  if (!pages_.Serialize(&fp) || !fp.CloseWrite(filename, writer)) {
363  tprintf("Serialize failed: %s\n", filename);
364  return false;
365  }
366  return true;
367 }
#define tprintf(...)
Definition: tprintf.h:31
#define NULL
Definition: host.h:144
bool tesseract::DocumentData::SaveToBuffer ( GenericVector< char > *  buffer)

Definition at line 368 of file imagedata.cpp.

368  {
369  TFile fp;
370  fp.OpenWrite(buffer);
371  return pages_.Serialize(&fp);
372 }
ImageData* tesseract::DocumentData::TakePage ( int  index)
inline

Definition at line 215 of file imagedata.h.

215  {
216  ImageData* page = pages_[index];
217  pages_[index] = NULL;
218  return page;
219  }
#define NULL
Definition: host.h:144

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