Skip to content

Commit 36f7688

Browse files
committed
Modernize C++ code using override
The modifications were done using this command: run-clang-tidy-8.py -header-filter='.*' -checks='-*,modernize-use-override' -fix Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent f877640 commit 36f7688

39 files changed

+123
-123
lines changed

src/api/renderer.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ class TESS_API TessTextRenderer : public TessResultRenderer {
148148
explicit TessTextRenderer(const char *outputbase);
149149

150150
protected:
151-
virtual bool AddImageHandler(TessBaseAPI* api);
151+
bool AddImageHandler(TessBaseAPI* api) override;
152152
};
153153

154154
/**
@@ -160,9 +160,9 @@ class TESS_API TessHOcrRenderer : public TessResultRenderer {
160160
explicit TessHOcrRenderer(const char *outputbase);
161161

162162
protected:
163-
virtual bool BeginDocumentHandler();
164-
virtual bool AddImageHandler(TessBaseAPI* api);
165-
virtual bool EndDocumentHandler();
163+
bool BeginDocumentHandler() override;
164+
bool AddImageHandler(TessBaseAPI* api) override;
165+
bool EndDocumentHandler() override;
166166

167167
private:
168168
bool font_info_; // whether to print font information
@@ -176,9 +176,9 @@ class TESS_API TessHOcrRenderer : public TessResultRenderer {
176176
explicit TessAltoRenderer(const char *outputbase);
177177

178178
protected:
179-
virtual bool BeginDocumentHandler();
180-
virtual bool AddImageHandler(TessBaseAPI* api);
181-
virtual bool EndDocumentHandler();
179+
bool BeginDocumentHandler() override;
180+
bool AddImageHandler(TessBaseAPI* api) override;
181+
bool EndDocumentHandler() override;
182182

183183
};
184184

@@ -191,9 +191,9 @@ class TESS_API TessTsvRenderer : public TessResultRenderer {
191191
explicit TessTsvRenderer(const char* outputbase);
192192

193193
protected:
194-
virtual bool BeginDocumentHandler();
195-
virtual bool AddImageHandler(TessBaseAPI* api);
196-
virtual bool EndDocumentHandler();
194+
bool BeginDocumentHandler() override;
195+
bool AddImageHandler(TessBaseAPI* api) override;
196+
bool EndDocumentHandler() override;
197197

198198
private:
199199
bool font_info_; // whether to print font information
@@ -209,9 +209,9 @@ class TESS_API TessPDFRenderer : public TessResultRenderer {
209209
TessPDFRenderer(const char* outputbase, const char* datadir, bool textonly = false);
210210

211211
protected:
212-
virtual bool BeginDocumentHandler();
213-
virtual bool AddImageHandler(TessBaseAPI* api);
214-
virtual bool EndDocumentHandler();
212+
bool BeginDocumentHandler() override;
213+
bool AddImageHandler(TessBaseAPI* api) override;
214+
bool EndDocumentHandler() override;
215215

216216
private:
217217
// We don't want to have every image in memory at once,
@@ -244,7 +244,7 @@ class TESS_API TessUnlvRenderer : public TessResultRenderer {
244244
explicit TessUnlvRenderer(const char *outputbase);
245245

246246
protected:
247-
virtual bool AddImageHandler(TessBaseAPI* api);
247+
bool AddImageHandler(TessBaseAPI* api) override;
248248
};
249249

250250
/**
@@ -255,7 +255,7 @@ class TESS_API TessLSTMBoxRenderer : public TessResultRenderer {
255255
explicit TessLSTMBoxRenderer(const char* outputbase);
256256

257257
protected:
258-
virtual bool AddImageHandler(TessBaseAPI* api);
258+
bool AddImageHandler(TessBaseAPI* api) override;
259259
};
260260

261261
/**
@@ -266,7 +266,7 @@ class TESS_API TessBoxTextRenderer : public TessResultRenderer {
266266
explicit TessBoxTextRenderer(const char *outputbase);
267267

268268
protected:
269-
virtual bool AddImageHandler(TessBaseAPI* api);
269+
bool AddImageHandler(TessBaseAPI* api) override;
270270
};
271271

272272
/**
@@ -277,7 +277,7 @@ class TESS_API TessWordStrBoxRenderer : public TessResultRenderer {
277277
explicit TessWordStrBoxRenderer(const char* outputbase);
278278

279279
protected:
280-
virtual bool AddImageHandler(TessBaseAPI* api);
280+
bool AddImageHandler(TessBaseAPI* api) override;
281281
};
282282

283283
#ifndef DISABLED_LEGACY_ENGINE
@@ -290,7 +290,7 @@ class TESS_API TessOsdRenderer : public TessResultRenderer {
290290
explicit TessOsdRenderer(const char* outputbase);
291291

292292
protected:
293-
virtual bool AddImageHandler(TessBaseAPI* api);
293+
bool AddImageHandler(TessBaseAPI* api) override;
294294
};
295295

296296
#endif // ndef DISABLED_LEGACY_ENGINE

src/ccmain/equationdetect.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class EquationDetect : public EquationDetectBase {
4040
public:
4141
EquationDetect(const char* equ_datapath,
4242
const char* equ_language);
43-
~EquationDetect();
43+
~EquationDetect() override;
4444

4545
enum IndentType {
4646
NO_INDENT,
@@ -57,13 +57,13 @@ class EquationDetect : public EquationDetectBase {
5757
// Iterate over the blobs inside to_block, and set the blobs that we want to
5858
// process to BSTT_NONE. (By default, they should be BSTT_SKIP). The function
5959
// returns 0 upon success.
60-
int LabelSpecialText(TO_BLOCK* to_block);
60+
int LabelSpecialText(TO_BLOCK* to_block) override;
6161

6262
// Find possible equation partitions from part_grid. Should be called
6363
// after the special_text_type of blobs are set.
6464
// It returns 0 upon success.
6565
int FindEquationParts(ColPartitionGrid* part_grid,
66-
ColPartitionSet** best_columns);
66+
ColPartitionSet** best_columns) override;
6767

6868
// Reset the resolution of the processing image. TEST only function.
6969
void SetResolution(const int resolution);

src/ccmain/ltrresultiterator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class TESS_API LTRResultIterator : public PageIterator {
6565
int rect_left, int rect_top,
6666
int rect_width, int rect_height);
6767

68-
virtual ~LTRResultIterator();
68+
~LTRResultIterator() override;
6969

7070
// LTRResultIterators may be copied! This makes it possible to iterate over
7171
// all the objects at a lower level, while maintaining an iterator to

src/ccmain/mutableiterator.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class MutableIterator : public ResultIterator {
5151
: ResultIterator(
5252
LTRResultIterator(page_res, tesseract, scale, scaled_yres, rect_left,
5353
rect_top, rect_width, rect_height)) {}
54-
virtual ~MutableIterator();
54+
~MutableIterator() override;
5555

5656
// See PageIterator and ResultIterator for most calls.
5757

src/ccmain/paramsd.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class ParamsEditor : public SVEventHandler {
103103
explicit ParamsEditor(tesseract::Tesseract*, ScrollView* sv = nullptr);
104104

105105
// Event listener. Waits for SVET_POPUP events and processes them.
106-
void Notify(const SVEvent* sve);
106+
void Notify(const SVEvent* sve) override;
107107

108108
private:
109109
// Gets the up to the first 3 prefixes from s (split by _).

src/ccmain/pgedit.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ STRING_VAR(editor_debug_config_file, "", "Config file to apply to single words")
148148

149149
class BlnEventHandler : public SVEventHandler {
150150
public:
151-
void Notify(const SVEvent* sv_event) {
151+
void Notify(const SVEvent* sv_event) override {
152152
if (sv_event->type == SVET_DESTROY)
153153
bln_word_window = nullptr;
154154
else if (sv_event->type == SVET_CLICK)

src/ccmain/pgedit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class PGEventHandler : public SVEventHandler {
3636
public:
3737
PGEventHandler(tesseract::Tesseract* tess) : tess_(tess) {
3838
}
39-
void Notify(const SVEvent* sve);
39+
void Notify(const SVEvent* sve) override;
4040
private:
4141
tesseract::Tesseract* tess_;
4242
};

src/ccmain/resultiterator.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,14 @@ class TESS_API ResultIterator : public LTRResultIterator {
4646
* ResultIterator is copy constructible!
4747
* The default copy constructor works just fine for us.
4848
*/
49-
virtual ~ResultIterator() = default;
49+
~ResultIterator() override = default;
5050

5151
// ============= Moving around within the page ============.
5252
/**
5353
* Moves the iterator to point to the start of the page to begin
5454
* an iteration.
5555
*/
56-
virtual void Begin();
56+
void Begin() override;
5757

5858
/**
5959
* Moves to the start of the next object at the given level in the
@@ -67,23 +67,23 @@ class TESS_API ResultIterator : public LTRResultIterator {
6767
* This function iterates words in right-to-left scripts correctly, if
6868
* the appropriate language has been loaded into Tesseract.
6969
*/
70-
virtual bool Next(PageIteratorLevel level);
70+
bool Next(PageIteratorLevel level) override;
7171

7272
/**
7373
* IsAtBeginningOf() returns whether we're at the logical beginning of the
7474
* given level. (as opposed to ResultIterator's left-to-right top-to-bottom
7575
* order). Otherwise, this acts the same as PageIterator::IsAtBeginningOf().
7676
* For a full description, see pageiterator.h
7777
*/
78-
virtual bool IsAtBeginningOf(PageIteratorLevel level) const;
78+
bool IsAtBeginningOf(PageIteratorLevel level) const override;
7979

8080
/**
8181
* Implement PageIterator's IsAtFinalElement correctly in a BiDi context.
8282
* For instance, IsAtFinalElement(RIL_PARA, RIL_WORD) returns whether we
8383
* point at the last word in a paragraph. See PageIterator for full comment.
8484
*/
85-
virtual bool IsAtFinalElement(PageIteratorLevel level,
86-
PageIteratorLevel element) const;
85+
bool IsAtFinalElement(PageIteratorLevel level,
86+
PageIteratorLevel element) const override;
8787

8888
// ============= Functions that refer to words only ============.
8989
// Returns the number of blanks before the current word.

src/ccmain/tesseractclass.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ typedef void (Tesseract::*WordRecognizer)(const WordData& word_data,
173173
class Tesseract : public Wordrec {
174174
public:
175175
Tesseract();
176-
~Tesseract();
176+
~Tesseract() override;
177177

178178
// Return appropriate dictionary
179179
Dict& getDict() override;

src/ccstruct/ccstruct.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace tesseract {
2525
class CCStruct : public CUtil {
2626
public:
2727
CCStruct() = default;
28-
virtual ~CCStruct();
28+
~CCStruct() override;
2929

3030
// Globally accessible constants.
3131
// APPROXIMATIONS of the fractions of the character cell taken by

src/ccstruct/matrix.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ class BandTriMatrix : public GENERIC_2D_ARRAY<T> {
540540
// Expression to select a specific location in the matrix. The matrix is
541541
// stored COLUMN-major, so the left-most index is the most significant.
542542
// This allows [][] access to use indices in the same order as (,).
543-
virtual int index(int column, int row) const {
543+
int index(int column, int row) const override {
544544
ASSERT_HOST(row >= column);
545545
ASSERT_HOST(row - column < this->dim2_);
546546
return column * this->dim2_ + row - column;
@@ -580,7 +580,7 @@ class MATRIX : public BandTriMatrix<BLOB_CHOICE_LIST *> {
580580
MATRIX(int dimension, int bandwidth)
581581
: BandTriMatrix<BLOB_CHOICE_LIST *>(dimension, bandwidth, NOT_CLASSIFIED) {}
582582

583-
virtual ~MATRIX();
583+
~MATRIX() override;
584584

585585
// Returns true if there are any real classification results.
586586
bool Classified(int col, int row, int wildcard_id) const;

src/ccutil/indexmapbidi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class IndexMap {
101101
// Allows a many-to-one mapping by merging compact space indices.
102102
class IndexMapBiDi : public IndexMap {
103103
public:
104-
virtual ~IndexMapBiDi();
104+
~IndexMapBiDi() override;
105105

106106
// Top-level init function in a single call to initialize a map to select
107107
// a single contiguous subrange [start, end) of the sparse space to be mapped
@@ -135,11 +135,11 @@ class IndexMapBiDi : public IndexMap {
135135
void CompleteMerges();
136136

137137
// SparseToCompact takes a sparse index to an index in the compact space.
138-
virtual int SparseToCompact(int sparse_index) const {
138+
int SparseToCompact(int sparse_index) const override {
139139
return sparse_map_[sparse_index];
140140
}
141141
// The size of the sparse space.
142-
virtual int SparseSize() const {
142+
int SparseSize() const override {
143143
return sparse_map_.size();
144144
}
145145

0 commit comments

Comments
 (0)