Tesseract
3.02
|
#include <unicharmap.h>
Classes | |
struct | UNICHARMAP_NODE |
Public Member Functions | |
UNICHARMAP () | |
~UNICHARMAP () | |
void | insert (const char *const unichar_repr, UNICHAR_ID id) |
UNICHAR_ID | unichar_to_id (const char *const unichar_repr) const |
UNICHAR_ID | unichar_to_id (const char *const unichar_repr, int length) const |
bool | contains (const char *const unichar_repr) const |
bool | contains (const char *const unichar_repr, int length) const |
int | minmatch (const char *const unichar_repr) const |
void | clear () |
Definition at line 27 of file unicharmap.h.
UNICHARMAP::UNICHARMAP | ( | ) |
Definition at line 25 of file unicharmap.cpp.
: nodes(0) { }
UNICHARMAP::~UNICHARMAP | ( | ) |
Definition at line 29 of file unicharmap.cpp.
{ if (nodes != 0) delete[] nodes; }
void UNICHARMAP::clear | ( | ) |
Definition at line 154 of file unicharmap.cpp.
{ if (nodes != 0) { delete[] nodes; nodes = 0; } }
bool UNICHARMAP::contains | ( | const char *const | unichar_repr | ) | const |
Definition at line 101 of file unicharmap.cpp.
{ const char* current_char = unichar_repr; UNICHARMAP_NODE* current_nodes = nodes; assert(*unichar_repr != '\0'); while (current_nodes != 0 && *(current_char + 1) != '\0') { current_nodes = current_nodes[static_cast<unsigned char>(*current_char)].children; ++current_char; } return current_nodes != 0 && *(current_char + 1) == '\0' && current_nodes[static_cast<unsigned char>(*current_char)].id >= 0; }
bool UNICHARMAP::contains | ( | const char *const | unichar_repr, |
int | length | ||
) | const |
Definition at line 120 of file unicharmap.cpp.
{ const char* current_char = unichar_repr; UNICHARMAP_NODE* current_nodes = nodes; assert(*unichar_repr != '\0'); assert(length > 0 && length <= UNICHAR_LEN); while (current_nodes != 0 && (length > 1 && *(current_char + 1) != '\0')) { current_nodes = current_nodes[static_cast<unsigned char>(*current_char)].children; --length; ++current_char; } return current_nodes != 0 && (length == 1 || *(current_char + 1) == '\0') && current_nodes[static_cast<unsigned char>(*current_char)].id >= 0; }
void UNICHARMAP::insert | ( | const char *const | unichar_repr, |
UNICHAR_ID | id | ||
) |
Definition at line 76 of file unicharmap.cpp.
{ const char* current_char = unichar_repr; UNICHARMAP_NODE** current_nodes_pointer = &nodes; assert(*unichar_repr != '\0'); assert(id >= 0); do { if (*current_nodes_pointer == 0) *current_nodes_pointer = new UNICHARMAP_NODE[256]; if (*(current_char + 1) == '\0') { (*current_nodes_pointer) [static_cast<unsigned char>(*current_char)].id = id; return; } current_nodes_pointer = &((*current_nodes_pointer) [static_cast<unsigned char>(*current_char)].children); ++current_char; } while (true); }
int UNICHARMAP::minmatch | ( | const char *const | unichar_repr | ) | const |
Definition at line 140 of file unicharmap.cpp.
{ const char* current_char = unichar_repr; UNICHARMAP_NODE* current_nodes = nodes; while (current_nodes != NULL && *current_char != '\0') { if (current_nodes[static_cast<unsigned char>(*current_char)].id >= 0) return current_char + 1 - unichar_repr; current_nodes = current_nodes[static_cast<unsigned char>(*current_char)].children; ++current_char; } return 0; }
UNICHAR_ID UNICHARMAP::unichar_to_id | ( | const char *const | unichar_repr | ) | const |
Definition at line 36 of file unicharmap.cpp.
{ const char* current_char = unichar_repr; UNICHARMAP_NODE* current_nodes = nodes; assert(*unichar_repr != '\0'); do { if (*(current_char + 1) == '\0') return current_nodes[static_cast<unsigned char>(*current_char)].id; current_nodes = current_nodes[static_cast<unsigned char>(*current_char)].children; ++current_char; } while (true); }
UNICHAR_ID UNICHARMAP::unichar_to_id | ( | const char *const | unichar_repr, |
int | length | ||
) | const |
Definition at line 54 of file unicharmap.cpp.
{ const char* current_char = unichar_repr; UNICHARMAP_NODE* current_nodes = nodes; assert(*unichar_repr != '\0'); assert(length > 0 && length <= UNICHAR_LEN); do { if (length == 1 || *(current_char + 1) == '\0') return current_nodes[static_cast<unsigned char>(*current_char)].id; current_nodes = current_nodes[static_cast<unsigned char>(*current_char)].children; ++current_char; --length; } while (true); }