Skip to content

Commit

Permalink
Replace ASSERT_HOST in genericvector.h
Browse files Browse the repository at this point in the history
genericvector.h used a mix of assert and ASSERT_HOST.

By using assert only, it does no longer depend on errcode.h
which defines the ASSERT_HOST macro.

Other files which still use ASSERT_HOST now need an explicit
include statement for errcode.h.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jun 20, 2018
1 parent 2bb4c4e commit 4445009
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/ccstruct/dppoint.cpp
Expand Up @@ -18,6 +18,7 @@
**********************************************************************/

#include "dppoint.h"
#include "errcode.h"
#include "tprintf.h"

namespace tesseract {
Expand Down
1 change: 1 addition & 0 deletions src/ccstruct/fontinfo.h
Expand Up @@ -21,6 +21,7 @@
#ifndef TESSERACT_CCSTRUCT_FONTINFO_H_
#define TESSERACT_CCSTRUCT_FONTINFO_H_

#include "errcode.h"
#include "genericvector.h"
#include "host.h"
#include "unichar.h"
Expand Down
5 changes: 3 additions & 2 deletions src/ccstruct/rejctmap.h
Expand Up @@ -45,8 +45,9 @@ OF THIS IMPLIED TEMPORAL ORDERING OF THE FLAGS!!!!
#include <assert.h>
#endif
#include <memory>
#include "bits16.h"
#include "params.h"
#include "bits16.h"
#include "errcode.h"
#include "params.h"

enum REJ_FLAGS {
/* Reject modes which are NEVER overridden */
Expand Down
15 changes: 8 additions & 7 deletions src/ccstruct/statistc.cpp
Expand Up @@ -22,13 +22,14 @@
#include "config_auto.h"
#endif

#include "statistc.h"
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "helpers.h"
#include "scrollview.h"
#include "tprintf.h"
#include "statistc.h"
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include "errcode.h"
#include "helpers.h"
#include "scrollview.h"
#include "tprintf.h"

using tesseract::KDPairInc;

Expand Down
15 changes: 7 additions & 8 deletions src/ccutil/genericvector.h
Expand Up @@ -26,7 +26,6 @@
#include <cstdlib>

#include "tesscallback.h"
#include "errcode.h"
#include "helpers.h"
#include "ndminx.h"
#include "serialis.h"
Expand Down Expand Up @@ -708,7 +707,7 @@ void GenericVector<T>::init_to_size(int size, T t) {
// Return the object from an index.
template <typename T>
T &GenericVector<T>::get(int index) const {
ASSERT_HOST(index >= 0 && index < size_used_);
assert(index >= 0 && index < size_used_);
return data_[index];
}

Expand All @@ -720,20 +719,20 @@ T &GenericVector<T>::operator[](int index) const {

template <typename T>
T &GenericVector<T>::back() const {
ASSERT_HOST(size_used_ > 0);
assert(size_used_ > 0);
return data_[size_used_ - 1];
}
// Returns the last object and removes it.
template <typename T>
T GenericVector<T>::pop_back() {
ASSERT_HOST(size_used_ > 0);
assert(size_used_ > 0);
return data_[--size_used_];
}

// Return the object from an index.
template <typename T>
void GenericVector<T>::set(T t, int index) {
ASSERT_HOST(index >= 0 && index < size_used_);
assert(index >= 0 && index < size_used_);
data_[index] = t;
}

Expand All @@ -742,7 +741,7 @@ void GenericVector<T>::set(T t, int index) {
// at the specified index.
template <typename T>
void GenericVector<T>::insert(T t, int index) {
ASSERT_HOST(index >= 0 && index <= size_used_);
assert(index >= 0 && index <= size_used_);
if (size_reserved_ == size_used_)
double_the_size();
for (int i = size_used_; i > index; --i) {
Expand All @@ -756,7 +755,7 @@ void GenericVector<T>::insert(T t, int index) {
// shifts the remaining elements to the left.
template <typename T>
void GenericVector<T>::remove(int index) {
ASSERT_HOST(index >= 0 && index < size_used_);
assert(index >= 0 && index < size_used_);
for (int i = index; i < size_used_ - 1; ++i) {
data_[i] = data_[i+1];
}
Expand All @@ -773,7 +772,7 @@ T GenericVector<T>::contains_index(int index) const {
template <typename T>
int GenericVector<T>::get_index(T object) const {
for (int i = 0; i < size_used_; ++i) {
ASSERT_HOST(compare_cb_ != nullptr);
assert(compare_cb_ != nullptr);
if (compare_cb_->Run(object, data_[i]))
return i;
}
Expand Down
1 change: 1 addition & 0 deletions src/ccutil/serialis.cpp
Expand Up @@ -19,6 +19,7 @@

#include "serialis.h"
#include <cstdio>
#include "errcode.h"
#include "genericvector.h"

namespace tesseract {
Expand Down
1 change: 1 addition & 0 deletions src/ccutil/strngs.cpp
Expand Up @@ -21,6 +21,7 @@

#include <assert.h>

#include "errcode.h"
#include "genericvector.h"
#include "helpers.h"
#include "serialis.h"
Expand Down
1 change: 1 addition & 0 deletions src/ccutil/tessdatamanager.cpp
Expand Up @@ -25,6 +25,7 @@

#include <cstdio>

#include "errcode.h"
#include "helpers.h"
#include "serialis.h"
#include "strngs.h"
Expand Down
1 change: 1 addition & 0 deletions src/training/commandlineflags.cpp
Expand Up @@ -10,6 +10,7 @@

#include "baseapi.h" // TessBaseAPI::Version
#include "commandlineflags.h"
#include "errcode.h"

#ifndef GOOGLE_TESSERACT

Expand Down
1 change: 1 addition & 0 deletions src/training/fileio.cpp
Expand Up @@ -27,6 +27,7 @@
#include <cstdio>
#include <string>

#include "errcode.h"
#include "fileio.h"
#include "tprintf.h"

Expand Down
1 change: 1 addition & 0 deletions src/training/normstrngs.cpp
Expand Up @@ -25,6 +25,7 @@
#include <unordered_map>
#include <vector>

#include "errcode.h"
#include "icuerrorcode.h"
#include "unichar.h"
#include "unicode/normalizer2.h" // From libicu
Expand Down

0 comments on commit 4445009

Please sign in to comment.