tesseract  3.04.01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 343 of file imagedata.cpp.

344  : document_name_(name), pages_offset_(0), total_pages_(0),
345  memory_used_(0), max_memory_(0), reader_(NULL) {}
tesseract::DocumentData::~DocumentData ( )

Definition at line 347 of file imagedata.cpp.

347 {}

Member Function Documentation

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

Definition at line 433 of file imagedata.cpp.

433  {
434  pages_.push_back(page);
435  memory_used_ += page->MemoryUsed();
436 }
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 380 of file imagedata.cpp.

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

Definition at line 351 of file imagedata.cpp.

353  {
354  document_name_ = filename;
355  lang_ = lang;
356  pages_offset_ = start_page;
357  max_memory_ = max_memory;
358  reader_ = reader;
359  return ReCachePages();
360 }
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 363 of file imagedata.cpp.

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

Definition at line 372 of file imagedata.cpp.

372  {
373  TFile fp;
374  fp.OpenWrite(buffer);
375  return pages_.Serialize(&fp);
376 }
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  }

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