@@ -67,14 +67,12 @@ int UnicharRating::FirstResultWithUnichar(
67
67
68
68
// Writes to the given file. Returns false in case of error.
69
69
bool UnicharAndFonts::Serialize (FILE* fp) const {
70
- if (fwrite (&unichar_id, sizeof (unichar_id), 1 , fp) != 1 ) return false ;
71
- return font_ids.Serialize (fp);
70
+ return tesseract::Serialize (fp, &unichar_id) && font_ids.Serialize (fp);
72
71
}
73
72
// Reads from the given file. Returns false in case of error.
74
73
75
74
bool UnicharAndFonts::DeSerialize (TFile* fp) {
76
- if (fp->FReadEndian (&unichar_id, sizeof (unichar_id), 1 ) != 1 ) return false ;
77
- return font_ids.DeSerialize (fp);
75
+ return fp->DeSerialize (&unichar_id) && font_ids.DeSerialize (fp);
78
76
}
79
77
80
78
// Sort function to sort a pair of UnicharAndFonts by unichar_id.
@@ -87,15 +85,13 @@ int UnicharAndFonts::SortByUnicharId(const void* v1, const void* v2) {
87
85
// Writes to the given file. Returns false in case of error.
88
86
bool Shape::Serialize (FILE* fp) const {
89
87
uint8_t sorted = unichars_sorted_;
90
- if (fwrite (&sorted, sizeof (sorted), 1 , fp) != 1 )
91
- return false ;
92
- return unichars_.SerializeClasses (fp);
88
+ return tesseract::Serialize (fp, &sorted) && unichars_.SerializeClasses (fp);
93
89
}
94
90
// Reads from the given file. Returns false in case of error.
95
91
96
92
bool Shape::DeSerialize (TFile* fp) {
97
93
uint8_t sorted;
98
- if (fp->FRead (&sorted, sizeof (sorted), 1 ) != 1 ) return false ;
94
+ if (! fp->DeSerialize (&sorted) ) return false ;
99
95
unichars_sorted_ = sorted != 0 ;
100
96
return unichars_.DeSerializeClasses (fp);
101
97
}
0 commit comments