tesseract  4.1.1
tesseract::FontInfoTable Class Reference

#include <fontinfo.h>

Inheritance diagram for tesseract::FontInfoTable:
GenericVector< FontInfo >

Public Member Functions

 FontInfoTable ()
 
 ~FontInfoTable ()
 
bool Serialize (FILE *fp) const
 
bool DeSerialize (TFile *fp)
 
bool SetContainsFontProperties (int font_id, const GenericVector< ScoredFont > &font_set) const
 
bool SetContainsMultipleFontProperties (const GenericVector< ScoredFont > &font_set) const
 
void MoveSpacingInfoFrom (FontInfoTable *other)
 
void MoveTo (UnicityTable< FontInfo > *target)
 
- Public Member Functions inherited from GenericVector< FontInfo >
 GenericVector ()
 
 GenericVector (int size, const FontInfo &init_val)
 
 GenericVector (const GenericVector &other)
 
GenericVector< FontInfo > & operator+= (const GenericVector &other)
 
void operator+= (const FontInfo &t)
 
GenericVector< FontInfo > & operator= (const GenericVector &other)
 
 ~GenericVector ()
 
void reserve (int size)
 
void double_the_size ()
 
void init_to_size (int size, const FontInfo &t)
 
void resize_no_init (int size)
 
int size () const
 
size_t unsigned_size () const
 
int size_reserved () const
 
int length () const
 
bool empty () const
 
FontInfo & get (int index) const
 
FontInfo & back () const
 
FontInfo & operator[] (int index) const
 
FontInfo pop_back ()
 
int get_index (const FontInfo &object) const
 
bool contains (const FontInfo &object) const
 
FontInfo contains_index (int index) const
 
int push_back (FontInfo object)
 
int push_back_new (const FontInfo &object)
 
int push_front (const FontInfo &object)
 
void set (const FontInfo &t, int index)
 
void insert (const FontInfo &t, int index)
 
void remove (int index)
 
void truncate (int size)
 
void set_clear_callback (TessCallback1< FontInfo > *cb)
 
void set_compare_callback (TessResultCallback2< bool, FontInfo const &, FontInfo const & > *cb)
 
void clear ()
 
void delete_data_pointers ()
 
void move (GenericVector< FontInfo > *from)
 
bool write (FILE *f, TessResultCallback2< bool, FILE *, FontInfo const & > *cb) const
 
bool read (tesseract::TFile *f, TessResultCallback2< bool, tesseract::TFile *, FontInfo * > *cb)
 
bool Serialize (FILE *fp) const
 
bool Serialize (tesseract::TFile *fp) const
 
bool DeSerialize (bool swap, FILE *fp)
 
bool DeSerialize (tesseract::TFile *fp)
 
bool SerializeClasses (FILE *fp) const
 
bool SerializeClasses (tesseract::TFile *fp) const
 
bool DeSerializeClasses (bool swap, FILE *fp)
 
bool DeSerializeClasses (tesseract::TFile *fp)
 
void reverse ()
 
void sort ()
 
void sort (int(*comparator)(const void *, const void *))
 
bool bool_binary_search (const FontInfo &target) const
 
int binary_search (const FontInfo &target) const
 
void compact_sorted ()
 
void compact (TessResultCallback1< bool, int > *delete_cb)
 
FontInfo dot_product (const GenericVector< FontInfo > &other) const
 
int choose_nth_item (int target_index)
 
void swap (int index1, int index2)
 
bool WithinBounds (const FontInfo &rangemin, const FontInfo &rangemax) const
 

Additional Inherited Members

- Static Public Member Functions inherited from GenericVector< FontInfo >
static bool SkipDeSerialize (tesseract::TFile *fp)
 
static bool SkipDeSerializeClasses (tesseract::TFile *fp)
 
static FontInfo * double_the_size_memcpy (int current_size, FontInfo *data)
 
- Protected Member Functions inherited from GenericVector< FontInfo >
int choose_nth_item (int target_index, int start, int end, unsigned int *seed)
 
void init (int size)
 
- Protected Attributes inherited from GenericVector< FontInfo >
int32_t size_used_
 
int32_t size_reserved_
 
FontInfo * data_
 
TessCallback1< FontInfo > * clear_cb_
 
TessResultCallback2< bool, FontInfo const &, FontInfo const &> * compare_cb_
 
- Static Protected Attributes inherited from GenericVector< FontInfo >
static const int kDefaultVectorSize
 

Detailed Description

Definition at line 146 of file fontinfo.h.

Constructor & Destructor Documentation

◆ FontInfoTable()

tesseract::FontInfoTable::FontInfoTable ( )

Definition at line 39 of file fontinfo.cpp.

39  {
42 }
void set_clear_callback(TessCallback1< FontInfo > *cb)
_ConstTessMemberResultCallback_5_0< false, R, T1, P1, P2, P3, P4, P5 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)(P1, P2, P3, P4, P5) const, typename Identity< P1 >::type p1, typename Identity< P2 >::type p2, typename Identity< P3 >::type p3, typename Identity< P4 >::type p4, typename Identity< P5 >::type p5)
Definition: tesscallback.h:258
void FontInfoDeleteCallback(FontInfo f)
Definition: fontinfo.cpp:138
bool CompareFontInfo(const FontInfo &fi1, const FontInfo &fi2)
Definition: fontinfo.cpp:119
void set_compare_callback(TessResultCallback2< bool, FontInfo const &, FontInfo const & > *cb)

◆ ~FontInfoTable()

tesseract::FontInfoTable::~FontInfoTable ( )

Definition at line 44 of file fontinfo.cpp.

44  {
45 }

Member Function Documentation

◆ DeSerialize()

bool tesseract::FontInfoTable::DeSerialize ( TFile fp)

Definition at line 53 of file fontinfo.cpp.

53  {
54  truncate(0);
55  return this->DeSerializeClasses(fp);
56 }
bool DeSerializeClasses(bool swap, FILE *fp)

◆ MoveSpacingInfoFrom()

void tesseract::FontInfoTable::MoveSpacingInfoFrom ( FontInfoTable other)

Definition at line 84 of file fontinfo.cpp.

84  {
87  for (int i = 0; i < other->size(); ++i) {
88  GenericVector<FontSpacingInfo*>* spacing_vec = other->get(i).spacing_vec;
89  if (spacing_vec != nullptr) {
90  int target_index = get_index(other->get(i));
91  if (target_index < 0) {
92  // Bit copy the FontInfo and steal all the pointers.
93  push_back(other->get(i));
94  other->get(i).name = nullptr;
95  } else {
96  delete get(target_index).spacing_vec;
97  get(target_index).spacing_vec = other->get(i).spacing_vec;
98  }
99  other->get(i).spacing_vec = nullptr;
100  }
101  }
102 }
int get_index(const FontInfo &object) const
T & get(int index) const
void set_clear_callback(TessCallback1< FontInfo > *cb)
_ConstTessMemberResultCallback_5_0< false, R, T1, P1, P2, P3, P4, P5 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)(P1, P2, P3, P4, P5) const, typename Identity< P1 >::type p1, typename Identity< P2 >::type p2, typename Identity< P3 >::type p3, typename Identity< P4 >::type p4, typename Identity< P5 >::type p5)
Definition: tesscallback.h:258
void FontInfoDeleteCallback(FontInfo f)
Definition: fontinfo.cpp:138
int push_back(FontInfo object)
bool CompareFontInfo(const FontInfo &fi1, const FontInfo &fi2)
Definition: fontinfo.cpp:119
void set_compare_callback(TessResultCallback2< bool, FontInfo const &, FontInfo const & > *cb)

◆ MoveTo()

void tesseract::FontInfoTable::MoveTo ( UnicityTable< FontInfo > *  target)

Definition at line 105 of file fontinfo.cpp.

105  {
106  target->clear();
109  for (int i = 0; i < size(); ++i) {
110  // Bit copy the FontInfo and steal all the pointers.
111  target->push_back(get(i));
112  get(i).name = nullptr;
113  get(i).spacing_vec = nullptr;
114  }
115 }
void set_clear_callback(TessCallback1< T > *cb)
int push_back(T object)
Add an element in the table.
_ConstTessMemberResultCallback_5_0< false, R, T1, P1, P2, P3, P4, P5 >::base * NewPermanentTessCallback(const T1 *obj, R(T2::*member)(P1, P2, P3, P4, P5) const, typename Identity< P1 >::type p1, typename Identity< P2 >::type p2, typename Identity< P3 >::type p3, typename Identity< P4 >::type p4, typename Identity< P5 >::type p5)
Definition: tesscallback.h:258
void FontInfoDeleteCallback(FontInfo f)
Definition: fontinfo.cpp:138
void set_compare_callback(TessResultCallback2< bool, T const &, T const &> *cb)
bool CompareFontInfo(const FontInfo &fi1, const FontInfo &fi2)
Definition: fontinfo.cpp:119

◆ Serialize()

bool tesseract::FontInfoTable::Serialize ( FILE *  fp) const

Definition at line 48 of file fontinfo.cpp.

48  {
49  return this->SerializeClasses(fp);
50 }
bool SerializeClasses(FILE *fp) const

◆ SetContainsFontProperties()

bool tesseract::FontInfoTable::SetContainsFontProperties ( int  font_id,
const GenericVector< ScoredFont > &  font_set 
) const

Definition at line 60 of file fontinfo.cpp.

61  {
62  uint32_t properties = get(font_id).properties;
63  for (int f = 0; f < font_set.size(); ++f) {
64  if (get(font_set[f].fontinfo_id).properties == properties)
65  return true;
66  }
67  return false;
68 }
int size() const
Definition: genericvector.h:72

◆ SetContainsMultipleFontProperties()

bool tesseract::FontInfoTable::SetContainsMultipleFontProperties ( const GenericVector< ScoredFont > &  font_set) const

Definition at line 71 of file fontinfo.cpp.

72  {
73  if (font_set.empty()) return false;
74  int first_font = font_set[0].fontinfo_id;
75  uint32_t properties = get(first_font).properties;
76  for (int f = 1; f < font_set.size(); ++f) {
77  if (get(font_set[f].fontinfo_id).properties != properties)
78  return true;
79  }
80  return false;
81 }
bool empty() const
Definition: genericvector.h:91
int size() const
Definition: genericvector.h:72

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