Skip to content

Commit 55f0ca5

Browse files
committed
Add missing include statements and clean some include statements
The changes are based on an analysis done with include-what-you-use. Signed-off-by: Stefan Weil <[email protected]>
1 parent 71bb9c3 commit 55f0ca5

31 files changed

+376
-231
lines changed

src/api/baseapi.cpp

+49-39
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222
#include "config_auto.h"
2323
#endif
2424

25+
#include "baseapi.h"
2526
#ifdef __linux__
26-
#include <signal.h>
27+
#include <signal.h> // for sigaction, SA_RESETHAND, SIGBUS, SIGFPE
2728
#endif
2829

2930
#if defined(_WIN32)
@@ -34,49 +35,58 @@
3435
#include <fcntl.h>
3536
#include <io.h>
3637
#else
37-
#include <dirent.h>
38+
#include <dirent.h> // for closedir, opendir, readdir, DIR, dirent
3839
#include <libgen.h>
39-
#include <cstring>
4040
#include <sys/types.h>
41-
#include <sys/stat.h>
41+
#include <sys/stat.h> // for stat, S_IFDIR
4242
#include <unistd.h>
4343
#endif // _WIN32
4444

45-
#include <algorithm>
46-
#include <clocale>
47-
#include <fstream>
48-
#include <iostream>
49-
#include <iterator>
50-
#include <memory> // std::unique_ptr
51-
#include <string>
52-
53-
#include "allheaders.h"
54-
55-
#include "baseapi.h"
56-
#include "blobclass.h"
57-
#include "resultiterator.h"
58-
#include "mutableiterator.h"
59-
#include "thresholder.h"
60-
#include "tesseractclass.h"
61-
#include "pageres.h"
62-
#include "paragraphs.h"
63-
#include "tessvars.h"
64-
#include "control.h"
65-
#include "dict.h"
66-
#include "pgedit.h"
67-
#include "paramsd.h"
68-
#include "output.h"
69-
#include "globaloc.h"
70-
#include "globals.h"
71-
#include "edgblob.h"
72-
#include "equationdetect.h"
73-
#include "makerow.h"
74-
#include "otsuthr.h"
75-
#include "osdetect.h"
76-
#include "params.h"
77-
#include "renderer.h"
78-
#include "strngs.h"
79-
#include "openclwrapper.h"
45+
#include <clocale> // for LC_ALL, LC_CTYPE, LC_NUMERIC
46+
#include <cmath> // for round, M_PI
47+
#include <cstdint> // for int32_t
48+
#include <cstring> // for strcmp, strcpy
49+
#include <fstream> // for size_t
50+
#include <iostream> // for std::cin
51+
#include <memory> // for std::unique_ptr
52+
#include "allheaders.h" // for pixDestroy, boxCreate, boxaAddBox, box...
53+
#include "blobclass.h" // for ExtractFontName
54+
#include "boxword.h" // for BoxWord
55+
#include "config_auto.h" // for PACKAGE_VERSION
56+
#include "coutln.h" // for C_OUTLINE_IT, C_OUTLINE_LIST
57+
#include "dawg_cache.h" // for DawgCache
58+
#include "dict.h" // for Dict
59+
#include "edgblob.h" // for extract_edges
60+
#include "elst.h" // for ELIST_ITERATOR, ELISTIZE, ELISTIZEH
61+
#include "environ.h" // for l_uint8, FALSE, TRUE
62+
#include "equationdetect.h" // for EquationDetect
63+
#include "errcode.h" // for ASSERT_HOST
64+
#include "globaloc.h" // for SavePixForCrash, signal_exit
65+
#include "helpers.h" // for IntCastRounded, chomp_string
66+
#include "host.h" // for BOOL8
67+
#include "imageio.h" // for IFF_TIFF_G4, IFF_TIFF, IFF_TIFF_G3
68+
#include "intfx.h" // for INT_FX_RESULT_STRUCT
69+
#include "mutableiterator.h" // for MutableIterator
70+
#include "normalis.h" // for kBlnBaselineOffset, kBlnXHeight
71+
#include "ocrclass.h" // for ETEXT_DESC
72+
#include "openclwrapper.h" // for PERF_COUNT_END, PERF_COUNT_START, PERF...
73+
#include "osdetect.h" // for OSResults, OSBestResult, OrientationId...
74+
#include "pageres.h" // for PAGE_RES_IT, WERD_RES, PAGE_RES, CR_DE...
75+
#include "paragraphs.h" // for DetectParagraphs
76+
#include "params.h" // for BoolParam, IntParam, DoubleParam, Stri...
77+
#include "pdblock.h" // for PDBLK
78+
#include "points.h" // for FCOORD
79+
#include "polyblk.h" // for POLY_BLOCK
80+
#include "rect.h" // for TBOX
81+
#include "renderer.h" // for TessResultRenderer
82+
#include "resultiterator.h" // for ResultIterator
83+
#include "stepblob.h" // for C_BLOB_IT, C_BLOB, C_BLOB_LIST
84+
#include "strngs.h" // for STRING
85+
#include "tessdatamanager.h" // for TessdataManager, kTrainedDataSuffix
86+
#include "tesseractclass.h" // for Tesseract
87+
#include "thresholder.h" // for ImageThresholder
88+
#include "tprintf.h" // for tprintf
89+
#include "werd.h" // for WERD, WERD_IT, W_FUZZY_NON, W_FUZZY_SP
8090

8191
BOOL_VAR(stream_filelist, FALSE, "Stream a filelist from stdin");
8292

src/api/renderer.h

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
// and hide includes of complex types in baseapi.cpp.
2424
#include "genericvector.h"
2525
#include "platform.h"
26-
#include "publictypes.h"
2726

2827
namespace tesseract {
2928

src/ccmain/control.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
#include "config_auto.h"
2424
#endif
2525

26-
#include <algorithm>
27-
#include <cstring>
2826
#include <cmath>
27+
#include <cstdint> // for int16_t, int32_t
28+
#include <cstdio> // for fclose, fopen, FILE
29+
#include <ctime> // for clock
2930
#ifdef __UNIX__
3031
#include <unistd.h>
3132
#endif
32-
#include <ctype.h>
33-
#include <errno.h>
33+
#include <cctype>
3434
#include "callcpp.h"
3535
#include "control.h"
3636
#ifndef DISABLED_LEGACY_ENGINE
@@ -42,6 +42,7 @@
4242
#include "lstmrecognizer.h"
4343
#include "ocrclass.h"
4444
#include "output.h"
45+
#include "pageres.h" // for WERD_RES, PAGE_RES_IT, PAGE_RES, BLO...
4546
#include "pgedit.h"
4647
#include "reject.h"
4748
#include "sorthelper.h"

src/ccmain/fixspace.cpp

+23-8
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,30 @@
1919
*
2020
**********************************************************************/
2121

22-
#include <ctype.h>
23-
#include "reject.h"
24-
#include "statistc.h"
25-
#include "control.h"
2622
#include "fixspace.h"
27-
#include "genblob.h"
28-
#include "tessvars.h"
29-
#include "globals.h"
30-
#include "tesseractclass.h"
23+
#include <cstdint> // for INT16_MAX, int16_t, int32_t
24+
#include "blobs.h" // for TWERD, TBLOB, TESSLINE
25+
#include "boxword.h" // for BoxWord
26+
#include "errcode.h" // for ASSERT_HOST
27+
#include "genblob.h" // for c_blob_comparator
28+
#include "host.h" // for FALSE, TRUE
29+
#include "normalis.h" // for kBlnXHeight, kBlnBaselineOffset
30+
#include "ocrclass.h" // for ETEXT_DESC
31+
#include "pageres.h" // for WERD_RES_IT, WERD_RES, WERD_RES_LIST
32+
#include "params.h" // for IntParam, StringParam, BoolParam, Doub...
33+
#include "ratngs.h" // for WERD_CHOICE, FREQ_DAWG_PERM, NUMBER_PERM
34+
#include "rect.h" // for TBOX
35+
#include "stepblob.h" // for C_BLOB_IT, C_BLOB_LIST, C_BLOB
36+
#include "strngs.h" // for STRING
37+
#include "tesseractclass.h" // for Tesseract, TesseractStats, WordData
38+
#include "tessvars.h" // for debug_fp
39+
#include "tprintf.h" // for tprintf
40+
#include "unichar.h" // for UNICHAR_ID
41+
#include "unicharset.h" // for UNICHARSET
42+
#include "werd.h" // for WERD, W_EOL, W_FUZZY_NON, W_FUZZY_SP
43+
44+
class BLOCK;
45+
class ROW;
3146

3247
#define PERFECT_WERDS 999
3348
#define MAXSPACING 128 /*max expected spacing in pix */

src/ccmain/tesseractclass.h

+21-15
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,28 @@
2626
#ifndef TESSERACT_CCMAIN_TESSERACTCLASS_H_
2727
#define TESSERACT_CCMAIN_TESSERACTCLASS_H_
2828

29-
#include "allheaders.h"
30-
#include "control.h"
31-
#include "debugpixa.h"
32-
#include "devanagari_processing.h"
33-
#include "docqual.h"
34-
#include "genericvector.h"
35-
#include "ocrclass.h"
36-
#include "params.h"
37-
#include "textord.h"
38-
#include "wordrec.h"
39-
#ifdef DISABLED_LEGACY_ENGINE
40-
#include "pageres.h"
41-
#endif
29+
#include <cstdint> // for int16_t, int32_t, uint16_t
30+
#include <cstdio> // for FILE
31+
#include "allheaders.h" // for pixDestroy, pixGetWidth, pixGetHe...
32+
#include "control.h" // for ACCEPTABLE_WERD_TYPE
33+
#include "debugpixa.h" // for DebugPixa
34+
#include "devanagari_processing.h" // for ShiroRekhaSplitter
35+
#include "docqual.h" // for GARBAGE_LEVEL
36+
#include "genericvector.h" // for GenericVector, PointerVector
37+
#include "host.h" // for BOOL8
38+
#include "pageres.h" // for WERD_RES (ptr only), PAGE_RES (pt...
39+
#include "params.h" // for BOOL_VAR_H, BoolParam, DoubleParam
40+
#include "points.h" // for FCOORD
41+
#include "publictypes.h" // for OcrEngineMode, PageSegMode, OEM_L...
42+
#include "ratngs.h" // for ScriptPos, WERD_CHOICE (ptr only)
43+
#include "strngs.h" // for STRING
44+
#include "tessdatamanager.h" // for TessdataManager
45+
#include "textord.h" // for Textord
46+
#include "unichar.h" // for UNICHAR_ID
47+
#include "wordrec.h" // for Wordrec
4248

43-
class BLOB_CHOICE_LIST_CLIST;
4449
class BLOCK_LIST;
50+
class ETEXT_DESC;
4551
struct OSResults;
4652
class PAGE_RES;
4753
class PAGE_RES_IT;
@@ -169,7 +175,7 @@ class Tesseract : public Wordrec {
169175
Tesseract();
170176
~Tesseract();
171177

172-
// Return appropriate dictionary
178+
// Return appropriate dictionary
173179
Dict& getDict() override;
174180

175181
// Clear as much used memory as possible without resetting the adaptive

src/ccstruct/blamer.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include <cstring> // for memcpy
2626
#include "boxword.h" // for BoxWord
2727
#include "genericvector.h" // for GenericVector
28-
#include "matrix.h" // for MATRIX_COORD, MATRIX (ptr only)
2928
#include "params_training_featdef.h" // for ParamsTrainingBundle, ParamsTra...
3029
#include "ratngs.h" // for BLOB_CHOICE_LIST (ptr only)
3130
#include "rect.h" // for TBOX
@@ -34,9 +33,11 @@
3433
#include "unichar.h" // for UNICHAR_ID
3534

3635
class DENORM;
36+
class MATRIX;
3737
class UNICHARSET;
3838
class WERD_RES;
3939

40+
struct MATRIX_COORD;
4041
struct TWERD;
4142

4243
template <class R, class A1, class A2> class TessResultCallback2;

src/ccstruct/boxread.cpp

+9-7
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,15 @@
1818
**********************************************************************/
1919

2020
#include "boxread.h"
21-
#include <cstring>
22-
23-
#include "fileerr.h"
24-
#include "rect.h"
25-
#include "strngs.h"
26-
#include "tprintf.h"
27-
#include "unichar.h"
21+
#include <cstring> // for strchr, strcmp, strrchr
22+
#include "errcode.h" // for ERRCODE, TESSEXIT
23+
#include "fileerr.h" // for CANTOPENFILE
24+
#include "genericvector.h" // for GenericVector
25+
#include "helpers.h" // for chomp_string
26+
#include "rect.h" // for TBOX
27+
#include "strngs.h" // for STRING
28+
#include "tprintf.h" // for tprintf
29+
#include "unichar.h" // for UNICHAR
2830

2931
// Special char code used to identify multi-blob labels.
3032
static const char* kMultiBlobLabelCode = "WordStr";

src/ccstruct/points.h

+6-5
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
*
1818
**********************************************************************/
1919

20-
#ifndef POINTS_H
21-
#define POINTS_H
20+
#ifndef POINTS_H
21+
#define POINTS_H
2222

23-
#include <stdio.h>
24-
#include <math.h>
25-
#include "elst.h"
23+
#include <cmath> // for sqrt, atan2
24+
#include <cstdio>
25+
#include "elst.h"
26+
#include "platform.h" // for DLLSYM
2627

2728
class FCOORD;
2829

src/ccstruct/polyaprx.h

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
#ifndef POLYAPRX_H
2121
#define POLYAPRX_H
2222

23-
#include "blobs.h"
24-
#include "coutln.h"
23+
class C_OUTLINE;
24+
struct EDGEPT;
25+
struct TESSLINE;
2526

2627
// convert a chain-coded input to the old OUTLINE approximation
2728
TESSLINE* ApproximateOutline(bool allow_detailed_fx, C_OUTLINE *c_outline);

src/ccstruct/quspline.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/**********************************************************************
22
* File: quspline.cpp (Formerly qspline.c)
33
* Description: Code for the QSPLINE class.
4-
* Author: Ray Smith
5-
* Created: Tue Oct 08 17:16:12 BST 1991
4+
* Author: Ray Smith
65
*
76
* (C) Copyright 1991, Hewlett-Packard Ltd.
87
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,9 +16,12 @@
1716
*
1817
**********************************************************************/
1918

20-
#include "allheaders.h"
21-
#include "quadlsq.h"
2219
#include "quspline.h"
20+
#include "allheaders.h" // for pixRenderPolyline, pixGetDepth, pixGetHeight
21+
#include "pix.h" // for L_CLEAR_PIXELS, L_SET_PIXELS, Pix (ptr only)
22+
#include "points.h" // for ICOORD
23+
#include "quadlsq.h" // for QLSQ
24+
#include "quadratc.h" // for QUAD_COEFFS
2325

2426
// Include automatically generated configuration file if running autoconf.
2527
#ifdef HAVE_CONFIG_H

src/ccstruct/quspline.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@
2020
#ifndef QUSPLINE_H
2121
#define QUSPLINE_H
2222

23-
#include "quadratc.h"
24-
#include "serialis.h"
25-
#include "rect.h"
23+
#include <cstdint> // for int32_t
24+
#include "scrollview.h" // for ScrollView, ScrollView::Color
2625

26+
class ICOORD;
27+
class QUAD_COEFFS;
2728
class ROW;
29+
class TBOX;
2830
struct Pix;
2931

3032
class QSPLINE

src/ccstruct/rect.h

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**********************************************************************
22
* File: rect.h (Formerly box.h)
33
* Description: Bounding box class definition.
4-
* Author: Phil Cheatle
5-
* Created: Wed Oct 16 15:18:45 BST 1991
4+
* Author: Phil Cheatle
5+
* Created: Wed Oct 16 15:18:45 BST 1991
66
*
77
* (C) Copyright 1991, Hewlett-Packard Ltd.
88
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,14 +17,20 @@
1717
*
1818
**********************************************************************/
1919

20-
#ifndef RECT_H
21-
#define RECT_H
20+
#ifndef RECT_H
21+
#define RECT_H
2222

23-
#include <cmath>
24-
#include "points.h"
25-
#include "scrollview.h"
26-
#include "strngs.h"
27-
#include "tprintf.h"
23+
#include <algorithm> // for std::max, std::min
24+
#include <cmath> // for ceil, floor
25+
#include <cstdint> // for INT16_MAX
26+
#include <cstdio> // for FILE
27+
#include "ipoints.h" // for operator+=, operator-=, ICOORD::rotate
28+
#include "platform.h" // for DLLSYM
29+
#include "points.h" // for ICOORD, FCOORD
30+
#include "scrollview.h" // for ScrollView, ScrollView::Color
31+
#include "tprintf.h" // for tprintf
32+
33+
class STRING;
2834

2935
class DLLSYM TBOX { // bounding box
3036
public:

0 commit comments

Comments
 (0)