tesseract  4.00.00dev
tesseract::RecodedCharID Class Reference

#include <unicharcompress.h>

Classes

struct  RecodedCharIDHash
 

Public Member Functions

 RecodedCharID ()
 
void Truncate (int length)
 
void Set (int index, int value)
 
void Set3 (int code0, int code1, int code2)
 
bool self_normalized () const
 
void set_self_normalized (bool value)
 
int length () const
 
int operator() (int index) const
 
bool Serialize (TFile *fp) const
 
bool DeSerialize (TFile *fp)
 
bool operator== (const RecodedCharID &other) const
 

Static Public Attributes

static const int kMaxCodeLen = 9
 

Detailed Description

Definition at line 34 of file unicharcompress.h.

Constructor & Destructor Documentation

◆ RecodedCharID()

tesseract::RecodedCharID::RecodedCharID ( )
inline

Definition at line 39 of file unicharcompress.h.

39  : self_normalized_(0), length_(0) {
40  memset(code_, 0, sizeof(code_));
41  }

Member Function Documentation

◆ DeSerialize()

bool tesseract::RecodedCharID::DeSerialize ( TFile fp)
inline

Definition at line 72 of file unicharcompress.h.

72  {
73  if (fp->FRead(&self_normalized_, sizeof(self_normalized_), 1) != 1)
74  return false;
75  if (fp->FReadEndian(&length_, sizeof(length_), 1) != 1) return false;
76  if (fp->FReadEndian(code_, sizeof(code_[0]), length_) != length_)
77  return false;
78  return true;
79  }

◆ length()

int tesseract::RecodedCharID::length ( ) const
inline

Definition at line 59 of file unicharcompress.h.

59 { return length_; }

◆ operator()()

int tesseract::RecodedCharID::operator() ( int  index) const
inline

Definition at line 60 of file unicharcompress.h.

60 { return code_[index]; }

◆ operator==()

bool tesseract::RecodedCharID::operator== ( const RecodedCharID other) const
inline

Definition at line 80 of file unicharcompress.h.

80  {
81  if (length_ != other.length_) return false;
82  for (int i = 0; i < length_; ++i) {
83  if (code_[i] != other.code_[i]) return false;
84  }
85  return true;
86  }

◆ self_normalized()

bool tesseract::RecodedCharID::self_normalized ( ) const
inline

Definition at line 57 of file unicharcompress.h.

57 { return self_normalized_ != 0; }

◆ Serialize()

bool tesseract::RecodedCharID::Serialize ( TFile fp) const
inline

Definition at line 63 of file unicharcompress.h.

63  {
64  if (fp->FWrite(&self_normalized_, sizeof(self_normalized_), 1) != 1)
65  return false;
66  if (fp->FWrite(&length_, sizeof(length_), 1) != 1) return false;
67  if (fp->FWrite(code_, sizeof(code_[0]), length_) != length_) return false;
68  return true;
69  }

◆ Set()

void tesseract::RecodedCharID::Set ( int  index,
int  value 
)
inline

Definition at line 44 of file unicharcompress.h.

44  {
45  code_[index] = value;
46  if (length_ <= index) length_ = index + 1;
47  }

◆ Set3()

void tesseract::RecodedCharID::Set3 ( int  code0,
int  code1,
int  code2 
)
inline

Definition at line 50 of file unicharcompress.h.

50  {
51  length_ = 3;
52  code_[0] = code0;
53  code_[1] = code1;
54  code_[2] = code2;
55  }

◆ set_self_normalized()

void tesseract::RecodedCharID::set_self_normalized ( bool  value)
inline

Definition at line 58 of file unicharcompress.h.

58 { self_normalized_ = value; }

◆ Truncate()

void tesseract::RecodedCharID::Truncate ( int  length)
inline

Definition at line 42 of file unicharcompress.h.

42 { length_ = length; }

Member Data Documentation

◆ kMaxCodeLen

const int tesseract::RecodedCharID::kMaxCodeLen = 9
static

Definition at line 37 of file unicharcompress.h.


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