Skip to content

Commit 0697235

Browse files
committed
1 parent 0248c7f commit 0697235

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+82
-82
lines changed

src/ccmain/paragraphs_internal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ struct LineHypothesis {
8888

8989
class ParagraphTheory; // Forward Declaration
9090

91-
typedef GenericVectorEqEq<const ParagraphModel *> SetOfModels;
91+
using SetOfModels = GenericVectorEqEq<const ParagraphModel *>;
9292

9393
// Row Scratch Registers are data generated by the paragraph detection
9494
// algorithm based on a RowInfo input.

src/ccstruct/blobs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct TPOINT {
7171
int16_t x; // absolute x coord.
7272
int16_t y; // absolute y coord.
7373
};
74-
typedef TPOINT VECTOR; // structure for coordinates.
74+
using VECTOR = TPOINT; // structure for coordinates.
7575

7676
struct EDGEPT {
7777
EDGEPT()

src/ccstruct/detlinefit.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ class DetLineFit {
120120
// Type holds the distance of each point from the fitted line and the point
121121
// itself. Use of double allows integer distances from ICOORDs to be stored
122122
// exactly, and also the floating point results from ConstrainedFit.
123-
typedef KDPairInc<double, ICOORD> DistPointPair;
123+
using DistPointPair = KDPairInc<double, ICOORD>;
124124

125125
// Computes and returns the squared evaluation metric for a line fit.
126126
double EvaluateLineFit();

src/ccstruct/matrix.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,6 @@ struct MATRIX_COORD {
628628
};
629629

630630
// The MatrixCoordPair contains a MATRIX_COORD and its priority.
631-
typedef tesseract::KDPairInc<float, MATRIX_COORD> MatrixCoordPair;
631+
using MatrixCoordPair = tesseract::KDPairInc<float, MATRIX_COORD>;
632632

633633
#endif // TESSERACT_CCSTRUCT_MATRIX_H_

src/ccstruct/params_training_featdef.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct ParamsTrainingHypothesis {
119119
};
120120

121121
// A list of hypotheses explored during one run of segmentation search.
122-
typedef GenericVector<ParamsTrainingHypothesis> ParamsTrainingHypothesisList;
122+
using ParamsTrainingHypothesisList = GenericVector<ParamsTrainingHypothesis>;
123123

124124
// A bundle that accumulates all of the hypothesis lists explored during all
125125
// of the runs of segmentation search on a word (e.g. a list of hypotheses

src/ccstruct/ratngs.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ class WERD_CHOICE : public ELIST_LINK {
637637

638638
// Make WERD_CHOICE listable.
639639
ELISTIZEH(WERD_CHOICE)
640-
typedef GenericVector<BLOB_CHOICE_LIST *> BLOB_CHOICE_LIST_VECTOR;
640+
using BLOB_CHOICE_LIST_VECTOR = GenericVector<BLOB_CHOICE_LIST *>;
641641

642642
// Utilities for comparing WERD_CHOICEs
643643

src/ccstruct/seam.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
/*----------------------------------------------------------------------
4040
T y p e s
4141
----------------------------------------------------------------------*/
42-
typedef float PRIORITY; /* PRIORITY */
42+
using PRIORITY = float; /* PRIORITY */
4343

4444
class SEAM {
4545
public:

src/ccutil/ambigs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
namespace tesseract {
3333

34-
typedef GenericVector<UNICHAR_ID> UnicharIdVector;
34+
using UnicharIdVector = GenericVector<UNICHAR_ID>;
3535

3636
static const int kUnigramAmbigsBufferSize = 1000;
3737
static const char kAmbigNgramSeparator[] = { ' ', '\0' };
@@ -138,7 +138,7 @@ ELISTIZEH(AmbigSpec)
138138

139139
// AMBIG_TABLE[i] stores a set of ambiguities whose
140140
// wrong ngram starts with unichar id i.
141-
typedef GenericVector<AmbigSpec_LIST *> UnicharAmbigsVector;
141+
using UnicharAmbigsVector = GenericVector<AmbigSpec_LIST *>;
142142

143143
class UnicharAmbigs {
144144
public:

src/ccutil/host.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@
3131
#include <cstdint> // int32_t, ...
3232

3333
// definitions of portable data types (numbers and characters)
34-
typedef float FLOAT32;
35-
typedef double FLOAT64;
36-
typedef unsigned char BOOL8;
34+
using FLOAT32 = float;
35+
using FLOAT64 = double;
36+
using BOOL8 = unsigned char;
3737

3838
#if defined(_WIN32)
3939

src/ccutil/kdpair.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ struct KDPtrPairDec : public KDPtrPair<Key, Data> {
176176
};
177177

178178
// Specialization for a pair of ints in increasing order.
179-
typedef KDPairInc<int, int> IntKDPair;
179+
using IntKDPair = KDPairInc<int, int>;
180180

181181
// Vector of IntKDPair.
182182
class KDVector : public GenericVector<IntKDPair> {

src/ccutil/unichar.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
// TODO(rays) Move these to the tesseract namespace.
3434
// A UNICHAR_ID is the unique id of a unichar.
35-
typedef int UNICHAR_ID;
35+
using UNICHAR_ID = int;
3636

3737
// A variable to indicate an invalid or uninitialized unichar id.
3838
static const int INVALID_UNICHAR_ID = -1;
@@ -49,7 +49,7 @@ enum StrongScriptDirection {
4949

5050
namespace tesseract {
5151

52-
typedef signed int char32;
52+
using char32 = signed int;
5353

5454
// The UNICHAR class holds a single classification result. This may be
5555
// a single Unicode character (stored as between 1 and 4 utf8 bytes) or
@@ -106,7 +106,7 @@ class UNICHAR {
106106
// tprintf("Char = %s\n", buf);
107107
// }
108108
class const_iterator {
109-
typedef const_iterator CI;
109+
using CI = const_iterator ;
110110

111111
public:
112112
// Step to the next UTF8 character.

src/ccutil/unicharcompress.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ static int RadicalPreHash(const std::vector<int>& rs) {
4444
}
4545

4646
// A hash map to convert unicodes to radical encoding.
47-
typedef std::unordered_map<int, std::unique_ptr<std::vector<int>>> RSMap;
47+
using RSMap = std::unordered_map<int, std::unique_ptr<std::vector<int>>>;
4848
// A hash map to count occurrences of each radical encoding.
49-
typedef std::unordered_map<int, int> RSCounts;
49+
using RSCounts = std::unordered_map<int, int>;
5050

5151
static bool DecodeRadicalLine(STRING* radical_data_line, RSMap* radical_map) {
5252
if (radical_data_line->length() == 0 || (*radical_data_line)[0] == '#')

src/classify/cluster.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ struct TEMPCLUSTER {
164164
CLUSTER *Neighbor;
165165
};
166166

167-
typedef tesseract::KDPairInc<float, TEMPCLUSTER*> ClusterPair;
168-
typedef tesseract::GenericHeap<ClusterPair> ClusterHeap;
167+
using ClusterPair = tesseract::KDPairInc<float, TEMPCLUSTER*>;
168+
using ClusterHeap = tesseract::GenericHeap<ClusterPair>;
169169

170170
struct STATISTICS {
171171
FLOAT32 AvgVariance;

src/classify/featdefs.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,14 @@ struct CHAR_DESC_STRUCT {
4343
uint32_t NumFeatureSets;
4444
FEATURE_SET FeatureSets[NUM_FEATURE_TYPES];
4545
};
46-
typedef CHAR_DESC_STRUCT *CHAR_DESC;
46+
using CHAR_DESC = CHAR_DESC_STRUCT *;
4747

4848
struct FEATURE_DEFS_STRUCT {
4949
int32_t NumFeatureTypes;
5050
const FEATURE_DESC_STRUCT* FeatureDesc[NUM_FEATURE_TYPES];
5151
int FeatureEnabled[NUM_FEATURE_TYPES];
5252
};
53-
typedef FEATURE_DEFS_STRUCT *FEATURE_DEFS;
53+
using FEATURE_DEFS = FEATURE_DEFS_STRUCT *;
5454

5555
/*----------------------------------------------------------------------
5656
Generic functions for manipulating character descriptions

src/classify/fpoint.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ typedef struct
3030
{
3131
FLOAT32 x, y;
3232
} FPOINT;
33-
typedef FPOINT FVECTOR;
33+
using FVECTOR = FPOINT;
3434

3535
/**----------------------------------------------------------------------------
3636
Macros

src/classify/ocrfeatures.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,26 @@ struct FEATURE_DESC_STRUCT {
5858
const char *ShortName; // short name for feature
5959
const PARAM_DESC *ParamDesc; // array - one per param
6060
};
61-
typedef FEATURE_DESC_STRUCT *FEATURE_DESC;
61+
using FEATURE_DESC = FEATURE_DESC_STRUCT *;
6262

6363
struct FEATURE_STRUCT {
6464
const FEATURE_DESC_STRUCT *Type; // points to description of feature type
6565
FLOAT32 Params[1]; // variable size array - params for feature
6666
};
67-
typedef FEATURE_STRUCT *FEATURE;
67+
using FEATURE = FEATURE_STRUCT *;
6868

6969
struct FEATURE_SET_STRUCT {
7070
uint16_t NumFeatures; // number of features in set
7171
uint16_t MaxNumFeatures; // maximum size of feature set
7272
FEATURE Features[1]; // variable size array of features
7373
};
74-
typedef FEATURE_SET_STRUCT *FEATURE_SET;
74+
using FEATURE_SET = FEATURE_SET_STRUCT *;
7575

7676
// A generic character description as a char pointer. In reality, it will be
7777
// a pointer to some data structure. Paired feature extractors/matchers need
7878
// to agree on the data structure to be used, however, the high level
7979
// classifier does not need to know the details of this data structure.
80-
typedef char *CHAR_FEATURES;
80+
using CHAR_FEATURES = char *;
8181

8282
/*----------------------------------------------------------------------
8383
Macros for defining the parameters of a new features

src/classify/protos.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
/*----------------------------------------------------------------------
3838
T y p e s
3939
----------------------------------------------------------------------*/
40-
typedef BIT_VECTOR *CONFIGS;
40+
using CONFIGS = BIT_VECTOR *;
4141

4242
typedef struct
4343
{
@@ -49,7 +49,7 @@ typedef struct
4949
FLOAT32 Angle;
5050
FLOAT32 Length;
5151
} PROTO_STRUCT;
52-
typedef PROTO_STRUCT *PROTO;
52+
using PROTO = PROTO_STRUCT *;
5353

5454
struct CLASS_STRUCT {
5555
CLASS_STRUCT()
@@ -64,8 +64,8 @@ struct CLASS_STRUCT {
6464
CONFIGS Configurations;
6565
UnicityTableEqEq<int> font_set;
6666
};
67-
typedef CLASS_STRUCT *CLASS_TYPE;
68-
typedef CLASS_STRUCT *CLASSES;
67+
using CLASS_TYPE = CLASS_STRUCT *;
68+
using CLASSES = CLASS_STRUCT *;
6969

7070
/*----------------------------------------------------------------------
7171
C o n s t a n t s

src/classify/shapetable.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ struct ShapeQueueEntry {
153153
// Which level in the tree did this come from?
154154
int level;
155155
};
156-
typedef GenericHeap<ShapeQueueEntry> ShapeQueue;
156+
using ShapeQueue = GenericHeap<ShapeQueueEntry>;
157157

158158
// Simple struct to hold a set of fonts associated with a single unichar-id.
159159
// A vector of UnicharAndFonts makes a shape.

src/cutil/bitvec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
-----------------------------------------------------------------------------*/
2626
// TODO(rays) Rename BITSINLONG to BITSINuint32_t, and use sizeof.
2727
#define BITSINLONG 32 /**< no of bits in a long */
28-
typedef uint32_t *BIT_VECTOR;
28+
using BIT_VECTOR = uint32_t *;
2929

3030
/*-----------------------------------------------------------------------------
3131
Public Function Prototypes

src/cutil/danerror.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#define NOERROR 0
2525
#define DO_NOTHING 0
2626

27-
typedef int TRAPERROR;
27+
using TRAPERROR = int;
2828
typedef void (*VOID_PROC) ();
2929

3030
/**----------------------------------------------------------------------------

src/cutil/oldlist.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ struct list_rec
129129
struct list_rec *node;
130130
struct list_rec *next;
131131
};
132-
typedef list_rec *LIST;
132+
using LIST = list_rec *;
133133

134134
/*----------------------------------------------------------------------
135135
M a c r o s

src/dict/dawg.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@
5050
----------------------------------------------------------------------*/
5151
class UNICHARSET;
5252

53-
typedef uint64_t EDGE_RECORD;
54-
typedef EDGE_RECORD *EDGE_ARRAY;
55-
typedef int64_t EDGE_REF;
56-
typedef int64_t NODE_REF;
57-
typedef EDGE_REF *NODE_MAP;
53+
using EDGE_RECORD = uint64_t;
54+
using EDGE_ARRAY = EDGE_RECORD *;
55+
using EDGE_REF = int64_t;
56+
using NODE_REF = int64_t;
57+
using NODE_MAP = EDGE_REF *;
5858

5959
namespace tesseract {
6060

@@ -65,9 +65,9 @@ struct NodeChild {
6565
NodeChild(): unichar_id(INVALID_UNICHAR_ID), edge_ref(NO_EDGE) {}
6666
};
6767

68-
typedef GenericVector<NodeChild> NodeChildVector;
69-
typedef GenericVector<int> SuccessorList;
70-
typedef GenericVector<SuccessorList *> SuccessorListsVector;
68+
using NodeChildVector = GenericVector<NodeChild>;
69+
using SuccessorList = GenericVector<int>;
70+
using SuccessorListsVector = GenericVector<SuccessorList *>;
7171

7272
enum DawgType {
7373
DAWG_TYPE_PUNCTUATION,

src/dict/dict.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct CHAR_FRAGMENT_INFO {
4646

4747
namespace tesseract {
4848

49-
typedef GenericVector<Dawg *> DawgVector;
49+
using DawgVector = GenericVector<Dawg *>;
5050

5151
//
5252
// Constants

src/dict/matchdefs.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,19 @@
3232
#define MAX_CLASS_ID (MAX_NUM_CLASSES - 1)
3333

3434
/** a CLASS_ID is the ascii character to be associated with a class */
35-
typedef UNICHAR_ID CLASS_ID;
35+
using CLASS_ID = UNICHAR_ID;
3636
#define NO_CLASS (0)
3737

3838
/** a PROTO_ID is the index of a prototype within it's class. Valid proto
3939
id's are 0 to N-1 where N is the number of prototypes that make up the
4040
class. */
41-
typedef int16_t PROTO_ID;
41+
using PROTO_ID = int16_t;
4242
#define NO_PROTO (-1)
4343

4444
/** FEATURE_ID is the index of a feature within a character description
4545
The feature id ranges from 0 to N-1 where N is the number
4646
of features in a character description. */
47-
typedef uint8_t FEATURE_ID;
47+
using FEATURE_ID = uint8_t;
4848
#define NO_FEATURE 255
4949
#define NOISE_FEATURE 254
5050
#define MISSING_PROTO 254
@@ -53,13 +53,13 @@ typedef uint8_t FEATURE_ID;
5353

5454
/** a RATING is the match rating returned by a classifier.
5555
Higher is better. */
56-
typedef FLOAT32 RATING;
56+
using RATING = FLOAT32;
5757

5858
/** a CERTAINTY is an indication of the degree of confidence of the
5959
classifier. Higher is better. 0 means the match is as good as the
6060
mean of the matches seen in training. -1 means the match was one
6161
standard deviation worse than the training matches, etc. */
62-
typedef FLOAT32 CERTAINTY;
62+
using CERTAINTY = FLOAT32;
6363

6464
/** define a data structure to hold a single match result */
6565
typedef struct

src/dict/stopper.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
class WERD_CHOICE;
3131

32-
typedef uint8_t BLOB_WIDTH;
32+
using BLOB_WIDTH = uint8_t;
3333

3434
struct DANGERR_INFO {
3535
DANGERR_INFO() :
@@ -44,7 +44,7 @@ struct DANGERR_INFO {
4444
UNICHAR_ID leftmost; // in the replacement, what's the leftmost character?
4545
};
4646

47-
typedef GenericVector<DANGERR_INFO> DANGERR;
47+
using DANGERR = GenericVector<DANGERR_INFO>;
4848

4949

5050
#endif

src/dict/trie.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ class UNICHARSET;
4141
// It might be cleanest to change the types of most of the Trie/Dawg related
4242
// typedefs to int and restrict the casts to extracting these values from
4343
// the 64 bit EDGE_RECORD.
44-
typedef int64_t EDGE_INDEX; // index of an edge in a given node
45-
typedef bool *NODE_MARKER;
46-
typedef GenericVector<EDGE_RECORD> EDGE_VECTOR;
44+
using EDGE_INDEX = int64_t ; // index of an edge in a given node
45+
using NODE_MARKER = bool *;
46+
using EDGE_VECTOR = GenericVector<EDGE_RECORD> ;
4747

4848
struct TRIE_NODE_RECORD {
4949
EDGE_VECTOR forward_edges;
5050
EDGE_VECTOR backward_edges;
5151
};
52-
typedef GenericVector<TRIE_NODE_RECORD *> TRIE_NODES;
52+
using TRIE_NODES = GenericVector<TRIE_NODE_RECORD *> ;
5353

5454
namespace tesseract {
5555

src/lstm/lstmtrainer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ double LSTMTrainer::ComputeCharError(const GenericVector<int>& truth_str,
12431243
// Computes word recall error rate using a very simple bag of words algorithm.
12441244
// NOTE that this is destructive on both input strings.
12451245
double LSTMTrainer::ComputeWordError(STRING* truth_str, STRING* ocr_str) {
1246-
typedef std::unordered_map<std::string, int, std::hash<std::string> > StrMap;
1246+
using StrMap = std::unordered_map<std::string, int, std::hash<std::string>>;
12471247
GenericVector<STRING> truth_words, ocr_words;
12481248
truth_str->split(' ', &truth_words);
12491249
if (truth_words.empty()) return 0.0;

0 commit comments

Comments
 (0)