mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-05 02:47:00 +08:00
RecodedCharID: Use new serialization API
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
0ca7cdd2c8
commit
eb90068b5f
@ -59,21 +59,15 @@ class RecodedCharID {
|
||||
|
||||
// Writes to the given file. Returns false in case of error.
|
||||
bool Serialize(TFile* fp) const {
|
||||
if (fp->FWrite(&self_normalized_, sizeof(self_normalized_), 1) != 1)
|
||||
return false;
|
||||
if (fp->FWrite(&length_, sizeof(length_), 1) != 1) return false;
|
||||
if (fp->FWrite(code_, sizeof(code_[0]), length_) != length_) return false;
|
||||
return true;
|
||||
return fp->Serialize(&self_normalized_) &&
|
||||
fp->Serialize(&length_) &&
|
||||
fp->Serialize(&code_[0], length_);
|
||||
}
|
||||
// Reads from the given file. Returns false in case of error.
|
||||
// If swap is true, assumes a big/little-endian swap is needed.
|
||||
bool DeSerialize(TFile* fp) {
|
||||
if (fp->FRead(&self_normalized_, sizeof(self_normalized_), 1) != 1)
|
||||
return false;
|
||||
if (fp->FReadEndian(&length_, sizeof(length_), 1) != 1) return false;
|
||||
if (fp->FReadEndian(code_, sizeof(code_[0]), length_) != length_)
|
||||
return false;
|
||||
return true;
|
||||
return fp->DeSerialize(&self_normalized_) &&
|
||||
fp->DeSerialize(&length_) &&
|
||||
fp->DeSerialize(&code_[0], length_);
|
||||
}
|
||||
bool operator==(const RecodedCharID& other) const {
|
||||
if (length_ != other.length_) return false;
|
||||
|
Loading…
Reference in New Issue
Block a user