Replace ASSERT_HOST in genericvector.h

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>
This commit is contained in:
Stefan Weil 2018-06-20 22:32:17 +02:00
parent 2bb4c4ed44
commit 44450094c3
11 changed files with 26 additions and 17 deletions

View File

@ -18,6 +18,7 @@
**********************************************************************/
#include "dppoint.h"
#include "errcode.h"
#include "tprintf.h"
namespace tesseract {

View File

@ -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"

View File

@ -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 */

View File

@ -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;

View File

@ -26,7 +26,6 @@
#include <cstdlib>
#include "tesscallback.h"
#include "errcode.h"
#include "helpers.h"
#include "ndminx.h"
#include "serialis.h"
@ -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];
}
@ -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;
}
@ -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) {
@ -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];
}
@ -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;
}

View File

@ -19,6 +19,7 @@
#include "serialis.h"
#include <cstdio>
#include "errcode.h"
#include "genericvector.h"
namespace tesseract {

View File

@ -21,6 +21,7 @@
#include <assert.h>
#include "errcode.h"
#include "genericvector.h"
#include "helpers.h"
#include "serialis.h"

View File

@ -25,6 +25,7 @@
#include <cstdio>
#include "errcode.h"
#include "helpers.h"
#include "serialis.h"
#include "strngs.h"

View File

@ -10,6 +10,7 @@
#include "baseapi.h" // TessBaseAPI::Version
#include "commandlineflags.h"
#include "errcode.h"
#ifndef GOOGLE_TESSERACT

View File

@ -27,6 +27,7 @@
#include <cstdio>
#include <string>
#include "errcode.h"
#include "fileio.h"
#include "tprintf.h"

View File

@ -25,6 +25,7 @@
#include <unordered_map>
#include <vector>
#include "errcode.h"
#include "icuerrorcode.h"
#include "unichar.h"
#include "unicode/normalizer2.h" // From libicu