Skip to content

Commit 146079f

Browse files
committed
api: Replace BOOL8, TRUE, FALSE by bool, true, false and modernize code
Signed-off-by: Stefan Weil <[email protected]>
1 parent 4e0c726 commit 146079f

File tree

2 files changed

+14
-25
lines changed

2 files changed

+14
-25
lines changed

src/api/baseapi.cpp

+4-5
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,11 @@
5959
#include "dict.h" // for Dict
6060
#include "edgblob.h" // for extract_edges
6161
#include "elst.h" // for ELIST_ITERATOR, ELISTIZE, ELISTIZEH
62-
#include "environ.h" // for l_uint8, FALSE, TRUE
62+
#include "environ.h" // for l_uint8
6363
#include "equationdetect.h" // for EquationDetect
6464
#include "errcode.h" // for ASSERT_HOST
6565
#include "globaloc.h" // for SavePixForCrash, signal_exit
6666
#include "helpers.h" // for IntCastRounded, chomp_string
67-
#include "host.h" // for BOOL8
6867
#include "imageio.h" // for IFF_TIFF_G4, IFF_TIFF, IFF_TIFF_G3
6968
#include "intfx.h" // for INT_FX_RESULT_STRUCT
7069
#include "mutableiterator.h" // for MutableIterator
@@ -91,7 +90,7 @@
9190
#include "tprintf.h" // for tprintf
9291
#include "werd.h" // for WERD, WERD_IT, W_FUZZY_NON, W_FUZZY_SP
9392

94-
BOOL_VAR(stream_filelist, FALSE, "Stream a filelist from stdin");
93+
BOOL_VAR(stream_filelist, false, "Stream a filelist from stdin");
9594

9695
namespace tesseract {
9796

@@ -309,7 +308,7 @@ bool TessBaseAPI::GetBoolVariable(const char *name, bool *value) const {
309308
auto *p = ParamUtils::FindParam<BoolParam>(
310309
name, GlobalParams()->bool_params, tesseract_->params()->bool_params);
311310
if (p == nullptr) return false;
312-
*value = (BOOL8)(*p);
311+
*value = bool(*p);
313312
return true;
314313
}
315314

@@ -2325,7 +2324,7 @@ ROW *TessBaseAPI::MakeTessOCRRow(float baseline,
23252324
TBLOB *TessBaseAPI::MakeTBLOB(Pix *pix) {
23262325
int width = pixGetWidth(pix);
23272326
int height = pixGetHeight(pix);
2328-
BLOCK block("a character", TRUE, 0, 0, 0, 0, width, height);
2327+
BLOCK block("a character", true, 0, 0, 0, 0, width, height);
23292328

23302329
// Create C_BLOBs from the page
23312330
extract_edges(pix, &block);

src/api/baseapi.h

+10-20
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
// To avoid collision with other typenames include the ABSOLUTE MINIMUM
2424
// complexity of includes here. Use forward declarations wherever possible
2525
// and hide includes of complex types in baseapi.cpp.
26-
#include "tess_version.h"
2726
#include "apitypes.h"
2827
#include "pageiterator.h"
2928
#include "platform.h"
3029
#include "publictypes.h"
3130
#include "resultiterator.h"
3231
#include "serialis.h"
32+
#include "tess_version.h"
3333
#include "tesscallback.h"
3434
#include "thresholder.h"
3535
#include "unichar.h"
@@ -56,7 +56,7 @@ class UNICHARSET;
5656
class WERD_CHOICE_LIST;
5757

5858
struct INT_FEATURE_STRUCT;
59-
typedef INT_FEATURE_STRUCT *INT_FEATURE;
59+
using INT_FEATURE = INT_FEATURE_STRUCT *;
6060
struct TBLOB;
6161

6262
namespace tesseract {
@@ -73,20 +73,10 @@ class Tesseract;
7373
class Trie;
7474
class Wordrec;
7575

76-
typedef int (Dict::*DictFunc)(void* void_dawg_args,
77-
const UNICHARSET& unicharset,
78-
UNICHAR_ID unichar_id, bool word_end) const;
79-
typedef double (Dict::*ProbabilityInContextFunc)(const char* lang,
80-
const char* context,
81-
int context_bytes,
82-
const char* character,
83-
int character_bytes);
84-
typedef float (Dict::*ParamsModelClassifyFunc)(
85-
const char *lang, void *path);
86-
typedef void (Wordrec::*FillLatticeFunc)(const MATRIX &ratings,
87-
const WERD_CHOICE_LIST &best_choices,
88-
const UNICHARSET &unicharset,
89-
BlamerBundle *blamer_bundle);
76+
using DictFunc = int (Dict::*)(void *, const UNICHARSET &, UNICHAR_ID, bool) const;
77+
using ProbabilityInContextFunc = double (Dict::*)(const char *, const char *, int, const char *, int);
78+
using ParamsModelClassifyFunc = float (Dict::*)(const char *, void *);
79+
using FillLatticeFunc = void (Wordrec::*)(const MATRIX &, const WERD_CHOICE_LIST &, const UNICHARSET &, BlamerBundle *);
9080
typedef TessCallback4<const UNICHARSET &, int, PageIterator *, Pix *>
9181
TruthCallback;
9282

@@ -404,7 +394,7 @@ class TESS_API TessBaseAPI {
404394
* If paraids is not nullptr, the paragraph-id of each line within its block is
405395
* also returned as an array of one element per line. delete [] after use.
406396
*/
407-
Boxa* GetTextlines(const bool raw_image, const int raw_padding,
397+
Boxa* GetTextlines(bool raw_image, int raw_padding,
408398
Pixa** pixa, int** blockids, int** paraids);
409399
/*
410400
Helper method to extract from the thresholded image. (most common usage)
@@ -453,9 +443,9 @@ class TESS_API TessBaseAPI {
453443
* instead of the thresholded image and padded with raw_padding.
454444
* If text_only is true, then only text components are returned.
455445
*/
456-
Boxa* GetComponentImages(const PageIteratorLevel level,
457-
const bool text_only, const bool raw_image,
458-
const int raw_padding,
446+
Boxa* GetComponentImages(PageIteratorLevel level,
447+
bool text_only, bool raw_image,
448+
int raw_padding,
459449
Pixa** pixa, int** blockids, int** paraids);
460450
// Helper function to get binary images with no padding (most common usage).
461451
Boxa* GetComponentImages(const PageIteratorLevel level,

0 commit comments

Comments
 (0)