mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 13:04:05 -08:00
A few portability fixes and one stupid string error (mine). Closes Issue 1082.
- remove some uses of floating min/max fns: use the same integer code as java - Generalize counted pointers to compare against pointers instead of just integer 0 - Careless string error I added when porting some java code git-svn-id: https://zxing.googlecode.com/svn/trunk@2054 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
6de693fa06
commit
46cd54ab64
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include <zxing/common/CharacterSetECI.h>
|
||||
#include <sstream>
|
||||
#include <zxing/common/IllegalArgumentException.h>
|
||||
|
||||
using std::string;
|
||||
|
@ -77,7 +78,9 @@ void CharacterSetECI::addCharacterSet(int value, char const* const* encodingName
|
|||
|
||||
CharacterSetECI* CharacterSetECI::getCharacterSetECIByValue(int value) {
|
||||
if (value < 0 || value >= 900) {
|
||||
throw IllegalArgumentException("Bad ECI value: " + value);
|
||||
std::ostringstream oss;
|
||||
oss << "Bad ECI value: " << value;
|
||||
throw IllegalArgumentException(oss.str().c_str());
|
||||
}
|
||||
return VALUE_TO_ECI[value];
|
||||
}
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
#ifndef __COUNTED_H__
|
||||
#define __COUNTED_H__
|
||||
|
||||
/*
|
||||
* Counted.h
|
||||
* zxing
|
||||
*
|
||||
* Copyright 2010 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -177,8 +175,8 @@ public:
|
|||
return object_;
|
||||
}
|
||||
|
||||
bool operator==(const int x) {
|
||||
return x == 0 ? object_ == 0 : false;
|
||||
bool operator==(const T* that) {
|
||||
return object_ == that;
|
||||
}
|
||||
bool operator==(const Ref &other) const {
|
||||
return object_ == other.object_ || *object_ == *(other.object_);
|
||||
|
@ -188,8 +186,8 @@ public:
|
|||
return object_ == other.object_ || *object_ == *(other.object_);
|
||||
}
|
||||
|
||||
bool operator!=(const int x) {
|
||||
return x == 0 ? object_ != 0 : true;
|
||||
bool operator!=(const T* that) {
|
||||
return !(*this == that);
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
|
||||
#include <zxing/common/ECI.h>
|
||||
#include <sstream>
|
||||
#include <zxing/common/CharacterSetECI.h>
|
||||
#include <zxing/common/IllegalArgumentException.h>
|
||||
|
||||
|
@ -30,7 +31,9 @@ int ECI::getValue() const {
|
|||
|
||||
ECI* ECI::getECIByValue(int value) {
|
||||
if (value < 0 || value > 999999) {
|
||||
throw IllegalArgumentException("Bad ECI value: " + value);
|
||||
std::ostringstream oss;
|
||||
oss << "Bad ECI value: " << value;
|
||||
throw IllegalArgumentException(oss.str().c_str());
|
||||
}
|
||||
if (value < 900) { // Character set ECIs use 000000 - 000899
|
||||
return CharacterSetECI::getCharacterSetECIByValue(value);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
/*
|
||||
* Code128Reader.cpp
|
||||
* ZXing
|
||||
*
|
||||
* Copyright 2010 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -178,7 +176,7 @@ namespace zxing {
|
|||
}
|
||||
if (bestMatch >= 0) {
|
||||
// Look for whitespace before start pattern, >= 50% of width of start pattern
|
||||
if (row->isRange(fmaxl(0, patternStart - (i - patternStart) / 2), patternStart,
|
||||
if (row->isRange(std::max(0, patternStart - (i - patternStart) / 2), patternStart,
|
||||
false)) {
|
||||
int* resultValue = new int[3];
|
||||
resultValue[0] = patternStart;
|
||||
|
@ -430,7 +428,9 @@ namespace zxing {
|
|||
while (nextStart < width && row->get(nextStart)) {
|
||||
nextStart++;
|
||||
}
|
||||
if (!row->isRange(nextStart, fminl(width, nextStart + (nextStart - lastStart) / 2), false)) {
|
||||
if (!row->isRange(nextStart,
|
||||
std::min(row->getSize(), nextStart + (nextStart - lastStart) / 2),
|
||||
false)) {
|
||||
throw ReaderException("");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
|
||||
/*
|
||||
* Code39Reader.cpp
|
||||
* ZXing
|
||||
*
|
||||
* Copyright 2010 ZXing authors All rights reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -209,9 +207,7 @@ namespace oned {
|
|||
if (toNarrowWidePattern(counters, countersLen) == ASTERISK_ENCODING) {
|
||||
// Look for whitespace before start pattern, >= 50% of width of
|
||||
// start pattern.
|
||||
long double longPatternOffset =
|
||||
fmaxl(0, patternStart - (i - patternStart) / 2);
|
||||
if (row->isRange(longPatternOffset, patternStart, false)) {
|
||||
if (row->isRange(std::max(0, patternStart - ((i - patternStart) >> 1)), patternStart, false)) {
|
||||
int* resultValue = new int[2];
|
||||
resultValue[0] = patternStart;
|
||||
resultValue[1] = i;
|
||||
|
|
Loading…
Reference in a new issue