[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809
dmaclach
dmaclach at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:31:20 UTC 2010
The following commit has been merged in the upstream branch:
commit d7cf61c05100985f6dd9dddc1f4631cb690c28fa
Author: dmaclach <dmaclach at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date: Tue May 4 21:44:53 2010 +0000
Cleaned up the iPhone code so that it compiles with the 3.1.2 SDK. Also tightened up warnings and cleaned up the C++ code that violated the warnings.
Fixed up some memory issues.
git-svn-id: http://zxing.googlecode.com/svn/trunk@1334 59b500cc-1b3d-0410-9834-0bbf25fbcc57
diff --git a/AUTHORS b/AUTHORS
index bda8553..e2f33f5 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -9,6 +9,7 @@ Androida.hu / http://www.androida.hu/
Brian Brown (Google)
Christian Brunschen (Google)
Daniel Switkin (Google)
+Dave MacLachlan (Google)
David Albert (Bug Labs)
Diego Pierotto
Eric Kobrin (Velocitude)
diff --git a/cpp/core/src/zxing/Binarizer.cpp b/cpp/core/src/zxing/Binarizer.cpp
index 5f6e746..adaab05 100644
--- a/cpp/core/src/zxing/Binarizer.cpp
+++ b/cpp/core/src/zxing/Binarizer.cpp
@@ -23,7 +23,7 @@
namespace zxing {
- Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source) {
+ Binarizer::Binarizer(Ref<LuminanceSource> source) : source_(source), array_(NULL), matrix_(NULL) {
}
Binarizer::~Binarizer() {
diff --git a/cpp/core/src/zxing/BinaryBitmap.cpp b/cpp/core/src/zxing/BinaryBitmap.cpp
index 1e692a9..c8fea36 100644
--- a/cpp/core/src/zxing/BinaryBitmap.cpp
+++ b/cpp/core/src/zxing/BinaryBitmap.cpp
@@ -23,7 +23,7 @@
namespace zxing {
- BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : bits_(NULL), binarizer_(binarizer) {
+ BinaryBitmap::BinaryBitmap(Ref<Binarizer> binarizer) : bits_(NULL), array_bits_(NULL), binarizer_(binarizer) {
}
diff --git a/cpp/core/src/zxing/Exception.cpp b/cpp/core/src/zxing/Exception.cpp
index 47143c9..d20b6e3 100644
--- a/cpp/core/src/zxing/Exception.cpp
+++ b/cpp/core/src/zxing/Exception.cpp
@@ -16,7 +16,7 @@ Exception::Exception(const char *msg) :
}
const char* Exception::what() const throw() {
- return message;
+ return message.c_str();
}
Exception::~Exception() throw() {
diff --git a/cpp/core/src/zxing/Exception.h b/cpp/core/src/zxing/Exception.h
index 7502c5c..ac4026e 100644
--- a/cpp/core/src/zxing/Exception.h
+++ b/cpp/core/src/zxing/Exception.h
@@ -28,7 +28,7 @@ namespace zxing {
class Exception : public std::exception {
private:
- const char * message;
+ std::string message;
public:
Exception(const char *msg);
diff --git a/cpp/core/src/zxing/LuminanceSource.cpp b/cpp/core/src/zxing/LuminanceSource.cpp
index 6c8ef1e..d7af375 100644
--- a/cpp/core/src/zxing/LuminanceSource.cpp
+++ b/cpp/core/src/zxing/LuminanceSource.cpp
@@ -28,7 +28,7 @@ LuminanceSource::LuminanceSource() {
LuminanceSource::~LuminanceSource() {
}
-unsigned char* LuminanceSource::copyMatrix() {
+unsigned char* LuminanceSource::copyMatrix() const {
int width = getWidth();
int height = getHeight();
unsigned char* matrix = new unsigned char[width*height];
diff --git a/cpp/core/src/zxing/LuminanceSource.h b/cpp/core/src/zxing/LuminanceSource.h
index e23621e..fcc6588 100644
--- a/cpp/core/src/zxing/LuminanceSource.h
+++ b/cpp/core/src/zxing/LuminanceSource.h
@@ -30,11 +30,11 @@ public:
LuminanceSource();
virtual ~LuminanceSource();
- virtual int getWidth() = 0;
- virtual int getHeight() = 0;
+ virtual int getWidth() const = 0;
+ virtual int getHeight() const = 0;
- virtual unsigned char getPixel(int x, int y) = 0;
- virtual unsigned char* copyMatrix();
+ virtual unsigned char getPixel(int x, int y) const = 0;
+ virtual unsigned char* copyMatrix() const;
};
}
diff --git a/cpp/core/src/zxing/MultiFormatReader.cpp b/cpp/core/src/zxing/MultiFormatReader.cpp
index e65d0a9..5bdf165 100644
--- a/cpp/core/src/zxing/MultiFormatReader.cpp
+++ b/cpp/core/src/zxing/MultiFormatReader.cpp
@@ -27,19 +27,17 @@
#include <zxing/ReaderException.h>
namespace zxing {
- MultiFormatReader::MultiFormatReader(){
- readers = new std::vector<Reader*>();
-
- readers->push_back(new zxing::qrcode::QRCodeReader());
- readers->push_back(new zxing::datamatrix::DataMatrixReader());
- readers->push_back(new zxing::oned::MultiFormatUPCEANReader());
- readers->push_back(new zxing::oned::MultiFormatOneDReader());
+ MultiFormatReader::MultiFormatReader() : readers() {
+ readers.push_back(Ref<Reader>(new zxing::qrcode::QRCodeReader()));
+ readers.push_back(Ref<Reader>(new zxing::datamatrix::DataMatrixReader()));
+ readers.push_back(Ref<Reader>(new zxing::oned::MultiFormatUPCEANReader()));
+ readers.push_back(Ref<Reader>(new zxing::oned::MultiFormatOneDReader()));
}
Ref<Result> MultiFormatReader::decode(Ref<BinaryBitmap> image){
- int size = readers->size();
+ int size = readers.size();
for (int i = 0; i < size; i++) {
- Reader* reader = (*readers)[i];
+ Ref<Reader> reader = readers[i];
try {
return reader->decode(image);
} catch (ReaderException re) {
@@ -48,11 +46,4 @@ namespace zxing {
}
throw ReaderException("No code detected");
}
- MultiFormatReader::~MultiFormatReader(){
- int size = readers->size();
- for (int i = 0; i < size; i++) {
- delete (*readers)[i];
- }
- delete readers;
- }
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/MultiFormatReader.h b/cpp/core/src/zxing/MultiFormatReader.h
index 9fca54f..4cbe61b 100644
--- a/cpp/core/src/zxing/MultiFormatReader.h
+++ b/cpp/core/src/zxing/MultiFormatReader.h
@@ -27,12 +27,11 @@ namespace zxing {
class MultiFormatReader : public Reader {
private:
- std::vector<Reader*>* readers;
+ std::vector<Ref<Reader> >readers;
public:
MultiFormatReader();
Ref<Result> decode(Ref<BinaryBitmap> image);
-
- ~MultiFormatReader();
+
};
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/Reader.h b/cpp/core/src/zxing/Reader.h
index b4d96a4..d7844a9 100755
--- a/cpp/core/src/zxing/Reader.h
+++ b/cpp/core/src/zxing/Reader.h
@@ -26,10 +26,12 @@
namespace zxing {
-class Reader {
-public:
- virtual Ref<Result> decode(Ref<BinaryBitmap> image) = 0;
- virtual ~Reader();
+ class Reader : public Counted {
+ protected:
+ Reader() {}
+ public:
+ virtual Ref<Result> decode(Ref<BinaryBitmap> image) = 0;
+ virtual ~Reader();
};
}
diff --git a/cpp/core/src/zxing/Result.cpp b/cpp/core/src/zxing/Result.cpp
index f87ef88..6ea6582 100644
--- a/cpp/core/src/zxing/Result.cpp
+++ b/cpp/core/src/zxing/Result.cpp
@@ -39,11 +39,11 @@ ArrayRef<unsigned char> Result::getRawBytes() {
return rawBytes_;
}
-std::vector<Ref<ResultPoint> > Result::getResultPoints() {
+const std::vector<Ref<ResultPoint> >& Result::getResultPoints() const {
return resultPoints_;
}
-BarcodeFormat Result::getBarcodeFormat() {
+BarcodeFormat Result::getBarcodeFormat() const {
return format_;
}
diff --git a/cpp/core/src/zxing/Result.h b/cpp/core/src/zxing/Result.h
index 710d8d5..c9fcf43 100644
--- a/cpp/core/src/zxing/Result.h
+++ b/cpp/core/src/zxing/Result.h
@@ -44,8 +44,8 @@ public:
~Result();
Ref<String> getText();
ArrayRef<unsigned char> getRawBytes();
- std::vector<Ref<ResultPoint> > getResultPoints();
- BarcodeFormat getBarcodeFormat();
+ const std::vector<Ref<ResultPoint> >& getResultPoints() const;
+ BarcodeFormat getBarcodeFormat() const;
friend std::ostream& operator<<(std::ostream &out, Result& result);
};
diff --git a/cpp/core/src/zxing/ResultPoint.h b/cpp/core/src/zxing/ResultPoint.h
index 6118cc0..33dff70 100644
--- a/cpp/core/src/zxing/ResultPoint.h
+++ b/cpp/core/src/zxing/ResultPoint.h
@@ -26,9 +26,11 @@
namespace zxing {
class ResultPoint : public Counted {
+protected:
+ ResultPoint() {}
public:
- virtual float getX() = 0;
- virtual float getY() = 0;
+ virtual float getX() const = 0;
+ virtual float getY() const = 0;
};
}
diff --git a/cpp/core/src/zxing/common/BitArray.cpp b/cpp/core/src/zxing/common/BitArray.cpp
index e4627c7..9355d01 100644
--- a/cpp/core/src/zxing/common/BitArray.cpp
+++ b/cpp/core/src/zxing/common/BitArray.cpp
@@ -44,9 +44,6 @@ size_t BitArray::wordsForBits(size_t bits) {
}
return arraySize;
}
-BitArray::BitArray() {
- cout << "hey! don't use this BitArrayConstructor!\n";
-}
BitArray::BitArray(size_t size) :
size_(size), bits_(wordsForBits(size), (const unsigned int)0) {
diff --git a/cpp/core/src/zxing/common/BitMatrix.cpp b/cpp/core/src/zxing/common/BitMatrix.cpp
index 48a074d..8c137f2 100644
--- a/cpp/core/src/zxing/common/BitMatrix.cpp
+++ b/cpp/core/src/zxing/common/BitMatrix.cpp
@@ -53,7 +53,7 @@ static size_t wordsForSize(size_t width, size_t height) {
}
BitMatrix::BitMatrix(size_t dimension) :
- width_(dimension), height_(dimension), bits_(NULL) {
+ width_(dimension), height_(dimension), words_(0), bits_(NULL) {
words_ = wordsForSize(width_, height_);
bits_ = new unsigned int[words_];
@@ -61,7 +61,7 @@ BitMatrix::BitMatrix(size_t dimension) :
}
BitMatrix::BitMatrix(size_t width, size_t height) :
- width_(width), height_(height), bits_(NULL) {
+ width_(width), height_(height), words_(0), bits_(NULL) {
words_ = wordsForSize(width_, height_);
bits_ = new unsigned int[words_];
@@ -125,11 +125,11 @@ size_t BitMatrix::getDimension() const {
return width_;
}
-unsigned int* BitMatrix::getBits() {
+unsigned int* BitMatrix::getBits() const {
return bits_;
}
-ostream& operator<<(ostream &out, BitMatrix &bm) {
+ostream& operator<<(ostream &out, const BitMatrix &bm) {
for (size_t y = 0; y < bm.height_; y++) {
for (size_t x = 0; x < bm.width_; x++) {
out << (bm.get(x, y) ? "X " : " ");
diff --git a/cpp/core/src/zxing/common/BitMatrix.h b/cpp/core/src/zxing/common/BitMatrix.h
index a30e8ca..91d785e 100644
--- a/cpp/core/src/zxing/common/BitMatrix.h
+++ b/cpp/core/src/zxing/common/BitMatrix.h
@@ -49,10 +49,14 @@ public:
size_t getWidth() const;
size_t getHeight() const;
- unsigned int* getBits();
+ unsigned int* getBits() const;
- friend std::ostream& operator<<(std::ostream &out, BitMatrix &bm);
+ friend std::ostream& operator<<(std::ostream &out, const BitMatrix &bm);
const char *description();
+
+private:
+ BitMatrix(const BitMatrix&);
+ BitMatrix& operator =(const BitMatrix&);
};
}
diff --git a/cpp/core/src/zxing/common/Counted.h b/cpp/core/src/zxing/common/Counted.h
index dd0f845..4f2b369 100644
--- a/cpp/core/src/zxing/common/Counted.h
+++ b/cpp/core/src/zxing/common/Counted.h
@@ -172,10 +172,10 @@ public:
T& operator*() {
return *object_;
}
- T* operator->() {
+ T* operator->() const {
return object_;
}
- operator T*() {
+ operator T*() const {
return object_;
}
diff --git a/cpp/core/src/zxing/common/PerspectiveTransform.cpp b/cpp/core/src/zxing/common/PerspectiveTransform.cpp
index 0344a81..16d1327 100644
--- a/cpp/core/src/zxing/common/PerspectiveTransform.cpp
+++ b/cpp/core/src/zxing/common/PerspectiveTransform.cpp
@@ -23,18 +23,13 @@
namespace zxing {
using namespace std;
-PerspectiveTransform::PerspectiveTransform(float a11, float a21, float a31, float a12, float a22, float a32, float a13,
- float a23, float a33) {
- this->a11 = a11;
- this->a12 = a12;
- this->a13 = a13;
- this->a21 = a21;
- this->a22 = a22;
- this->a23 = a23;
- this->a31 = a31;
- this->a32 = a32;
- this->a33 = a33;
-}
+PerspectiveTransform::PerspectiveTransform(float inA11, float inA21,
+ float inA31, float inA12,
+ float inA22, float inA32,
+ float inA13, float inA23,
+ float inA33) :
+ a11(inA11), a21(inA21), a31(inA31), a12(inA12), a22(inA22), a32(inA32),
+ a13(inA13), a23(inA23), a33(inA33) {}
Ref<PerspectiveTransform> PerspectiveTransform::quadrilateralToQuadrilateral(float x0, float y0, float x1, float y1,
float x2, float y2, float x3, float y3, float x0p, float y0p, float x1p, float y1p, float x2p, float y2p,
@@ -93,15 +88,6 @@ Ref<PerspectiveTransform> PerspectiveTransform::times(Ref<PerspectiveTransform>
void PerspectiveTransform::transformPoints(vector<float> &points) {
int max = points.size();
- float a11 = this->a11;
- float a12 = this->a12;
- float a13 = this->a13;
- float a21 = this->a21;
- float a22 = this->a22;
- float a23 = this->a23;
- float a31 = this->a31;
- float a32 = this->a32;
- float a33 = this->a33;
for (int i = 0; i < max; i += 2) {
float x = points[i];
float y = points[i + 1];
@@ -111,7 +97,7 @@ void PerspectiveTransform::transformPoints(vector<float> &points) {
}
}
-ostream& operator<<(ostream& out, PerspectiveTransform &pt) {
+ostream& operator<<(ostream& out, const PerspectiveTransform &pt) {
out << pt.a11 << ", " << pt.a12 << ", " << pt.a13 << ", \n";
out << pt.a21 << ", " << pt.a22 << ", " << pt.a23 << ", \n";
out << pt.a31 << ", " << pt.a32 << ", " << pt.a33 << "\n";
diff --git a/cpp/core/src/zxing/common/PerspectiveTransform.h b/cpp/core/src/zxing/common/PerspectiveTransform.h
index b95a8fb..b322632 100644
--- a/cpp/core/src/zxing/common/PerspectiveTransform.h
+++ b/cpp/core/src/zxing/common/PerspectiveTransform.h
@@ -43,7 +43,7 @@ public:
Ref<PerspectiveTransform> times(Ref<PerspectiveTransform> other);
void transformPoints(std::vector<float> &points);
- friend std::ostream& operator<<(std::ostream& out, PerspectiveTransform &pt);
+ friend std::ostream& operator<<(std::ostream& out, const PerspectiveTransform &pt);
};
}
diff --git a/cpp/core/src/zxing/common/Str.cpp b/cpp/core/src/zxing/common/Str.cpp
index e2122dc..6259f94 100644
--- a/cpp/core/src/zxing/common/Str.cpp
+++ b/cpp/core/src/zxing/common/Str.cpp
@@ -26,7 +26,7 @@ using namespace std;
String::String(const std::string &text) :
text_(text) {
}
-std::string& String::getText() {
+const std::string& String::getText() const {
return text_;
}
diff --git a/cpp/core/src/zxing/common/Str.h b/cpp/core/src/zxing/common/Str.h
index 255a055..09ff2bb 100644
--- a/cpp/core/src/zxing/common/Str.h
+++ b/cpp/core/src/zxing/common/Str.h
@@ -32,7 +32,7 @@ private:
std::string text_;
public:
String(const std::string &text);
- std::string &getText();
+ const std::string &getText() const;
friend std::ostream &operator<<(std::ostream &out, const String &s);
};
diff --git a/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp b/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp
index 92caa72..8b00161 100644
--- a/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp
+++ b/cpp/core/src/zxing/datamatrix/DataMatrixReader.cpp
@@ -53,8 +53,8 @@ Ref<Result> DataMatrixReader::decode(Ref<BinaryBitmap> image) {
#ifdef DEBUG
cout << "(3) extracted points " << &points << "\n" << flush;
- cout << "found " << points->size() << " points:\n";
- for (size_t i = 0; i < points->size(); i++) {
+ cout << "found " << points.size() << " points:\n";
+ for (size_t i = 0; i < points.size(); i++) {
cout << " " << points[i]->getX() << "," << points[i]->getY() << "\n";
}
cout << "bits:\n";
diff --git a/cpp/core/src/zxing/datamatrix/Version.cpp b/cpp/core/src/zxing/datamatrix/Version.cpp
index 267b334..e48d88e 100644
--- a/cpp/core/src/zxing/datamatrix/Version.cpp
+++ b/cpp/core/src/zxing/datamatrix/Version.cpp
@@ -39,13 +39,11 @@ int ECB::getDataCodewords() {
}
ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks) :
- ecCodewords_(ecCodewords) {
- ecBlocks_.push_back(ecBlocks);
+ ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks) {
}
ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2) :
- ecCodewords_(ecCodewords) {
- ecBlocks_.push_back(ecBlocks1);
+ ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks1) {
ecBlocks_.push_back(ecBlocks2);
}
@@ -70,7 +68,7 @@ Version::Version(int versionNumber, int symbolSizeRows, int symbolSizeColumns, i
int dataRegionSizeColumns, ECBlocks* ecBlocks) : versionNumber_(versionNumber),
symbolSizeRows_(symbolSizeRows), symbolSizeColumns_(symbolSizeColumns),
dataRegionSizeRows_(dataRegionSizeRows), dataRegionSizeColumns_(dataRegionSizeColumns),
- ecBlocks_(ecBlocks) {
+ ecBlocks_(ecBlocks), totalCodewords_(0) {
// Calculate the total number of codewords
int total = 0;
int ecCodewords = ecBlocks_->getECCodewords();
@@ -114,7 +112,7 @@ ECBlocks* Version::getECBlocks() {
return ecBlocks_;
}
-Version* Version::getVersionForDimensions(int numRows, int numColumns) {
+Ref<Version> Version::getVersionForDimensions(int numRows, int numColumns) {
if ((numRows & 0x01) != 0 || (numColumns & 0x01) != 0) {
throw ReaderException("Number of rows and columns must be even");
}
@@ -123,7 +121,7 @@ Version* Version::getVersionForDimensions(int numRows, int numColumns) {
// If we interleave the rectangular versions with the square versions we could
// do a binary search.
for (int i = 0; i < N_VERSIONS; ++i){
- Version* version = VERSIONS[i];
+ Ref<Version> version(VERSIONS[i]);
if (version->getSymbolSizeRows() == numRows && version->getSymbolSizeColumns() == numColumns) {
return version;
}
diff --git a/cpp/core/src/zxing/datamatrix/Version.h b/cpp/core/src/zxing/datamatrix/Version.h
index 97e3a5a..d8523fe 100644
--- a/cpp/core/src/zxing/datamatrix/Version.h
+++ b/cpp/core/src/zxing/datamatrix/Version.h
@@ -28,7 +28,6 @@
namespace zxing {
namespace datamatrix {
-using namespace std;
class ECB {
private:
@@ -76,7 +75,11 @@ public:
int getTotalCodewords();
ECBlocks* getECBlocks();
static int buildVersions();
- Version* getVersionForDimensions(int numRows, int numColumns);
+ Ref<Version> getVersionForDimensions(int numRows, int numColumns);
+
+private:
+ Version(const Version&);
+ Version & operator=(const Version&);
};
}
}
diff --git a/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.cpp b/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.cpp
index 08faa76..3be8a45 100644
--- a/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.cpp
+++ b/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.cpp
@@ -28,27 +28,29 @@ int BitMatrixParser::copyBit(size_t x, size_t y, int versionBits) {
return bitMatrix_->get(x, y) ? (versionBits << 1) | 0x1 : versionBits << 1;
}
-BitMatrixParser::BitMatrixParser(Ref<BitMatrix> bitMatrix) : parsedVersion_(0) {
+BitMatrixParser::BitMatrixParser(Ref<BitMatrix> bitMatrix) : parsedVersion_(NULL),
+ bitMatrix_(NULL),
+ readBitMatrix_(NULL) {
size_t dimension = bitMatrix->getDimension();
if (dimension < 10 || dimension > 144 || (dimension & 0x01) != 0)
throw ReaderException("Dimension must be even, > 10 < 144");
-
+
parsedVersion_ = readVersion(bitMatrix);
- bitMatrix_ = extractDataRegion(bitMatrix);
- // TODO(bbrown): Make this work for rectangular symbols
+ bitMatrix_ = extractDataRegion(bitMatrix);
+ // TODO(bbrown): Make this work for rectangular symbols
readBitMatrix_ = new BitMatrix(bitMatrix_->getDimension());
}
-Version *BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
+Ref<Version> BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
if (parsedVersion_ != 0) {
return parsedVersion_;
}
-
- // TODO(bbrown): make this work for rectangular dimensions as well.
- int numRows = bitMatrix->getDimension();
- int numColumns = numRows;
+
+ // TODO(bbrown): make this work for rectangular dimensions as well.
+ int numRows = bitMatrix->getDimension();
+ int numColumns = numRows;
- Version* version = parsedVersion_->getVersionForDimensions(numRows, numColumns);
+ Ref<Version> version = parsedVersion_->getVersionForDimensions(numRows, numColumns);
if (version != 0) {
return version;
}
@@ -57,305 +59,305 @@ Version *BitMatrixParser::readVersion(Ref<BitMatrix> bitMatrix) {
ArrayRef<unsigned char> BitMatrixParser::readCodewords() {
ArrayRef<unsigned char> result(parsedVersion_->getTotalCodewords());
- int resultOffset = 0;
- int row = 4;
+ int resultOffset = 0;
+ int row = 4;
int column = 0;
-
- // TODO(bbrown): Data Matrix can be rectangular, assuming square for now
- int numRows = bitMatrix_->getDimension();
- int numColumns = numRows;
-
- bool corner1Read = false;
- bool corner2Read = false;
- bool corner3Read = false;
- bool corner4Read = false;
-
- // Read all of the codewords
- do {
- // Check the four corner cases
- if ((row == numRows) && (column == 0) && !corner1Read) {
- result[resultOffset++] = (unsigned char) readCorner1(numRows, numColumns);
- row -= 2;
- column +=2;
- corner1Read = true;
- } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
- result[resultOffset++] = (unsigned char) readCorner2(numRows, numColumns);
- row -= 2;
- column +=2;
- corner2Read = true;
- } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
- result[resultOffset++] = (unsigned char) readCorner3(numRows, numColumns);
- row -= 2;
- column +=2;
- corner3Read = true;
- } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
- result[resultOffset++] = (unsigned char) readCorner4(numRows, numColumns);
- row -= 2;
- column +=2;
- corner4Read = true;
- } else {
- // Sweep upward diagonally to the right
- do {
- if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) {
- result[resultOffset++] = (unsigned char) readUtah(row, column, numRows, numColumns);
- }
- row -= 2;
- column +=2;
- } while ((row >= 0) && (column < numColumns));
- row += 1;
- column +=3;
-
- // Sweep downward diagonally to the left
- do {
- if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) {
- result[resultOffset++] = (unsigned char) readUtah(row, column, numRows, numColumns);
- }
- row += 2;
- column -=2;
- } while ((row < numRows) && (column >= 0));
- row += 3;
- column +=1;
- }
- } while ((row < numRows) || (column < numColumns));
-
- if (resultOffset != parsedVersion_->getTotalCodewords()) {
- throw ReaderException("Did not read all codewords");
- }
+
+ // TODO(bbrown): Data Matrix can be rectangular, assuming square for now
+ int numRows = bitMatrix_->getDimension();
+ int numColumns = numRows;
+
+ bool corner1Read = false;
+ bool corner2Read = false;
+ bool corner3Read = false;
+ bool corner4Read = false;
+
+ // Read all of the codewords
+ do {
+ // Check the four corner cases
+ if ((row == numRows) && (column == 0) && !corner1Read) {
+ result[resultOffset++] = (unsigned char) readCorner1(numRows, numColumns);
+ row -= 2;
+ column +=2;
+ corner1Read = true;
+ } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x03) != 0) && !corner2Read) {
+ result[resultOffset++] = (unsigned char) readCorner2(numRows, numColumns);
+ row -= 2;
+ column +=2;
+ corner2Read = true;
+ } else if ((row == numRows+4) && (column == 2) && ((numColumns & 0x07) == 0) && !corner3Read) {
+ result[resultOffset++] = (unsigned char) readCorner3(numRows, numColumns);
+ row -= 2;
+ column +=2;
+ corner3Read = true;
+ } else if ((row == numRows-2) && (column == 0) && ((numColumns & 0x07) == 4) && !corner4Read) {
+ result[resultOffset++] = (unsigned char) readCorner4(numRows, numColumns);
+ row -= 2;
+ column +=2;
+ corner4Read = true;
+ } else {
+ // Sweep upward diagonally to the right
+ do {
+ if ((row < numRows) && (column >= 0) && !readBitMatrix_->get(column, row)) {
+ result[resultOffset++] = (unsigned char) readUtah(row, column, numRows, numColumns);
+ }
+ row -= 2;
+ column +=2;
+ } while ((row >= 0) && (column < numColumns));
+ row += 1;
+ column +=3;
+
+ // Sweep downward diagonally to the left
+ do {
+ if ((row >= 0) && (column < numColumns) && !readBitMatrix_->get(column, row)) {
+ result[resultOffset++] = (unsigned char) readUtah(row, column, numRows, numColumns);
+ }
+ row += 2;
+ column -=2;
+ } while ((row < numRows) && (column >= 0));
+ row += 3;
+ column +=1;
+ }
+ } while ((row < numRows) || (column < numColumns));
+
+ if (resultOffset != parsedVersion_->getTotalCodewords()) {
+ throw ReaderException("Did not read all codewords");
+ }
return result;
-}
+}
+
+bool BitMatrixParser::readModule(int row, int column, int numRows, int numColumns) {
+ // Adjust the row and column indices based on boundary wrapping
+ if (row < 0) {
+ row += numRows;
+ column += 4 - ((numRows + 4) & 0x07);
+ }
+ if (column < 0) {
+ column += numColumns;
+ row += 4 - ((numColumns + 4) & 0x07);
+ }
+ readBitMatrix_->set(column, row);
+ return bitMatrix_->get(column, row);
+ }
+
+int BitMatrixParser::readUtah(int row, int column, int numRows, int numColumns) {
+ int currentByte = 0;
+ if (readModule(row - 2, column - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row - 2, column - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row - 1, column - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row - 1, column - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row - 1, column, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row, column - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row, column - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(row, column, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
+ }
+
+int BitMatrixParser::readCorner1(int numRows, int numColumns) {
+ int currentByte = 0;
+ if (readModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 1, 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 1, 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(2, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(3, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
+ }
+
+int BitMatrixParser::readCorner2(int numRows, int numColumns) {
+ int currentByte = 0;
+ if (readModule(numRows - 3, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 2, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 4, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 3, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
+ }
+
+int BitMatrixParser::readCorner3(int numRows, int numColumns) {
+ int currentByte = 0;
+ if (readModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 3, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(1, numColumns - 3, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(1, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
+ }
+
+int BitMatrixParser::readCorner4(int numRows, int numColumns) {
+ int currentByte = 0;
+ if (readModule(numRows - 3, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 2, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(numRows - 1, 0, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 2, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(0, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(1, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(2, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ currentByte <<= 1;
+ if (readModule(3, numColumns - 1, numRows, numColumns)) {
+ currentByte |= 1;
+ }
+ return currentByte;
+ }
-bool BitMatrixParser::readModule(int row, int column, int numRows, int numColumns) {
- // Adjust the row and column indices based on boundary wrapping
- if (row < 0) {
- row += numRows;
- column += 4 - ((numRows + 4) & 0x07);
- }
- if (column < 0) {
- column += numColumns;
- row += 4 - ((numColumns + 4) & 0x07);
- }
- readBitMatrix_->set(column, row);
- return bitMatrix_->get(column, row);
- }
-
-int BitMatrixParser::readUtah(int row, int column, int numRows, int numColumns) {
- int currentByte = 0;
- if (readModule(row - 2, column - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row - 2, column - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row - 1, column - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row - 1, column - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row - 1, column, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row, column - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row, column - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(row, column, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
- }
-
-int BitMatrixParser::readCorner1(int numRows, int numColumns) {
- int currentByte = 0;
- if (readModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 1, 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 1, 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(2, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(3, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
- }
-
-int BitMatrixParser::readCorner2(int numRows, int numColumns) {
- int currentByte = 0;
- if (readModule(numRows - 3, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 2, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 4, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 3, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
- }
-
-int BitMatrixParser::readCorner3(int numRows, int numColumns) {
- int currentByte = 0;
- if (readModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 3, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(1, numColumns - 3, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(1, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
- }
-
-int BitMatrixParser::readCorner4(int numRows, int numColumns) {
- int currentByte = 0;
- if (readModule(numRows - 3, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 2, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(numRows - 1, 0, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 2, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(0, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(1, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(2, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- currentByte <<= 1;
- if (readModule(3, numColumns - 1, numRows, numColumns)) {
- currentByte |= 1;
- }
- return currentByte;
- }
-
-Ref<BitMatrix> BitMatrixParser::extractDataRegion(Ref<BitMatrix> bitMatrix) {
- int symbolSizeRows = parsedVersion_->getSymbolSizeRows();
- int symbolSizeColumns = parsedVersion_->getSymbolSizeColumns();
-
- // TODO(bbrown): Make this work with rectangular codes
- if ((int)bitMatrix->getDimension() != symbolSizeRows) {
- throw IllegalArgumentException("Dimension of bitMarix must match the version size");
- }
-
- int dataRegionSizeRows = parsedVersion_->getDataRegionSizeRows();
- int dataRegionSizeColumns = parsedVersion_->getDataRegionSizeColumns();
-
- int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
- int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
-
- int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
- //int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
-
- // TODO(bbrown): Make this work with rectangular codes
- Ref<BitMatrix> bitMatrixWithoutAlignment(new BitMatrix(sizeDataRegionRow));
- for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
- int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
- for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) {
- int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns;
- for (int i = 0; i < dataRegionSizeRows; ++i) {
- int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i;
- int writeRowOffset = dataRegionRowOffset + i;
- for (int j = 0; j < dataRegionSizeColumns; ++j) {
- int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j;
- if (bitMatrix->get(readColumnOffset, readRowOffset)) {
- int writeColumnOffset = dataRegionColumnOffset + j;
- bitMatrixWithoutAlignment->set(writeColumnOffset, writeRowOffset);
- }
- }
- }
- }
- }
- return bitMatrixWithoutAlignment;
+Ref<BitMatrix> BitMatrixParser::extractDataRegion(Ref<BitMatrix> bitMatrix) {
+ int symbolSizeRows = parsedVersion_->getSymbolSizeRows();
+ int symbolSizeColumns = parsedVersion_->getSymbolSizeColumns();
+
+ // TODO(bbrown): Make this work with rectangular codes
+ if ((int)bitMatrix->getDimension() != symbolSizeRows) {
+ throw IllegalArgumentException("Dimension of bitMarix must match the version size");
+ }
+
+ int dataRegionSizeRows = parsedVersion_->getDataRegionSizeRows();
+ int dataRegionSizeColumns = parsedVersion_->getDataRegionSizeColumns();
+
+ int numDataRegionsRow = symbolSizeRows / dataRegionSizeRows;
+ int numDataRegionsColumn = symbolSizeColumns / dataRegionSizeColumns;
+
+ int sizeDataRegionRow = numDataRegionsRow * dataRegionSizeRows;
+ //int sizeDataRegionColumn = numDataRegionsColumn * dataRegionSizeColumns;
+
+ // TODO(bbrown): Make this work with rectangular codes
+ Ref<BitMatrix> bitMatrixWithoutAlignment(new BitMatrix(sizeDataRegionRow));
+ for (int dataRegionRow = 0; dataRegionRow < numDataRegionsRow; ++dataRegionRow) {
+ int dataRegionRowOffset = dataRegionRow * dataRegionSizeRows;
+ for (int dataRegionColumn = 0; dataRegionColumn < numDataRegionsColumn; ++dataRegionColumn) {
+ int dataRegionColumnOffset = dataRegionColumn * dataRegionSizeColumns;
+ for (int i = 0; i < dataRegionSizeRows; ++i) {
+ int readRowOffset = dataRegionRow * (dataRegionSizeRows + 2) + 1 + i;
+ int writeRowOffset = dataRegionRowOffset + i;
+ for (int j = 0; j < dataRegionSizeColumns; ++j) {
+ int readColumnOffset = dataRegionColumn * (dataRegionSizeColumns + 2) + 1 + j;
+ if (bitMatrix->get(readColumnOffset, readRowOffset)) {
+ int writeColumnOffset = dataRegionColumnOffset + j;
+ bitMatrixWithoutAlignment->set(writeColumnOffset, writeRowOffset);
+ }
+ }
+ }
+ }
+ }
+ return bitMatrixWithoutAlignment;
}
}
diff --git a/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.h b/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.h
index 92097ae..174fc1c 100644
--- a/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.h
+++ b/cpp/core/src/zxing/datamatrix/decoder/BitMatrixParser.h
@@ -34,22 +34,22 @@ class BitMatrixParser : public Counted {
private:
Ref<BitMatrix> bitMatrix_;
Ref<BitMatrix> readBitMatrix_;
- Version *parsedVersion_;
+ Ref<Version> parsedVersion_;
int copyBit(size_t x, size_t y, int versionBits);
public:
BitMatrixParser(Ref<BitMatrix> bitMatrix);
- Version *readVersion(Ref<BitMatrix> bitMatrix);
+ Ref<Version> readVersion(Ref<BitMatrix> bitMatrix);
ArrayRef<unsigned char> readCodewords();
bool readModule(int row, int column, int numRows, int numColumns);
-private:
- int readUtah(int row, int column, int numRows, int numColumns);
- int readCorner1(int numRows, int numColumns);
- int readCorner2(int numRows, int numColumns);
+private:
+ int readUtah(int row, int column, int numRows, int numColumns);
+ int readCorner1(int numRows, int numColumns);
+ int readCorner2(int numRows, int numColumns);
int readCorner3(int numRows, int numColumns);
- int readCorner4(int numRows, int numColumns);
+ int readCorner4(int numRows, int numColumns);
Ref<BitMatrix> extractDataRegion(Ref<BitMatrix> bitMatrix);
};
diff --git a/cpp/core/src/zxing/datamatrix/detector/CornerPoint.cpp b/cpp/core/src/zxing/datamatrix/detector/CornerPoint.cpp
index 00ad26d..8222f6b 100644
--- a/cpp/core/src/zxing/datamatrix/detector/CornerPoint.cpp
+++ b/cpp/core/src/zxing/datamatrix/detector/CornerPoint.cpp
@@ -27,18 +27,18 @@ namespace zxing {
using namespace std;
CornerPoint::CornerPoint(float posX, float posY) :
- posX_(posX), posY_(posY) {
+ posX_(posX), posY_(posY), counter_(0) {
}
- float CornerPoint::getX() {
+ float CornerPoint::getX() const {
return posX_;
}
- float CornerPoint::getY() {
+ float CornerPoint::getY() const {
return posY_;
}
- int CornerPoint::getCount() {
+ int CornerPoint::getCount() const {
return counter_;
}
@@ -46,7 +46,7 @@ namespace zxing {
counter_++;
}
- bool CornerPoint::equals(Ref<CornerPoint> other) {
+ bool CornerPoint::equals(Ref<CornerPoint> other) const {
return posX_ == other->getX() && posY_ == other->getY();
}
diff --git a/cpp/core/src/zxing/datamatrix/detector/CornerPoint.h b/cpp/core/src/zxing/datamatrix/detector/CornerPoint.h
index 06ef879..a44d72b 100644
--- a/cpp/core/src/zxing/datamatrix/detector/CornerPoint.h
+++ b/cpp/core/src/zxing/datamatrix/detector/CornerPoint.h
@@ -35,11 +35,11 @@ namespace zxing {
public:
CornerPoint(float posX, float posY);
- float getX();
- float getY();
- int getCount();
+ float getX() const;
+ float getY() const;
+ int getCount() const;
void incrementCount();
- bool equals(Ref<CornerPoint> other);
+ bool equals(Ref<CornerPoint> other) const;
};
}
}
diff --git a/cpp/core/src/zxing/datamatrix/detector/Detector.cpp b/cpp/core/src/zxing/datamatrix/detector/Detector.cpp
index 6c9aad5..5373cc4 100644
--- a/cpp/core/src/zxing/datamatrix/detector/Detector.cpp
+++ b/cpp/core/src/zxing/datamatrix/detector/Detector.cpp
@@ -29,17 +29,14 @@ namespace datamatrix {
using namespace std;
-ResultPointsAndTransitions::ResultPointsAndTransitions() {
+ResultPointsAndTransitions::ResultPointsAndTransitions() : from_(), to_(), transitions_(0) {
Ref<CornerPoint> ref(new CornerPoint(0,0));
from_ = ref;
to_ = ref;
- transitions_ = 0;
}
-ResultPointsAndTransitions::ResultPointsAndTransitions(Ref<CornerPoint> from, Ref<CornerPoint> to, int transitions) {
- from_ = from;
- to_ = to;
- transitions_ = transitions;
+ResultPointsAndTransitions::ResultPointsAndTransitions(Ref<CornerPoint> from, Ref<CornerPoint> to, int transitions) :
+ from_(from), to_(to), transitions_(transitions) {
}
Ref<CornerPoint> ResultPointsAndTransitions::getFrom() {
diff --git a/cpp/core/src/zxing/oned/Code39Reader.cpp b/cpp/core/src/zxing/oned/Code39Reader.cpp
index fbf2580..92e63b5 100644
--- a/cpp/core/src/zxing/oned/Code39Reader.cpp
+++ b/cpp/core/src/zxing/oned/Code39Reader.cpp
@@ -46,17 +46,16 @@ namespace zxing {
};
static int ASTERISK_ENCODING = 0x094;
-
+ static const char* ALPHABET_STRING = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%";
/**
* Creates a reader that assumes all encoded data is data, and does not treat the final
* character as a check digit. It will not decoded "extended Code 39" sequences.
*/
- Code39Reader::Code39Reader(){
- ALPHABET_STRING = new std::string("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%");
- usingCheckDigit = false;
- extendedMode = false;
+ Code39Reader::Code39Reader() : alphabet_string(ALPHABET_STRING),
+ usingCheckDigit(false),
+ extendedMode(false) {
}
/**
@@ -66,10 +65,9 @@ namespace zxing {
* @param usingCheckDigit if true, treat the last data character as a check digit, not
* data, and verify that the checksum passes.
*/
- Code39Reader::Code39Reader(bool usingCheckDigit_){
- ALPHABET_STRING = new std::string("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. *$/+%");
- usingCheckDigit = usingCheckDigit_;
- extendedMode = false;
+ Code39Reader::Code39Reader(bool usingCheckDigit_) : alphabet_string(ALPHABET_STRING),
+ usingCheckDigit(usingCheckDigit_),
+ extendedMode(false) {
}
@@ -138,9 +136,9 @@ namespace zxing {
int max = tmpResultString.length() - 1;
int total = 0;
for (int i = 0; i < max; i++) {
- total += ALPHABET_STRING->find_first_of(tmpResultString[i], 0);
+ total += alphabet_string.find_first_of(tmpResultString[i], 0);
}
- if (total % 43 != ALPHABET_STRING->find_first_of(tmpResultString[max], 0)) {
+ if (total % 43 != alphabet_string.find_first_of(tmpResultString[max], 0)) {
throw ReaderException("");
}
tmpResultString.erase(max, 1);
@@ -344,11 +342,5 @@ namespace zxing {
Ref<String> decoded(new String(tmpDecoded));
return decoded;
}
-
-
- Code39Reader::~Code39Reader(){
- delete ALPHABET_STRING;
- }
-
}
}
diff --git a/cpp/core/src/zxing/oned/Code39Reader.h b/cpp/core/src/zxing/oned/Code39Reader.h
index 1846761..cc7148c 100644
--- a/cpp/core/src/zxing/oned/Code39Reader.h
+++ b/cpp/core/src/zxing/oned/Code39Reader.h
@@ -33,7 +33,7 @@ namespace zxing {
class Code39Reader : public OneDReader {
private:
- std::string* ALPHABET_STRING;
+ std::string alphabet_string;
bool usingCheckDigit;
bool extendedMode;
@@ -49,9 +49,7 @@ namespace zxing {
Code39Reader(bool usingCheckDigit_);
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
-
- ~Code39Reader();
- };
+ };
}
}
diff --git a/cpp/core/src/zxing/oned/EAN13Reader.cpp b/cpp/core/src/zxing/oned/EAN13Reader.cpp
index fecb8e7..a1b9667 100644
--- a/cpp/core/src/zxing/oned/EAN13Reader.cpp
+++ b/cpp/core/src/zxing/oned/EAN13Reader.cpp
@@ -27,20 +27,11 @@ namespace zxing {
static const int FIRST_DIGIT_ENCODINGS[10] = {0x00, 0x0B, 0x0D, 0xE, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A};
- EAN13Reader::EAN13Reader(){
- decodeMiddleCounters = new int[4];
- for (int i=0; i<4; i++) {
- decodeMiddleCounters[i] = 0;
- }
- }
+ EAN13Reader::EAN13Reader() { }
int EAN13Reader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
- int countersLen = 4;
- int* counters = decodeMiddleCounters;
- counters[0] = 0;
- counters[1] = 0;
- counters[2] = 0;
- counters[3] = 0;
+ const int countersLen = 4;
+ int counters[countersLen] = { 0, 0, 0, 0 };
int end = row->getSize();
@@ -88,8 +79,5 @@ namespace zxing {
BarcodeFormat EAN13Reader::getBarcodeFormat(){
return BarcodeFormat_EAN_13;
}
- EAN13Reader::~EAN13Reader(){
- delete [] decodeMiddleCounters;
- }
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/EAN13Reader.h b/cpp/core/src/zxing/oned/EAN13Reader.h
index 8ef6fe3..540d326 100644
--- a/cpp/core/src/zxing/oned/EAN13Reader.h
+++ b/cpp/core/src/zxing/oned/EAN13Reader.h
@@ -26,7 +26,6 @@ namespace zxing {
class EAN13Reader : public UPCEANReader {
private:
- int* decodeMiddleCounters;
static void determineFirstDigit(std::string& resultString, int lgPatternFound); //throws ReaderException
public:
@@ -35,7 +34,6 @@ namespace zxing {
int decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString); //throws ReaderException
BarcodeFormat getBarcodeFormat();
- ~EAN13Reader();
};
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/EAN8Reader.cpp b/cpp/core/src/zxing/oned/EAN8Reader.cpp
index 52d09fe..e3c0e2a 100644
--- a/cpp/core/src/zxing/oned/EAN8Reader.cpp
+++ b/cpp/core/src/zxing/oned/EAN8Reader.cpp
@@ -24,21 +24,11 @@
namespace zxing {
namespace oned {
- EAN8Reader::EAN8Reader(){
- decodeMiddleCounters = new int[4];
- for (int i=0; i<4; i++) {
- decodeMiddleCounters[i] = 0;
- }
- }
+ EAN8Reader::EAN8Reader(){ }
int EAN8Reader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
- int countersLen = 4;
- int* counters = decodeMiddleCounters;
- counters[0] = 0;
- counters[1] = 0;
- counters[2] = 0;
- counters[3] = 0;
-
+ const int countersLen = 4;
+ int counters[countersLen] = { 0, 0, 0, 0 };
int end = row->getSize();
int rowOffset = startRange[1];
@@ -68,8 +58,5 @@ namespace zxing {
BarcodeFormat EAN8Reader::getBarcodeFormat(){
return BarcodeFormat_EAN_8;
}
- EAN8Reader::~EAN8Reader(){
- delete [] decodeMiddleCounters;
- }
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/EAN8Reader.h b/cpp/core/src/zxing/oned/EAN8Reader.h
index 3e4f3d6..481944c 100644
--- a/cpp/core/src/zxing/oned/EAN8Reader.h
+++ b/cpp/core/src/zxing/oned/EAN8Reader.h
@@ -25,16 +25,12 @@ namespace zxing {
namespace oned {
class EAN8Reader : public UPCEANReader {
- private:
- int* decodeMiddleCounters;
-
public:
EAN8Reader();
int decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString); //throws ReaderException
BarcodeFormat getBarcodeFormat();
- ~EAN8Reader();
};
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/ITFReader.cpp b/cpp/core/src/zxing/oned/ITFReader.cpp
index c00ba56..51a712f 100644
--- a/cpp/core/src/zxing/oned/ITFReader.cpp
+++ b/cpp/core/src/zxing/oned/ITFReader.cpp
@@ -62,8 +62,7 @@ namespace zxing {
};
- ITFReader::ITFReader(){
- narrowLineWidth = -1;
+ ITFReader::ITFReader() : narrowLineWidth(-1) {
}
diff --git a/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp b/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp
index cfb4b10..ea44471 100644
--- a/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp
+++ b/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp
@@ -28,18 +28,17 @@
namespace zxing {
namespace oned {
- MultiFormatOneDReader::MultiFormatOneDReader(){
- readers = new std::vector<OneDReader*>();
- readers->push_back(new MultiFormatUPCEANReader());
- readers->push_back(new Code39Reader());
- readers->push_back(new Code128Reader());
- readers->push_back(new ITFReader());
+ MultiFormatOneDReader::MultiFormatOneDReader() : readers() {
+ readers.push_back(Ref<OneDReader>(new MultiFormatUPCEANReader()));
+ readers.push_back(Ref<OneDReader>(new Code39Reader()));
+ readers.push_back(Ref<OneDReader>(new Code128Reader()));
+ readers.push_back(Ref<OneDReader>(new ITFReader()));
}
Ref<Result> MultiFormatOneDReader::decodeRow(int rowNumber, Ref<BitArray> row){
- int size = readers->size();
+ int size = readers.size();
for (int i = 0; i < size; i++) {
- OneDReader* reader = (*readers)[i];
+ OneDReader* reader = readers[i];
try {
return reader->decodeRow(rowNumber, row);
} catch (ReaderException re) {
@@ -48,12 +47,5 @@ namespace zxing {
}
throw ReaderException("No code detected");
}
- MultiFormatOneDReader::~MultiFormatOneDReader(){
- int size = readers->size();
- for (int i = 0; i < size; i++) {
- delete (*readers)[i];
- }
- delete readers;
- }
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/MultiFormatOneDReader.h b/cpp/core/src/zxing/oned/MultiFormatOneDReader.h
index 9fcc6fb..0e5ab53 100644
--- a/cpp/core/src/zxing/oned/MultiFormatOneDReader.h
+++ b/cpp/core/src/zxing/oned/MultiFormatOneDReader.h
@@ -27,13 +27,11 @@ namespace zxing {
class MultiFormatOneDReader : public OneDReader {
private:
- std::vector<OneDReader*>* readers;
+ std::vector<Ref<OneDReader> > readers;
public:
MultiFormatOneDReader();
- Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
-
- ~MultiFormatOneDReader();
+ Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
};
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp b/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp
index 4331911..24aa5e6 100644
--- a/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp
+++ b/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.cpp
@@ -30,19 +30,18 @@
namespace zxing {
namespace oned {
- MultiFormatUPCEANReader::MultiFormatUPCEANReader(){
- readers = new std::vector<OneDReader*>();
- readers->push_back(new EAN13Reader());
+ MultiFormatUPCEANReader::MultiFormatUPCEANReader() : readers() {
+ readers.push_back(Ref<OneDReader>(new EAN13Reader()));
// UPC-A is covered by EAN-13
- readers->push_back(new EAN8Reader());
- readers->push_back(new UPCEReader());
+ readers.push_back(Ref<OneDReader>(new EAN8Reader()));
+ readers.push_back(Ref<OneDReader>(new UPCEReader()));
}
Ref<Result> MultiFormatUPCEANReader::decodeRow(int rowNumber, Ref<BitArray> row){
// Compute this location once and reuse it on multiple implementations
- int size = readers->size();
+ int size = readers.size();
for (int i = 0; i < size; i++) {
- OneDReader* reader = (*readers)[i];
+ Ref<OneDReader> reader = readers[i];
Ref<Result> result;
try {
result = reader->decodeRow(rowNumber, row);//decodeRow(rowNumber, row, startGuardPattern);
@@ -60,7 +59,7 @@ namespace zxing {
// UPC-A. So we special case it here, and convert an EAN-13 result to a UPC-A
// result if appropriate.
if (result->getBarcodeFormat() == BarcodeFormat_EAN_13) {
- std::string& text = (result->getText())->getText();
+ const std::string& text = (result->getText())->getText();
if (text[0] == '0') {
Ref<String> resultString(new String(text.substr(1)));
Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(), BarcodeFormat_UPC_A));
@@ -71,13 +70,5 @@ namespace zxing {
}
throw ReaderException("No EAN code detected");
}
-
- MultiFormatUPCEANReader::~MultiFormatUPCEANReader(){
- int size = readers->size();
- for (int i = 0; i < size; i++) {
- delete (*readers)[i];
- }
- delete readers;
- }
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.h b/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.h
index 706f9c4..2c5b196 100644
--- a/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.h
+++ b/cpp/core/src/zxing/oned/MultiFormatUPCEANReader.h
@@ -29,13 +29,11 @@ namespace zxing {
class MultiFormatUPCEANReader : public OneDReader {
private:
- std::vector<OneDReader*>* readers;
+ std::vector<Ref<OneDReader> > readers;
public:
MultiFormatUPCEANReader();
Ref<Result> decodeRow(int rowNumber, Ref<BitArray> row);
-
- ~MultiFormatUPCEANReader();
- };
+ };
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/OneDReader.cpp b/cpp/core/src/zxing/oned/OneDReader.cpp
index 21526f5..0b557d6 100644
--- a/cpp/core/src/zxing/oned/OneDReader.cpp
+++ b/cpp/core/src/zxing/oned/OneDReader.cpp
@@ -191,4 +191,4 @@ namespace zxing {
OneDReader::~OneDReader() {
}
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/OneDReader.h b/cpp/core/src/zxing/oned/OneDReader.h
index a029f9c..92a7e77 100644
--- a/cpp/core/src/zxing/oned/OneDReader.h
+++ b/cpp/core/src/zxing/oned/OneDReader.h
@@ -43,4 +43,4 @@ namespace zxing {
virtual ~OneDReader();
};
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/OneDResultPoint.cpp b/cpp/core/src/zxing/oned/OneDResultPoint.cpp
index 272319d..0ac8dc3 100644
--- a/cpp/core/src/zxing/oned/OneDResultPoint.cpp
+++ b/cpp/core/src/zxing/oned/OneDResultPoint.cpp
@@ -23,17 +23,15 @@
namespace zxing {
namespace oned {
- using namespace std;
-
OneDResultPoint::OneDResultPoint(float posX, float posY) : posX_(posX), posY_(posY){
}
- float OneDResultPoint::getX() {
+ float OneDResultPoint::getX() const {
return posX_;
}
- float OneDResultPoint::getY() {
+ float OneDResultPoint::getY() const {
return posY_;
}
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/OneDResultPoint.h b/cpp/core/src/zxing/oned/OneDResultPoint.h
index 1b07b77..18f1614 100644
--- a/cpp/core/src/zxing/oned/OneDResultPoint.h
+++ b/cpp/core/src/zxing/oned/OneDResultPoint.h
@@ -30,8 +30,8 @@ namespace zxing {
public:
OneDResultPoint(float posX, float posY);
- float getX();
- float getY();
+ float getX() const;
+ float getY() const;
};
}
}
diff --git a/cpp/core/src/zxing/oned/UPCAReader.cpp b/cpp/core/src/zxing/oned/UPCAReader.cpp
index e46c2b7..cb2fcb5 100644
--- a/cpp/core/src/zxing/oned/UPCAReader.cpp
+++ b/cpp/core/src/zxing/oned/UPCAReader.cpp
@@ -19,31 +19,29 @@
*/
#include "UPCAReader.h"
-#include <zxing/oned/EAN13Reader.h>
#include <zxing/ReaderException.h>
namespace zxing {
namespace oned {
- UPCAReader::UPCAReader(){
- ean13Reader = new EAN13Reader();
+ UPCAReader::UPCAReader() : ean13Reader() {
}
Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row){
- return maybeReturnResult(ean13Reader->decodeRow(rowNumber, row));
+ return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row));
}
Ref<Result> UPCAReader::decodeRow(int rowNumber, Ref<BitArray> row, int startGuardRange[]){
- return maybeReturnResult(ean13Reader->decodeRow(rowNumber, row, startGuardRange));
+ return maybeReturnResult(ean13Reader.decodeRow(rowNumber, row, startGuardRange));
}
Ref<Result> UPCAReader::decode(Ref<BinaryBitmap> image){
- return maybeReturnResult(ean13Reader->decode(image));
+ return maybeReturnResult(ean13Reader.decode(image));
}
int UPCAReader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
- return ean13Reader->decodeMiddle(row, startRange, startRangeLen, resultString);
+ return ean13Reader.decodeMiddle(row, startRange, startRangeLen, resultString);
}
Ref<Result> UPCAReader::maybeReturnResult(Ref<Result> result){
- std::string& text = (result->getText())->getText();
+ const std::string& text = (result->getText())->getText();
if (text[0] == '0') {
Ref<String> resultString(new String(text.substr(1)));
Ref<Result> res(new Result(resultString, result->getRawBytes(), result->getResultPoints(), BarcodeFormat_UPC_A));
@@ -57,8 +55,5 @@ namespace zxing {
BarcodeFormat UPCAReader::getBarcodeFormat(){
return BarcodeFormat_UPC_A;
}
- UPCAReader::~UPCAReader(){
- delete ean13Reader;
- }
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/UPCAReader.h b/cpp/core/src/zxing/oned/UPCAReader.h
index 217184b..8542207 100644
--- a/cpp/core/src/zxing/oned/UPCAReader.h
+++ b/cpp/core/src/zxing/oned/UPCAReader.h
@@ -18,15 +18,14 @@
* limitations under the License.
*/
-#include <zxing/oned/UPCEANReader.h>
-#include <zxing/Result.h>
+#include <zxing/oned/EAN13Reader.h>
namespace zxing {
namespace oned {
class UPCAReader : public UPCEANReader {
private:
- UPCEANReader* ean13Reader;
+ EAN13Reader ean13Reader;
static Ref<Result> maybeReturnResult(Ref<Result> result); //throws ReaderException
public:
@@ -39,7 +38,6 @@ namespace zxing {
Ref<Result> decode(Ref<BinaryBitmap> image);
BarcodeFormat getBarcodeFormat();
- ~UPCAReader();
};
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/UPCEANReader.h b/cpp/core/src/zxing/oned/UPCEANReader.h
index a6c155d..d673dc9 100644
--- a/cpp/core/src/zxing/oned/UPCEANReader.h
+++ b/cpp/core/src/zxing/oned/UPCEANReader.h
@@ -62,4 +62,5 @@ namespace zxing {
virtual ~UPCEANReader();
};
}
-}
\ No newline at end of file
+}
+
diff --git a/cpp/core/src/zxing/oned/UPCEReader.cpp b/cpp/core/src/zxing/oned/UPCEReader.cpp
index 8c02ac2..1fce8dd 100644
--- a/cpp/core/src/zxing/oned/UPCEReader.cpp
+++ b/cpp/core/src/zxing/oned/UPCEReader.cpp
@@ -40,21 +40,11 @@ namespace zxing {
{0x07, 0x0B, 0x0D, 0x0E, 0x13, 0x19, 0x1C, 0x15, 0x16, 0x1A}
};
- UPCEReader::UPCEReader(){
- decodeMiddleCounters = new int[4];
- for (int i=0; i<4; i++) {
- decodeMiddleCounters[i] = 0;
- }
- }
+ UPCEReader::UPCEReader(){}
int UPCEReader::decodeMiddle(Ref<BitArray> row, int startRange[], int startRangeLen, std::string& resultString){
- int countersLen = 4;
- int* counters = decodeMiddleCounters;
- counters[0] = 0;
- counters[1] = 0;
- counters[2] = 0;
- counters[3] = 0;
-
+ const int countersLen = 4;
+ int counters[countersLen] = { 0, 0, 0, 0 };
int end = row->getSize();
int rowOffset = startRange[1];
@@ -143,8 +133,5 @@ namespace zxing {
BarcodeFormat UPCEReader::getBarcodeFormat(){
return BarcodeFormat_UPC_E;
}
- UPCEReader::~UPCEReader(){
- delete [] decodeMiddleCounters;
- }
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/oned/UPCEReader.h b/cpp/core/src/zxing/oned/UPCEReader.h
index a26e2ec..5de2ef5 100644
--- a/cpp/core/src/zxing/oned/UPCEReader.h
+++ b/cpp/core/src/zxing/oned/UPCEReader.h
@@ -26,7 +26,6 @@ namespace zxing {
class UPCEReader : public UPCEANReader {
private:
- int* decodeMiddleCounters;
static void determineFirstDigit(std::string& resultString, int lgPatternFound); //throws ReaderException
static void determineNumSysAndCheckDigit(std::string& resultString, int lgPatternFound); //throws ReaderException
protected:
@@ -39,7 +38,6 @@ namespace zxing {
static std::string& convertUPCEtoUPCA(std::string upce);
BarcodeFormat getBarcodeFormat();
- ~UPCEReader();
};
}
-}
\ No newline at end of file
+}
diff --git a/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.cpp b/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.cpp
index 9c610b5..e8faf90 100644
--- a/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.cpp
+++ b/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.cpp
@@ -23,8 +23,8 @@
namespace zxing {
namespace qrcode {
-ErrorCorrectionLevel::ErrorCorrectionLevel(int ordinal) :
- ordinal_(ordinal) {
+ErrorCorrectionLevel::ErrorCorrectionLevel(int inOrdinal) :
+ ordinal_(inOrdinal) {
}
int ErrorCorrectionLevel::ordinal() {
diff --git a/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.h b/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.h
index 426d204..9d6a6c5 100644
--- a/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.h
+++ b/cpp/core/src/zxing/qrcode/ErrorCorrectionLevel.h
@@ -29,7 +29,7 @@ namespace qrcode {
class ErrorCorrectionLevel {
private:
int ordinal_;
- ErrorCorrectionLevel(int ordinal);
+ ErrorCorrectionLevel(int inOrdinal);
static ErrorCorrectionLevel *FOR_BITS[];
static int N_LEVELS;
public:
diff --git a/cpp/core/src/zxing/qrcode/Version.cpp b/cpp/core/src/zxing/qrcode/Version.cpp
index 367cac1..62c2acf 100644
--- a/cpp/core/src/zxing/qrcode/Version.cpp
+++ b/cpp/core/src/zxing/qrcode/Version.cpp
@@ -41,13 +41,11 @@ int ECB::getDataCodewords() {
}
ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks) :
- ecCodewords_(ecCodewords) {
- ecBlocks_.push_back(ecBlocks);
+ ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks) {
}
ECBlocks::ECBlocks(int ecCodewords, ECB *ecBlocks1, ECB *ecBlocks2) :
- ecCodewords_(ecCodewords) {
- ecBlocks_.push_back(ecBlocks1);
+ ecCodewords_(ecCodewords), ecBlocks_(1, ecBlocks1) {
ecBlocks_.push_back(ecBlocks2);
}
@@ -102,7 +100,7 @@ Version *Version::getProvisionalVersionForDimension(int dimension) {
}
Version *Version::getVersionForNumber(int versionNumber) {
- if (versionNumber < 1 || versionNumber > 40) {
+ if (versionNumber < 1 || versionNumber > N_VERSIONS) {
throw ReaderException("versionNumber must be between 1 and 40");
}
@@ -111,7 +109,7 @@ Version *Version::getVersionForNumber(int versionNumber) {
Version::Version(int versionNumber, vector<int> *alignmentPatternCenters, ECBlocks *ecBlocks1, ECBlocks *ecBlocks2,
ECBlocks *ecBlocks3, ECBlocks *ecBlocks4) :
- versionNumber_(versionNumber), alignmentPatternCenters_(*alignmentPatternCenters), ecBlocks_(4) {
+ versionNumber_(versionNumber), alignmentPatternCenters_(*alignmentPatternCenters), ecBlocks_(4), totalCodewords_(0) {
ecBlocks_[0] = ecBlocks1;
ecBlocks_[1] = ecBlocks2;
ecBlocks_[2] = ecBlocks3;
diff --git a/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp b/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp
index e4ef5e2..04cd06b 100644
--- a/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp
+++ b/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.cpp
@@ -158,8 +158,8 @@ ArrayRef<unsigned char> BitMatrixParser::readCodewords() {
x--;
}
// Read alternatingly from bottom to top then top to bottom
- for (int count = 0; count < dimension; count++) {
- int y = readingUp ? dimension - 1 - count : count;
+ for (int counter = 0; counter < dimension; counter++) {
+ int y = readingUp ? dimension - 1 - counter : counter;
for (int col = 0; col < 2; col++) {
// Ignore bits covered by the function pattern
if (!functionPattern->get(x - col, y)) {
diff --git a/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.h b/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.h
index 824556b..0939492 100644
--- a/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.h
+++ b/cpp/core/src/zxing/qrcode/decoder/BitMatrixParser.h
@@ -44,6 +44,11 @@ public:
Ref<FormatInformation> readFormatInformation();
Version *readVersion();
ArrayRef<unsigned char> readCodewords();
+
+private:
+ BitMatrixParser(const BitMatrixParser&);
+ BitMatrixParser& operator =(const BitMatrixParser&);
+
};
}
diff --git a/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.cpp b/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.cpp
index 0f6ee59..25baeb3 100644
--- a/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.cpp
+++ b/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.cpp
@@ -29,15 +29,15 @@ AlignmentPattern::AlignmentPattern(float posX, float posY, float estimatedModule
posX_(posX), posY_(posY), estimatedModuleSize_(estimatedModuleSize) {
}
-float AlignmentPattern::getX() {
+float AlignmentPattern::getX() const {
return posX_;
}
-float AlignmentPattern::getY() {
+float AlignmentPattern::getY() const {
return posY_;
}
-bool AlignmentPattern::aboutEquals(float moduleSize, float i, float j) {
+bool AlignmentPattern::aboutEquals(float moduleSize, float i, float j) const {
return abs(i - posY_) <= moduleSize && abs(j - posX_) <= moduleSize && (abs(moduleSize - estimatedModuleSize_)
<= 1.0f || abs(moduleSize - estimatedModuleSize_) / estimatedModuleSize_ <= 0.1f);
}
diff --git a/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.h b/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.h
index 56a683f..b822afa 100644
--- a/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.h
+++ b/cpp/core/src/zxing/qrcode/detector/AlignmentPattern.h
@@ -35,9 +35,9 @@ namespace zxing {
public:
AlignmentPattern(float posX, float posY, float estimatedModuleSize);
- float getX();
- float getY();
- bool aboutEquals(float moduleSize, float i, float j);
+ float getX() const;
+ float getY() const;
+ bool aboutEquals(float moduleSize, float i, float j) const;
};
}
diff --git a/cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h b/cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h
index 3b60d60..6221b6c 100644
--- a/cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h
+++ b/cpp/core/src/zxing/qrcode/detector/AlignmentPatternFinder.h
@@ -55,6 +55,11 @@ public:
float moduleSize);
~AlignmentPatternFinder();
Ref<AlignmentPattern> find();
+
+private:
+ AlignmentPatternFinder(const AlignmentPatternFinder&);
+ AlignmentPatternFinder& operator =(const AlignmentPatternFinder&);
+
};
}
}
diff --git a/cpp/core/src/zxing/qrcode/detector/FinderPattern.cpp b/cpp/core/src/zxing/qrcode/detector/FinderPattern.cpp
index 531d4e2..1c9a534 100644
--- a/cpp/core/src/zxing/qrcode/detector/FinderPattern.cpp
+++ b/cpp/core/src/zxing/qrcode/detector/FinderPattern.cpp
@@ -29,19 +29,19 @@ namespace zxing {
posX_(posX), posY_(posY), estimatedModuleSize_(estimatedModuleSize), counter_(1) {
}
- float FinderPattern::getX() {
+ float FinderPattern::getX() const {
return posX_;
}
- float FinderPattern::getY() {
+ float FinderPattern::getY() const {
return posY_;
}
- int FinderPattern::getCount() {
+ int FinderPattern::getCount() const {
return counter_;
}
- float FinderPattern::getEstimatedModuleSize() {
+ float FinderPattern::getEstimatedModuleSize() const {
return estimatedModuleSize_;
}
@@ -49,7 +49,7 @@ namespace zxing {
counter_++;
}
- bool FinderPattern::aboutEquals(float moduleSize, float i, float j) {
+ bool FinderPattern::aboutEquals(float moduleSize, float i, float j) const {
return abs(i - posY_) <= moduleSize && abs(j - posX_) <= moduleSize && (abs(moduleSize - estimatedModuleSize_)
<= 1.0f || abs(moduleSize - estimatedModuleSize_) / estimatedModuleSize_ <= 0.1f);
}
diff --git a/cpp/core/src/zxing/qrcode/detector/FinderPattern.h b/cpp/core/src/zxing/qrcode/detector/FinderPattern.h
index 0b6615c..8b2ff59 100644
--- a/cpp/core/src/zxing/qrcode/detector/FinderPattern.h
+++ b/cpp/core/src/zxing/qrcode/detector/FinderPattern.h
@@ -36,12 +36,12 @@ namespace zxing {
public:
FinderPattern(float posX, float posY, float estimatedModuleSize);
- float getX();
- float getY();
- int getCount();
- float getEstimatedModuleSize();
+ float getX() const;
+ float getY() const;
+ int getCount() const;
+ float getEstimatedModuleSize() const;
void incrementCount();
- bool aboutEquals(float moduleSize, float i, float j);
+ bool aboutEquals(float moduleSize, float i, float j) const;
};
}
}
diff --git a/cpp/core/tests/src/TestRunner.cpp b/cpp/core/tests/src/TestRunner.cpp
index 639eb28..d82dde7 100644
--- a/cpp/core/tests/src/TestRunner.cpp
+++ b/cpp/core/tests/src/TestRunner.cpp
@@ -27,4 +27,4 @@ int main(int argc, char **argv) {
runner.addTest(registry.makeTest());
bool wasSuccessful = runner.run("", false);
return wasSuccessful ? 0 : 1;
-}
\ No newline at end of file
+}
diff --git a/iphone/Classes/AddContactAction.h b/iphone/Classes/AddContactAction.h
index feb1ad9..ac6af6f 100644
--- a/iphone/Classes/AddContactAction.h
+++ b/iphone/Classes/AddContactAction.h
@@ -41,11 +41,11 @@
@property (nonatomic, copy) NSString *urlString;
@property (nonatomic, copy) NSString *address;
-+ actionWithName:(NSString *)n
- phoneNumbers:(NSArray *)nums
- email:(NSString *)em
- url:(NSString *)us
- address:(NSString *)ad
- note:(NSString *)nt;
++ (id)actionWithName:(NSString *)n
+ phoneNumbers:(NSArray *)nums
+ email:(NSString *)em
+ url:(NSString *)us
+ address:(NSString *)ad
+ note:(NSString *)nt;
@end
diff --git a/iphone/Classes/AddContactAction.m b/iphone/Classes/AddContactAction.m
index 7791593..3930913 100644
--- a/iphone/Classes/AddContactAction.m
+++ b/iphone/Classes/AddContactAction.m
@@ -32,12 +32,12 @@
@synthesize urlString;
@synthesize address;
-+ actionWithName:(NSString *)n
- phoneNumbers:(NSArray *)nums
- email:(NSString *)em
- url:(NSString *)us
- address:(NSString *)ad
- note:(NSString *)nt {
++ (id)actionWithName:(NSString *)n
+ phoneNumbers:(NSArray *)nums
+ email:(NSString *)em
+ url:(NSString *)us
+ address:(NSString *)ad
+ note:(NSString *)nt {
AddContactAction *aca = [[[self alloc] init] autorelease];
aca.name = n;
aca.phoneNumbers = nums;
diff --git a/iphone/Classes/ArchiveController.h b/iphone/Classes/ArchiveController.h
index ed88d6b..b341207 100644
--- a/iphone/Classes/ArchiveController.h
+++ b/iphone/Classes/ArchiveController.h
@@ -36,6 +36,6 @@
@property (nonatomic, retain) NSDateFormatter *dateFormatter;
- (NSInteger)scanIndexForRow:(NSInteger)row;
-- initWithDecoderViewController:(DecoderViewController *)dc;
+- (id)initWithDecoderViewController:(DecoderViewController *)dc;
@end
diff --git a/iphone/Classes/ArchiveController.m b/iphone/Classes/ArchiveController.m
index d2a708d..1d65764 100644
--- a/iphone/Classes/ArchiveController.m
+++ b/iphone/Classes/ArchiveController.m
@@ -35,8 +35,8 @@
@synthesize decoderViewController;
@synthesize dateFormatter;
-- initWithDecoderViewController:(DecoderViewController *)dc {
- if (self = [super initWithStyle:UITableViewStylePlain]) {
+- (id)initWithDecoderViewController:(DecoderViewController *)dc {
+ if ((self = [super initWithStyle:UITableViewStylePlain])) {
decoderViewController = [dc retain];
scans = [[NSMutableArray alloc] init];
results = [[NSMutableArray alloc] init];
@@ -66,17 +66,17 @@
}
// Configure the cell
- int index = [self scanIndexForRow:indexPath.row];
- Scan *scan = [scans objectAtIndex:index];
+ int idx = [self scanIndexForRow:indexPath.row];
+ Scan *scan = [scans objectAtIndex:idx];
[cell setScan:scan];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//[decoderViewController showScan:[scans objectAtIndex:[self scanIndexForRow:indexPath.row]]];
- int index = [self scanIndexForRow:indexPath.row];
- Scan *scan = [scans objectAtIndex:index];
- ParsedResult *result = [results objectAtIndex:index];
+ int idx = [self scanIndexForRow:indexPath.row];
+ Scan *scan = [scans objectAtIndex:idx];
+ ParsedResult *result = [results objectAtIndex:idx];
ScanViewController *scanViewController = [[ScanViewController alloc] initWithResult:result forScan:scan];
[self.navigationController pushViewController:scanViewController animated:YES];
[scanViewController release];
@@ -84,14 +84,14 @@
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
if (editingStyle == UITableViewCellEditingStyleDelete) {
- int index = [self scanIndexForRow:indexPath.row];
- Scan *scan = [self.scans objectAtIndex:index];
+ int idx = [self scanIndexForRow:indexPath.row];
+ Scan *scan = [self.scans objectAtIndex:idx];
// delete the scan from the database ...
[[Database sharedDatabase] deleteScan:scan];
// ... delete the scan from our in-memory cache of the database ...
- [scans removeObjectAtIndex:index];
+ [scans removeObjectAtIndex:idx];
// ... delete the corresponding result from our in-memory cache ...
- [results removeObjectAtIndex:index];
+ [results removeObjectAtIndex:idx];
// ... and remove the row from the table view.
[tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
// [tableView reloadData];
diff --git a/iphone/Classes/BookmarkDoCoMoResultParser.m b/iphone/Classes/BookmarkDoCoMoResultParser.m
index dc5ca9d..7c5f47d 100644
--- a/iphone/Classes/BookmarkDoCoMoResultParser.m
+++ b/iphone/Classes/BookmarkDoCoMoResultParser.m
@@ -24,6 +24,10 @@
@implementation BookmarkDoCoMoResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange foundRange = [s rangeOfString:@"MEBKM:"];
if (foundRange.location == NSNotFound) {
diff --git a/iphone/Classes/CallAction.h b/iphone/Classes/CallAction.h
index a12ad81..becd868 100644
--- a/iphone/Classes/CallAction.h
+++ b/iphone/Classes/CallAction.h
@@ -30,7 +30,7 @@
+ (NSURL *)urlForNumber:(NSString *)number;
-- initWithNumber:(NSString *)number;
-+ actionWithNumber:(NSString *)number;
+- (id)initWithNumber:(NSString *)number;
++ (id)actionWithNumber:(NSString *)number;
@end
diff --git a/iphone/Classes/CallAction.m b/iphone/Classes/CallAction.m
index 6dd2aee..e6acc78 100644
--- a/iphone/Classes/CallAction.m
+++ b/iphone/Classes/CallAction.m
@@ -31,14 +31,14 @@
return [NSURL URLWithString:urlString];
}
-- initWithNumber:(NSString *)n {
+- (id)initWithNumber:(NSString *)n {
if ((self = [super initWithURL:[[self class] urlForNumber:n]]) != nil) {
self.number = n;
}
return self;
}
-+ actionWithNumber:(NSString *)number {
++ (id)actionWithNumber:(NSString *)number {
return [[[self alloc] initWithNumber:number] autorelease];
}
diff --git a/iphone/Classes/Database.h b/iphone/Classes/Database.h
index 2f1adb6..38ec771 100644
--- a/iphone/Classes/Database.h
+++ b/iphone/Classes/Database.h
@@ -32,7 +32,7 @@
@property sqlite3 *connection;
@property int nextScanIdent;
-+ sharedDatabase;
++ (id)sharedDatabase;
- (void)addScanWithText:(NSString *)text;
- (NSArray *)scans;
diff --git a/iphone/Classes/Database.m b/iphone/Classes/Database.m
index 79026ae..cd4897c 100644
--- a/iphone/Classes/Database.m
+++ b/iphone/Classes/Database.m
@@ -34,7 +34,7 @@ static sqlite3_stmt *deleteStatement;
static Database *sharedDatabase = nil;
-+ sharedDatabase {
++ (id)sharedDatabase {
if (!sharedDatabase) {
sharedDatabase = [[self alloc] init];
@@ -58,17 +58,17 @@ static Database *sharedDatabase = nil;
sqlite3_open([writableDBPath UTF8String], &connection);
sharedDatabase.connection = connection;
- static char *maxIdSql = "SELECT MAX(id) FROM SCAN";
+ static const char *maxIdSql = "SELECT MAX(id) FROM SCAN";
sqlite3_prepare_v2(connection, maxIdSql, -1, &maxIdStatement, NULL);
- static char *selectAllSql = "SELECT id, text, stamp FROM SCAN ORDER BY id";
+ static const char *selectAllSql = "SELECT id, text, stamp FROM SCAN ORDER BY id";
sqlite3_prepare_v2(connection, selectAllSql, -1, &selectAllStatement, NULL);
- static char *insertSql =
+ static const char *insertSql =
"INSERT INTO SCAN (id, text, stamp) VALUES (?, ?, ?)";
sqlite3_prepare_v2(connection, insertSql, -1, &insertStatement, NULL);
- static char *deleteSql = "DELETE FROM SCAN WHERE id = ?";
+ static const char *deleteSql = "DELETE FROM SCAN WHERE id = ?";
sqlite3_prepare_v2(connection, deleteSql, -1, &deleteStatement, NULL);
if (SQLITE_ROW == sqlite3_step(maxIdStatement)) {
diff --git a/iphone/Classes/Decoder.m b/iphone/Classes/Decoder.m
deleted file mode 100644
index 90143a2..0000000
--- a/iphone/Classes/Decoder.m
+++ /dev/null
@@ -1,265 +0,0 @@
-//
-// Decoder.m
-// ZXing
-//
-// Created by Christian Brunschen on 31/03/2008.
-//
-/*
- * Copyright 2008 ZXing authors
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#import "Decoder.h"
-#import "TwoDDecoderResult.h"
-
-#include <zxing/qrcode/QRCodeReader.h>
-#include <zxing/MultiFormatReader.h>
-
-#include <zxing/BinaryBitmap.h>
-#include <zxing/ReaderException.h>
-#include <zxing/common/IllegalArgumentException.h>
-#include <zxing/common/GlobalHistogramBinarizer.h>
-#include "GrayBytesMonochromeBitmapSource.h"
-
-using namespace zxing;
-
- at implementation Decoder
-
- at synthesize image;
- at synthesize cropRect;
- at synthesize subsetImage;
- at synthesize subsetData;
- at synthesize subsetWidth;
- at synthesize subsetHeight;
- at synthesize subsetBytesPerRow;
- at synthesize delegate;
-
-- (void)willDecodeImage {
- [self.delegate decoder:self willDecodeImage:self.image usingSubset:self.subsetImage];
-}
-
-- (void)progressDecodingImage:(NSString *)progress {
- [self.delegate decoder:self
- decodingImage:self.image
- usingSubset:self.subsetImage
- progress:progress];
-}
-
-- (void)didDecodeImage:(TwoDDecoderResult *)result {
- [self.delegate decoder:self didDecodeImage:self.image usingSubset:self.subsetImage withResult:result];
-}
-
-- (void)failedToDecodeImage:(NSString *)reason {
- [self.delegate decoder:self failedToDecodeImage:self.image usingSubset:self.subsetImage reason:reason];
-}
-
-#define SUBSET_SIZE 320.0
-- (void) prepareSubset {
- CGSize size = [image size];
-#ifdef DEBUG
- NSLog(@"decoding: image is (%.1f x %.1f), cropRect is (%.1f,%.1f)x(%.1f,%.1f)", size.width, size.height,
- cropRect.origin.x, cropRect.origin.y, cropRect.size.width, cropRect.size.height);
-#endif
- float scale = fminf(1.0f, fmaxf(SUBSET_SIZE / cropRect.size.width, SUBSET_SIZE / cropRect.size.height));
- CGPoint offset = CGPointMake(-cropRect.origin.x, -cropRect.origin.y);
-#ifdef DEBUG
- NSLog(@" offset = (%.1f, %.1f), scale = %.3f", offset.x, offset.y, scale);
-#endif
-
- subsetWidth = cropRect.size.width * scale;
- subsetHeight = cropRect.size.height * scale;
-
- subsetBytesPerRow = ((subsetWidth + 0xf) >> 4) << 4;
-#ifdef DEBUG
- NSLog(@"decoding: image to decode is (%d x %d) (%d bytes/row)", subsetWidth, subsetHeight, subsetBytesPerRow);
-#endif
-
- subsetData = (unsigned char *)malloc(subsetBytesPerRow * subsetHeight);
-#ifdef DEBUG
- NSLog(@"allocated %d bytes of memory", subsetBytesPerRow * subsetHeight);
-#endif
-
- CGColorSpaceRef grayColorSpace = CGColorSpaceCreateDeviceGray();
-
- CGContextRef ctx =
- CGBitmapContextCreate(subsetData, subsetWidth, subsetHeight,
- 8, subsetBytesPerRow, grayColorSpace,
- kCGImageAlphaNone);
- CGColorSpaceRelease(grayColorSpace);
- CGContextSetInterpolationQuality(ctx, kCGInterpolationNone);
- CGContextSetAllowsAntialiasing(ctx, false);
- // adjust the coordinate system
- CGContextTranslateCTM(ctx, 0.0, subsetHeight);
- CGContextScaleCTM(ctx, 1.0, -1.0);
-
-#ifdef DEBUG
- NSLog(@"created %dx%d bitmap context", subsetWidth, subsetHeight);
-#endif
-
- UIGraphicsPushContext(ctx);
- CGRect rect = CGRectMake(offset.x * scale, offset.y * scale, scale * size.width, scale * size.height);
-#ifdef DEBUG
- NSLog(@"rect for image = (%.1f,%.1f)x(%.1f,%.1f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
-#endif
- [image drawInRect:rect];
- UIGraphicsPopContext();
-
-#ifdef DEBUG
- NSLog(@"drew image into %d(%d)x%d bitmap context", subsetWidth, subsetBytesPerRow, subsetHeight);
-#endif
- CGContextFlush(ctx);
-#ifdef DEBUG
- NSLog(@"flushed context");
-#endif
-
- CGImageRef subsetImageRef = CGBitmapContextCreateImage(ctx);
-#ifdef DEBUG
- NSLog(@"created CGImage from context");
-#endif
-
- self.subsetImage = [UIImage imageWithCGImage:subsetImageRef];
- CGImageRelease(subsetImageRef);
-
- CGContextRelease(ctx);
-#ifdef DEBUG
- NSLog(@"released context");
-#endif
-}
-
-- (void)decode:(id)arg {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- {
-
- MultiFormatReader reader;
-#ifdef DEBUG
- NSLog(@"created MultiFormatReader");
-#endif
-
- Ref<LuminanceSource> source (new GrayBytesMonochromeBitmapSource(subsetData, subsetWidth, subsetHeight, subsetBytesPerRow));
-
- Ref<Binarizer> binarizer (new GlobalHistogramBinarizer(source));
- Ref<BinaryBitmap> grayImage (new BinaryBitmap(binarizer));
-#ifdef DEBUG
- NSLog(@"created GrayBytesMonochromeBitmapSource", subsetWidth, subsetHeight);
- NSLog(@"grayImage count = %d", grayImage->count());
-#endif
-
- TwoDDecoderResult *decoderResult = nil;
-
-#ifdef TRY_ROTATIONS
- for (int i = 0; !decoderResult && i < 4; i++) {
-#endif
-
- try {
-#ifdef DEBUG
- NSLog(@"decoding gray image");
-#endif
- Ref<Result> result(reader.decode(grayImage));
-#ifdef DEBUG
- NSLog(@"gray image decoded");
-#endif
-
- Ref<String> resultText(result->getText());
- const char *cString = resultText->getText().c_str();
- std::vector<Ref<ResultPoint> > resultPoints = result->getResultPoints();
- NSMutableArray *points =
- [NSMutableArray arrayWithCapacity:resultPoints.size()];
-
- for (size_t i = 0; i < resultPoints.size(); i++) {
- Ref<ResultPoint> rp(resultPoints[i]);
- CGPoint p = CGPointMake(rp->getX(), rp->getY());
- [points addObject:[NSValue valueWithCGPoint:p]];
- }
-
- NSString *resultString = [NSString stringWithCString:cString
- encoding:NSUTF8StringEncoding];
-
- decoderResult = [TwoDDecoderResult resultWithText:resultString
- points:points];
- } catch (ReaderException rex) {
- NSLog(@"failed to decode, caught ReaderException '%s'",
- rex.what());
- } catch (IllegalArgumentException iex) {
- NSLog(@"failed to decode, caught IllegalArgumentException '%s'",
- iex.what());
- } catch (...) {
- NSLog(@"Caught unknown exception!");
- }
-
-#ifdef TRY_ROTATIONS
- if (!decoderResult) {
-#ifdef DEBUG
- NSLog(@"rotating gray image");
-#endif
- grayImage = grayImage->rotateCounterClockwise();
-#ifdef DEBUG
- NSLog(@"gray image rotated");
-#endif
- }
- }
-#endif
-
- if (decoderResult) {
- [self performSelectorOnMainThread:@selector(didDecodeImage:)
- withObject:decoderResult
- waitUntilDone:NO];
- } else {
- [self performSelectorOnMainThread:@selector(failedToDecodeImage:)
- withObject:NSLocalizedString(@"Decoder BarcodeDetectionFailure", @"No barcode detected.")
- waitUntilDone:NO];
- }
-
- free(subsetData);
- self.subsetData = NULL;
- }
- [pool release];
-#ifdef DEBUG
- NSLog(@"finished decoding.");
-#endif
-
- // if this is not the main thread, then we end it
- if (![NSThread isMainThread]) {
- [NSThread exit];
- }
-}
-
-- (void) decodeImage:(UIImage *)i {
- [self decodeImage:i cropRect:CGRectMake(0.0f, 0.0f, image.size.width, image.size.height)];
-}
-
-- (void) decodeImage:(UIImage *)i cropRect:(CGRect)cr {
- self.image = i;
- self.cropRect = cr;
-
- [self prepareSubset];
- [self.delegate decoder:self willDecodeImage:i usingSubset:self.subsetImage];
-
-
- [self performSelectorOnMainThread:@selector(progressDecodingImage:)
- withObject:NSLocalizedString(@"Decoder MessageWhileDecoding", @"Decoding ...")
- waitUntilDone:NO];
-
- [NSThread detachNewThreadSelector:@selector(decode:)
- toTarget:self
- withObject:nil];
-}
-
-- (void) dealloc {
- [image release];
- [subsetImage release];
- if (subsetData) free(subsetData);
- [super dealloc];
-}
-
- at end
diff --git a/iphone/Classes/Decoder.mm b/iphone/Classes/Decoder.mm
new file mode 100644
index 0000000..ea7748b
--- /dev/null
+++ b/iphone/Classes/Decoder.mm
@@ -0,0 +1,264 @@
+//
+// Decoder.m
+// ZXing
+//
+// Created by Christian Brunschen on 31/03/2008.
+//
+/*
+ * Copyright 2008 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "Decoder.h"
+#import "TwoDDecoderResult.h"
+#import "FormatReader.h"
+
+#include <zxing/BinaryBitmap.h>
+#include <zxing/ReaderException.h>
+#include <zxing/common/IllegalArgumentException.h>
+#include <zxing/common/GlobalHistogramBinarizer.h>
+#include "GrayBytesMonochromeBitmapSource.h"
+
+using namespace zxing;
+
+ at implementation Decoder
+
+ at synthesize image;
+ at synthesize cropRect;
+ at synthesize subsetImage;
+ at synthesize subsetData;
+ at synthesize subsetWidth;
+ at synthesize subsetHeight;
+ at synthesize subsetBytesPerRow;
+ at synthesize delegate;
+
+- (void)willDecodeImage {
+ if ([self.delegate respondsToSelector:@selector(decoder:willDecodeImage:usingSubset:)]) {
+ [self.delegate decoder:self willDecodeImage:self.image usingSubset:self.subsetImage];
+ }
+}
+
+- (void)progressDecodingImage:(NSString *)progress {
+ if ([self.delegate respondsToSelector:@selector(decoder:decodingImage:usingSubset:progress:)]) {
+ [self.delegate decoder:self decodingImage:self.image usingSubset:self.subsetImage progress:progress];
+ }
+}
+
+- (void)didDecodeImage:(TwoDDecoderResult *)result {
+ if ([self.delegate respondsToSelector:@selector(decoder:didDecodeImage:usingSubset:withResult:)]) {
+ [self.delegate decoder:self didDecodeImage:self.image usingSubset:self.subsetImage withResult:result];
+ }
+}
+
+- (void)failedToDecodeImage:(NSString *)reason {
+ if ([self.delegate respondsToSelector:@selector(decoder:failedToDecodeImage:usingSubset:reason:)]) {
+ [self.delegate decoder:self failedToDecodeImage:self.image usingSubset:self.subsetImage reason:reason];
+ }
+}
+
+#define SUBSET_SIZE 320.0
+- (void) prepareSubset {
+ CGSize size = [image size];
+#ifdef DEBUG
+ NSLog(@"decoding: image is (%.1f x %.1f), cropRect is (%.1f,%.1f)x(%.1f,%.1f)", size.width, size.height,
+ cropRect.origin.x, cropRect.origin.y, cropRect.size.width, cropRect.size.height);
+#endif
+ float scale = fminf(1.0f, fmaxf(SUBSET_SIZE / cropRect.size.width, SUBSET_SIZE / cropRect.size.height));
+ CGPoint offset = CGPointMake(-cropRect.origin.x, -cropRect.origin.y);
+#ifdef DEBUG
+ NSLog(@" offset = (%.1f, %.1f), scale = %.3f", offset.x, offset.y, scale);
+#endif
+
+ subsetWidth = cropRect.size.width * scale;
+ subsetHeight = cropRect.size.height * scale;
+
+ subsetBytesPerRow = ((subsetWidth + 0xf) >> 4) << 4;
+#ifdef DEBUG
+ NSLog(@"decoding: image to decode is (%d x %d) (%d bytes/row)", subsetWidth, subsetHeight, subsetBytesPerRow);
+#endif
+
+ subsetData = (unsigned char *)malloc(subsetBytesPerRow * subsetHeight);
+#ifdef DEBUG
+ NSLog(@"allocated %d bytes of memory", subsetBytesPerRow * subsetHeight);
+#endif
+
+ CGColorSpaceRef grayColorSpace = CGColorSpaceCreateDeviceGray();
+
+ CGContextRef ctx =
+ CGBitmapContextCreate(subsetData, subsetWidth, subsetHeight,
+ 8, subsetBytesPerRow, grayColorSpace,
+ kCGImageAlphaNone);
+ CGColorSpaceRelease(grayColorSpace);
+ CGContextSetInterpolationQuality(ctx, kCGInterpolationNone);
+ CGContextSetAllowsAntialiasing(ctx, false);
+ // adjust the coordinate system
+ CGContextTranslateCTM(ctx, 0.0, subsetHeight);
+ CGContextScaleCTM(ctx, 1.0, -1.0);
+
+#ifdef DEBUG
+ NSLog(@"created %dx%d bitmap context", subsetWidth, subsetHeight);
+#endif
+
+ UIGraphicsPushContext(ctx);
+ CGRect rect = CGRectMake(offset.x * scale, offset.y * scale, scale * size.width, scale * size.height);
+#ifdef DEBUG
+ NSLog(@"rect for image = (%.1f,%.1f)x(%.1f,%.1f)", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
+#endif
+ [image drawInRect:rect];
+ UIGraphicsPopContext();
+
+#ifdef DEBUG
+ NSLog(@"drew image into %d(%d)x%d bitmap context", subsetWidth, subsetBytesPerRow, subsetHeight);
+#endif
+ CGContextFlush(ctx);
+#ifdef DEBUG
+ NSLog(@"flushed context");
+#endif
+
+ CGImageRef subsetImageRef = CGBitmapContextCreateImage(ctx);
+#ifdef DEBUG
+ NSLog(@"created CGImage from context");
+#endif
+
+ self.subsetImage = [UIImage imageWithCGImage:subsetImageRef];
+ CGImageRelease(subsetImageRef);
+
+ CGContextRelease(ctx);
+#ifdef DEBUG
+ NSLog(@"released context");
+#endif
+}
+
+- (void)decode:(id)arg {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ {
+
+ NSSet *formatReaders = [FormatReader formatReaders];
+
+ Ref<LuminanceSource> source (new GrayBytesMonochromeBitmapSource(subsetData, subsetWidth, subsetHeight, subsetBytesPerRow));
+
+ Ref<Binarizer> binarizer (new GlobalHistogramBinarizer(source));
+ Ref<BinaryBitmap> grayImage (new BinaryBitmap(binarizer));
+#ifdef DEBUG
+ NSLog(@"created GrayBytesMonochromeBitmapSource", subsetWidth, subsetHeight);
+ NSLog(@"grayImage count = %d", grayImage->count());
+#endif
+
+ TwoDDecoderResult *decoderResult = nil;
+
+#ifdef TRY_ROTATIONS
+ for (int i = 0; !decoderResult && i < 4; i++) {
+#endif
+ for (FormatReader *reader in formatReaders) {
+ try {
+ #ifdef DEBUG
+ NSLog(@"decoding gray image");
+ #endif
+ Ref<Result> result([reader decode:grayImage]);
+ #ifdef DEBUG
+ NSLog(@"gray image decoded");
+ #endif
+
+ Ref<String> resultText(result->getText());
+ const char *cString = resultText->getText().c_str();
+ const std::vector<Ref<ResultPoint> > &resultPoints = result->getResultPoints();
+ NSMutableArray *points =
+ [NSMutableArray arrayWithCapacity:resultPoints.size()];
+
+ for (size_t i = 0; i < resultPoints.size(); i++) {
+ const Ref<ResultPoint> &rp = resultPoints[i];
+ CGPoint p = CGPointMake(rp->getX(), rp->getY());
+ [points addObject:[NSValue valueWithCGPoint:p]];
+ }
+
+ NSString *resultString = [NSString stringWithCString:cString
+ encoding:NSUTF8StringEncoding];
+
+ decoderResult = [TwoDDecoderResult resultWithText:resultString
+ points:points];
+ } catch (ReaderException &rex) {
+ NSLog(@"failed to decode, caught ReaderException '%s'",
+ rex.what());
+ } catch (IllegalArgumentException &iex) {
+ NSLog(@"failed to decode, caught IllegalArgumentException '%s'",
+ iex.what());
+ } catch (...) {
+ NSLog(@"Caught unknown exception!");
+ }
+ }
+
+#ifdef TRY_ROTATIONS
+ if (!decoderResult) {
+#ifdef DEBUG
+ NSLog(@"rotating gray image");
+#endif
+ grayImage = grayImage->rotateCounterClockwise();
+#ifdef DEBUG
+ NSLog(@"gray image rotated");
+#endif
+ }
+ }
+#endif
+
+ if (decoderResult) {
+ [self performSelectorOnMainThread:@selector(didDecodeImage:)
+ withObject:decoderResult
+ waitUntilDone:NO];
+ } else {
+ [self performSelectorOnMainThread:@selector(failedToDecodeImage:)
+ withObject:NSLocalizedString(@"Decoder BarcodeDetectionFailure", @"No barcode detected.")
+ waitUntilDone:NO];
+ }
+
+ free(subsetData);
+ self.subsetData = NULL;
+ }
+ [pool drain];
+#ifdef DEBUG
+ NSLog(@"finished decoding.");
+#endif
+
+ // if this is not the main thread, then we end it
+ if (![NSThread isMainThread]) {
+ [NSThread exit];
+ }
+}
+
+- (void) decodeImage:(UIImage *)i {
+ [self decodeImage:i cropRect:CGRectMake(0.0f, 0.0f, image.size.width, image.size.height)];
+}
+
+- (void) decodeImage:(UIImage *)i cropRect:(CGRect)cr {
+ self.image = i;
+ self.cropRect = cr;
+
+ [self prepareSubset];
+ [self willDecodeImage];
+ [self performSelectorOnMainThread:@selector(progressDecodingImage:)
+ withObject:NSLocalizedString(@"Decoder MessageWhileDecoding", @"Decoding ...")
+ waitUntilDone:NO];
+
+ [NSThread detachNewThreadSelector:@selector(decode:)
+ toTarget:self
+ withObject:nil];
+}
+
+- (void) dealloc {
+ [image release];
+ [subsetImage release];
+ if (subsetData) free(subsetData);
+ [super dealloc];
+}
+
+ at end
diff --git a/iphone/Classes/DecoderDelegate.h b/iphone/Classes/DecoderDelegate.h
index 35d454e..5a78203 100644
--- a/iphone/Classes/DecoderDelegate.h
+++ b/iphone/Classes/DecoderDelegate.h
@@ -24,8 +24,8 @@
@class Decoder;
@class TwoDDecoderResult;
- at protocol DecoderDelegate
-
+ at protocol DecoderDelegate<NSObject>
+ at optional
- (void)decoder:(Decoder *)decoder willDecodeImage:(UIImage *)image usingSubset:(UIImage *)subset;
- (void)decoder:(Decoder *)decoder decodingImage:(UIImage *)image usingSubset:(UIImage *)subset progress:(NSString *)message;
- (void)decoder:(Decoder *)decoder didDecodeImage:(UIImage *)image usingSubset:(UIImage *)subset withResult:(TwoDDecoderResult *)result;
diff --git a/iphone/Classes/DecoderViewController.m b/iphone/Classes/DecoderViewController.m
index 02dc731..6fb2d86 100644
--- a/iphone/Classes/DecoderViewController.m
+++ b/iphone/Classes/DecoderViewController.m
@@ -53,7 +53,7 @@
@synthesize resultPointViews;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
- if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
+ if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Initialization code
self.title = NSLocalizedString(@"DecoderViewController AppTitle", @"Barcode Scanner");
@@ -82,24 +82,24 @@
NSLog(@"Showing Hints!");
MessageViewController *hintsController =
- [[MessageViewController alloc] initWithMessageFilename:@"Hints"
- target:self
- onSuccess:@selector(messageReady:)
- onFailure:@selector(messageFailed:)];
+ [[MessageViewController alloc] initWithMessageFilename:@"Hints"
+ target:self
+ onSuccess:@selector(messageReady:)
+ onFailure:@selector(messageFailed:)];
hintsController.title = NSLocalizedString(@"DecoderViewController Hints MessageViewController title", @"Hints");
- hintsController.view;
+ [hintsController view];
}
- (void) showAbout:(id)sender {
NSLog(@"Showing About!");
MessageViewController *aboutController =
- [[MessageViewController alloc] initWithMessageFilename:@"About"
- target:self
- onSuccess:@selector(messageReady:)
- onFailure:@selector(messageFailed:)];
+ [[MessageViewController alloc] initWithMessageFilename:@"About"
+ target:self
+ onSuccess:@selector(messageReady:)
+ onFailure:@selector(messageFailed:)];
aboutController.title = NSLocalizedString(@"DecoderViewController About MessageViewController title", @"About");
- aboutController.view;
+ [aboutController view];
}
@@ -257,11 +257,11 @@
NSLog(@"Showing message '%@' %@ help Button", message, showHelpButton ? @"with" : @"without");
#endif
- CGSize maxSize = imageView.bounds.size;
+ CGSize imageMaxSize = imageView.bounds.size;
if (showHelpButton) {
- maxSize.width -= messageHelpButton.frame.size.width;
+ imageMaxSize.width -= messageHelpButton.frame.size.width;
}
- CGSize size = [message sizeWithFont:messageTextView.font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap];
+ CGSize size = [message sizeWithFont:messageTextView.font constrainedToSize:imageMaxSize lineBreakMode:UILineBreakModeWordWrap];
float height = 20.0 + fmin(100.0, size.height);
if (showHelpButton) {
height = fmax(HELP_BUTTON_HEIGHT, height);
diff --git a/iphone/Classes/EmailAction.h b/iphone/Classes/EmailAction.h
index d4472ca..78e48e8 100644
--- a/iphone/Classes/EmailAction.h
+++ b/iphone/Classes/EmailAction.h
@@ -28,7 +28,7 @@
@property (nonatomic, copy) NSString *recipient;
-- initWithRecipient:(NSString *)recipient subject:(NSString *)subject body:(NSString *)body;
-+ actionWithRecipient:(NSString *)recipient subject:(NSString *)subject body:(NSString *)body;
+- (id)initWithRecipient:(NSString *)recipient subject:(NSString *)subject body:(NSString *)body;
++ (id)actionWithRecipient:(NSString *)recipient subject:(NSString *)subject body:(NSString *)body;
@end
diff --git a/iphone/Classes/EmailAction.m b/iphone/Classes/EmailAction.m
index f9f142c..2f4fb01 100644
--- a/iphone/Classes/EmailAction.m
+++ b/iphone/Classes/EmailAction.m
@@ -37,14 +37,14 @@ static NSURL *MailtoURL(NSString *to, NSString *sub, NSString *body) {
return [NSURL URLWithString:result];
}
-- initWithRecipient:(NSString *)rec subject:(NSString *)subject body:(NSString *)body {
+- (id)initWithRecipient:(NSString *)rec subject:(NSString *)subject body:(NSString *)body {
if ((self = [super initWithURL:MailtoURL(rec, subject, body)]) != nil) {
self.recipient = rec;
}
return self;
}
-+ actionWithRecipient:(NSString *)recipient subject:(NSString *)subject body:(NSString *)body {
++ (id)actionWithRecipient:(NSString *)recipient subject:(NSString *)subject body:(NSString *)body {
return [[[self alloc] initWithRecipient:recipient subject:subject body:body] autorelease];
}
diff --git a/iphone/Classes/EmailDoCoMoResultParser.m b/iphone/Classes/EmailDoCoMoResultParser.m
index 4761aa1..c62a473 100644
--- a/iphone/Classes/EmailDoCoMoResultParser.m
+++ b/iphone/Classes/EmailDoCoMoResultParser.m
@@ -24,6 +24,10 @@
@implementation EmailDoCoMoResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange foundRange = [s rangeOfString:@"MATMSG:"];
if (foundRange.location == NSNotFound) {
diff --git a/iphone/ZXing_Prefix.pch b/iphone/Classes/FormatReader.h
similarity index 55%
copy from iphone/ZXing_Prefix.pch
copy to iphone/Classes/FormatReader.h
index 6acbbc5..350a7a6 100644
--- a/iphone/ZXing_Prefix.pch
+++ b/iphone/Classes/FormatReader.h
@@ -1,8 +1,9 @@
//
-// Prefix header for all source files of the 'ZXing' target in the 'ZXing' project
+// FormatReader.h
//
+// Created by Dave MacLachlan on 2010-05-03.
/*
- * Copyright 2008 Google Inc.
+ * Copyright 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +18,20 @@
* limitations under the License.
*/
-#ifdef __OBJC__
#import <Foundation/Foundation.h>
-#import <UIKit/UIKit.h>
-#endif
+#import <zxing/common/Counted.h>
+#import <zxing/Result.h>
+#import <zxing/BinaryBitmap.h>
+#import <zxing/Reader.h>
+
+ at interface FormatReader : NSObject {
+ zxing::Reader *reader_;
+}
+
++ (void)registerFormatReader:(FormatReader *)formatReader;
++ (NSSet *)formatReaders;
+
+- (id)initWithReader:(zxing::Reader *)reader;
+- (zxing::Ref<zxing::Result>)decode:(zxing::Ref<zxing::BinaryBitmap>)grayImage;
+
+ at end
diff --git a/iphone/Classes/FormatReader.mm b/iphone/Classes/FormatReader.mm
new file mode 100644
index 0000000..b1db6dc
--- /dev/null
+++ b/iphone/Classes/FormatReader.mm
@@ -0,0 +1,62 @@
+//
+// FormatReader.mm
+//
+// Created by Dave MacLachlan on 2010-05-03.
+/*
+ * Copyright 2010 ZXing authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#import "FormatReader.h"
+
+ at implementation FormatReader
+
+static NSMutableSet *sFormatReaders = nil;
+
++ (void)registerFormatReader:(FormatReader*)formatReader {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ @synchronized(self) {
+ if (!sFormatReaders) {
+ sFormatReaders = [[NSMutableSet alloc] init];
+ }
+ [sFormatReaders addObject:formatReader];
+ }
+ [pool drain];
+}
+
++ (NSSet *)formatReaders {
+ NSSet *formatReaders = nil;
+ @synchronized(self) {
+ formatReaders = [[sFormatReaders copy] autorelease];
+ }
+ return formatReaders;
+}
+
+- (id)initWithReader:(zxing::Reader *)reader {
+ if ((self = [super init])) {
+ reader_ = reader;
+ }
+ return self;
+}
+
+- (void)dealloc {
+ delete reader_;
+ [super dealloc];
+}
+
+- (zxing::Ref<zxing::Result>)decode:(zxing::Ref<zxing::BinaryBitmap>)grayImage {
+ return reader_->decode(grayImage);
+}
+
+ at end
diff --git a/iphone/Classes/GeoParsedResult.h b/iphone/Classes/GeoParsedResult.h
index d428fe9..4feb880 100644
--- a/iphone/Classes/GeoParsedResult.h
+++ b/iphone/Classes/GeoParsedResult.h
@@ -28,7 +28,7 @@
@property (nonatomic, copy) NSString *location;
-- initWithLocation:(NSString *)location;
+- (id)initWithLocation:(NSString *)location;
@end
diff --git a/iphone/Classes/GeoParsedResult.m b/iphone/Classes/GeoParsedResult.m
index 368149d..44ecfc8 100644
--- a/iphone/Classes/GeoParsedResult.m
+++ b/iphone/Classes/GeoParsedResult.m
@@ -26,7 +26,7 @@
@synthesize location;
-- initWithLocation:(NSString *)l {
+- (id)initWithLocation:(NSString *)l {
if ((self = [super init]) != nil) {
self.location = l;
}
diff --git a/iphone/Classes/GeoResultParser.m b/iphone/Classes/GeoResultParser.m
index f263780..790983a 100644
--- a/iphone/Classes/GeoResultParser.m
+++ b/iphone/Classes/GeoResultParser.m
@@ -26,6 +26,10 @@
@implementation GeoResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange prefixRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (prefixRange.location == 0) {
diff --git a/iphone/Classes/GrayBytesMonochromeBitmapSource.cpp b/iphone/Classes/GrayBytesMonochromeBitmapSource.cpp
index 302156a..317919a 100644
--- a/iphone/Classes/GrayBytesMonochromeBitmapSource.cpp
+++ b/iphone/Classes/GrayBytesMonochromeBitmapSource.cpp
@@ -33,15 +33,15 @@ GrayBytesMonochromeBitmapSource::GrayBytesMonochromeBitmapSource(const unsigned
bytesPerRow_(bytesPerRow) { }
-int GrayBytesMonochromeBitmapSource::getWidth() {
+int GrayBytesMonochromeBitmapSource::getWidth() const{
return width_;
}
-int GrayBytesMonochromeBitmapSource::getHeight() {
+int GrayBytesMonochromeBitmapSource::getHeight() const {
return height_;
}
-unsigned char GrayBytesMonochromeBitmapSource::getPixel(int x, int y) {
+unsigned char GrayBytesMonochromeBitmapSource::getPixel(int x, int y) const {
/* if (x >= width_ || y >= height_) {
throw new ReaderException("bitmap coordinate out of bounds");
}*/
diff --git a/iphone/Classes/GrayBytesMonochromeBitmapSource.h b/iphone/Classes/GrayBytesMonochromeBitmapSource.h
index 6f14159..462118c 100644
--- a/iphone/Classes/GrayBytesMonochromeBitmapSource.h
+++ b/iphone/Classes/GrayBytesMonochromeBitmapSource.h
@@ -38,11 +38,14 @@ public:
int bytesPerRow);
virtual ~GrayBytesMonochromeBitmapSource() { }
- virtual unsigned char getPixel(int x, int y);
-
- virtual int getWidth();
- virtual int getHeight();
+ virtual unsigned char getPixel(int x, int y) const;
+ virtual int getWidth() const;
+ virtual int getHeight() const;
+
+private:
+ GrayBytesMonochromeBitmapSource(const GrayBytesMonochromeBitmapSource&);
+ GrayBytesMonochromeBitmapSource& operator=(const GrayBytesMonochromeBitmapSource&);
};
#endif // __GRAY_BYTES_MONOCHROM_BITMAP_SOURCE_H__
diff --git a/iphone/Classes/MeCardParser.m b/iphone/Classes/MeCardParser.m
index c784583..77d4e6d 100644
--- a/iphone/Classes/MeCardParser.m
+++ b/iphone/Classes/MeCardParser.m
@@ -24,6 +24,10 @@
@implementation MeCardParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange foundRange = [s rangeOfString:@"MECARD:"];
if (foundRange.location == NSNotFound) {
diff --git a/iphone/Classes/MessageViewController.m b/iphone/Classes/MessageViewController.m
index 3449fec..886b60c 100644
--- a/iphone/Classes/MessageViewController.m
+++ b/iphone/Classes/MessageViewController.m
@@ -37,7 +37,7 @@
target:(id)cbt
onSuccess:(SEL)ss
onFailure:(SEL)fs {
- if (self = [super initWithNibName:@"Message" bundle:nil]) {
+ if ((self = [super initWithNibName:@"Message" bundle:nil])) {
self.callbackTarget = cbt;
self.callbackSelectorSuccess = ss;
self.callbackSelectorFailure = fs;
diff --git a/iphone/Classes/ResultAction.m b/iphone/Classes/MultiFormatReader.mm
similarity index 52%
copy from iphone/Classes/ResultAction.m
copy to iphone/Classes/MultiFormatReader.mm
index d0b61d3..a1b8bf7 100644
--- a/iphone/Classes/ResultAction.m
+++ b/iphone/Classes/MultiFormatReader.mm
@@ -1,10 +1,9 @@
//
-// ResultAction.m
-// ZXing
+// MultiFormatReader.mm
//
-// Created by Christian Brunschen on 28/05/2008.
+// Created by Dave MacLachlan on 2010-05-03.
/*
- * Copyright 2008 ZXing authors
+ * Copyright 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,18 +18,23 @@
* limitations under the License.
*/
-#import "ResultAction.h"
+#import "FormatReader.h"
+#import <zxing/MultiFormatReader.h>
+ at interface MultiFormatReader : FormatReader
+ at end
- at implementation ResultAction
+ at implementation MultiFormatReader
-- (NSString *)title {
- return @"Abstract Action";
++ (void)load {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [FormatReader registerFormatReader:[[[self alloc] init] autorelease]];
+ [pool drain];
}
-- (void)performActionWithController:(UIViewController *)controller
- shouldConfirm:(bool)confirm {
- NSLog(@"Abstract Action performed");
+- (id)init {
+ zxing::MultiFormatReader *reader = new zxing::MultiFormatReader();
+ return [super initWithReader:reader];
}
@end
diff --git a/iphone/Classes/OpenUrlAction.h b/iphone/Classes/OpenUrlAction.h
index 687b251..cc1e17b 100644
--- a/iphone/Classes/OpenUrlAction.h
+++ b/iphone/Classes/OpenUrlAction.h
@@ -28,8 +28,8 @@
@property(nonatomic, retain) NSURL *URL;
-- initWithURL:(NSURL *)URL;
-+ actionWithURL:(NSURL *)URL;
+- (id)initWithURL:(NSURL *)URL;
++ (id)actionWithURL:(NSURL *)URL;
- (void)openURL;
- (NSString *)alertTitle;
diff --git a/iphone/Classes/OpenUrlAction.m b/iphone/Classes/OpenUrlAction.m
index 9d3ea06..f59da60 100644
--- a/iphone/Classes/OpenUrlAction.m
+++ b/iphone/Classes/OpenUrlAction.m
@@ -26,14 +26,14 @@
@synthesize URL;
-- initWithURL:(NSURL *)url {
+- (id)initWithURL:(NSURL *)url {
if ((self = [super init]) != nil) {
self.URL = url;
}
return self;
}
-+ actionWithURL:(NSURL *)URL {
++ (id)actionWithURL:(NSURL *)URL {
return [[[self alloc] initWithURL:URL] autorelease];
}
diff --git a/iphone/Classes/PlainEmailResultParser.m b/iphone/Classes/PlainEmailResultParser.m
index 0f0a226..6c90783 100644
--- a/iphone/Classes/PlainEmailResultParser.m
+++ b/iphone/Classes/PlainEmailResultParser.m
@@ -24,6 +24,10 @@
@implementation PlainEmailResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
if ([EmailParsedResult looksLikeAnEmailAddress:s]) {
EmailParsedResult *result = [[[EmailParsedResult alloc] init] autorelease];
diff --git a/iphone/Classes/DoCoMoResultParser.h b/iphone/Classes/QRCodeFormatReader.mm
similarity index 51%
copy from iphone/Classes/DoCoMoResultParser.h
copy to iphone/Classes/QRCodeFormatReader.mm
index 0b52870..2a10e02 100644
--- a/iphone/Classes/DoCoMoResultParser.h
+++ b/iphone/Classes/QRCodeFormatReader.mm
@@ -1,10 +1,10 @@
//
-// DoCoMoResultParser.h
-// ZXing
+// QRCodeFormatReader.mm
+// OTPAuth
//
-// Created by Christian Brunschen on 25/06/2008.
+// Created by Dave MacLachlan on 2010-05-03.
/*
- * Copyright 2008 ZXing authors
+ * Copyright 2010 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,20 +19,24 @@
* limitations under the License.
*/
-#import <UIKit/UIKit.h>
-#import "ResultParser.h"
+#import "FormatReader.h"
- at interface NSString (DoCoMoFieldParsing)
-- (NSString *)backslashUnescaped;
-- (NSArray *)fieldsWithPrefix:(NSString *)prefix;
-- (NSArray *)fieldsWithPrefix:(NSString *)prefix terminator:(NSString *)term;
-- (NSString *)fieldWithPrefix:(NSString *)prefix;
-- (NSString *)fieldWithPrefix:(NSString *)prefix terminator:(NSString *)term;
+#import <zxing/qrcode/QRCodeReader.h>
+
+ at interface QRCodeFormatReader : FormatReader
@end
+ at implementation QRCodeFormatReader
- at interface DoCoMoResultParser : ResultParser {
++ (void)load {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [FormatReader registerFormatReader:[[[self alloc] init] autorelease]];
+ [pool drain];
+}
+- (id)init {
+ zxing::qrcode::QRCodeReader *reader = new zxing::qrcode::QRCodeReader();
+ return [super initWithReader:reader];
}
@end
diff --git a/iphone/Classes/ResultParser.h b/iphone/Classes/ResultParser.h
index fe4fcf0..6651f73 100644
--- a/iphone/Classes/ResultParser.h
+++ b/iphone/Classes/ResultParser.h
@@ -25,7 +25,7 @@
@interface ResultParser : NSObject {
}
-
++ (void)registerResultParserClass:(Class)resultParser;
+ (ParsedResult *)parsedResultForString:(NSString *)s;
@end
diff --git a/iphone/Classes/ResultParser.m b/iphone/Classes/ResultParser.m
index f7a9c09..0e53676 100644
--- a/iphone/Classes/ResultParser.m
+++ b/iphone/Classes/ResultParser.m
@@ -21,37 +21,25 @@
#import "ResultParser.h"
-#import "MeCardParser.h"
-#import "EmailDoCoMoResultParser.h"
-#import "BookmarkDoCoMoResultParser.h"
-#import "TelResultParser.h"
-#import "GeoResultParser.h"
-#import "URLTOResultParser.h"
-#import "URLResultParser.h"
-#import "TextResultParser.h"
-#import "SMSResultParser.h"
-#import "SMSTOResultParser.h"
-#import "PlainEmailResultParser.h"
-
@implementation ResultParser
-static NSArray *resultParsers = nil;
-+ (NSArray *)resultParsers {
- if (resultParsers == nil) {
- resultParsers =
- [[NSArray alloc] initWithObjects:
- [MeCardParser class],
- [EmailDoCoMoResultParser class],
- [BookmarkDoCoMoResultParser class],
- [TelResultParser class],
- [GeoResultParser class],
- [SMSTOResultParser class],
- [SMSResultParser class],
- [URLTOResultParser class],
- [URLResultParser class],
- [PlainEmailResultParser class],
- [TextResultParser class],
- nil];
+static NSMutableSet *sResultParsers = nil;
+
++ (void)registerResultParserClass:(Class)resultParser {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ @synchronized(self) {
+ if (!sResultParsers) {
+ sResultParsers = [[NSMutableSet alloc] init];
+ }
+ [sResultParsers addObject:resultParser];
+ }
+ [pool drain];
+}
+
++ (NSSet *)resultParsers {
+ NSSet *resultParsers = nil;
+ @synchronized(self) {
+ resultParsers = [[sResultParsers copy] autorelease];
}
return resultParsers;
}
diff --git a/iphone/Classes/SMSParsedResult.h b/iphone/Classes/SMSParsedResult.h
index d1c7976..3349d1b 100644
--- a/iphone/Classes/SMSParsedResult.h
+++ b/iphone/Classes/SMSParsedResult.h
@@ -31,6 +31,6 @@
@property (nonatomic, copy) NSString *number;
@property (nonatomic, copy) NSString *body;
-- initWithNumber:(NSString *)n body:(NSString *)b;
+- (id)initWithNumber:(NSString *)n body:(NSString *)b;
@end
diff --git a/iphone/Classes/SMSParsedResult.m b/iphone/Classes/SMSParsedResult.m
index c9d1e13..ac2205b 100644
--- a/iphone/Classes/SMSParsedResult.m
+++ b/iphone/Classes/SMSParsedResult.m
@@ -27,7 +27,7 @@
@synthesize number;
@synthesize body;
-- initWithNumber:(NSString *)n body:(NSString *)b {
+- (id)initWithNumber:(NSString *)n body:(NSString *)b {
if ((self = [super init]) != nil) {
self.number = n;
self.body = b;
diff --git a/iphone/Classes/SMSResultParser.m b/iphone/Classes/SMSResultParser.m
index 7b339ea..d6cf3e8 100644
--- a/iphone/Classes/SMSResultParser.m
+++ b/iphone/Classes/SMSResultParser.m
@@ -26,6 +26,10 @@
@implementation SMSResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange prefixRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (prefixRange.location == 0) {
diff --git a/iphone/Classes/SMSTOResultParser.m b/iphone/Classes/SMSTOResultParser.m
index d552a66..a10a55c 100644
--- a/iphone/Classes/SMSTOResultParser.m
+++ b/iphone/Classes/SMSTOResultParser.m
@@ -26,6 +26,10 @@
@implementation SMSTOResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange prefixRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (prefixRange.location == 0) {
diff --git a/iphone/Classes/Scan.h b/iphone/Classes/Scan.h
index 4b5fd3a..b96d9c9 100644
--- a/iphone/Classes/Scan.h
+++ b/iphone/Classes/Scan.h
@@ -32,6 +32,6 @@
@property (nonatomic, copy) NSString *text;
@property (nonatomic, retain) NSDate *stamp;
-- initWithIdent:(int)i text:(NSString *)t stamp:(NSDate *)s;
+- (id)initWithIdent:(int)i text:(NSString *)t stamp:(NSDate *)s;
@end
diff --git a/iphone/Classes/Scan.m b/iphone/Classes/Scan.m
index b792c51..6d7b29b 100644
--- a/iphone/Classes/Scan.m
+++ b/iphone/Classes/Scan.m
@@ -28,7 +28,7 @@
@synthesize text;
@synthesize stamp;
-- initWithIdent:(int)i text:(NSString *)t stamp:(NSDate *)s {
+- (id)initWithIdent:(int)i text:(NSString *)t stamp:(NSDate *)s {
if ((self = [super init]) != nil) {
self.ident = i;
self.text = t;
diff --git a/iphone/Classes/ScanCell.m b/iphone/Classes/ScanCell.m
index b87422f..3144ab4 100644
--- a/iphone/Classes/ScanCell.m
+++ b/iphone/Classes/ScanCell.m
@@ -66,7 +66,7 @@ static NSString *_timeString(NSDate *date) {
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
- if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
+ if ((self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier])) {
imageView = [[UIImageView alloc] initWithFrame:CGRectZero];
imageView.contentMode = UIViewContentModeCenter;
[self.contentView addSubview:imageView];
diff --git a/iphone/Classes/ScanViewController.m b/iphone/Classes/ScanViewController.m
index 8950cb3..ee40cc9 100644
--- a/iphone/Classes/ScanViewController.m
+++ b/iphone/Classes/ScanViewController.m
@@ -39,7 +39,7 @@
#define FONT_SIZE 16
- (id)initWithResult:(ParsedResult *)r forScan:(Scan *)s {
- if (self = [super initWithStyle:UITableViewStyleGrouped]) {
+ if ((self = [super initWithStyle:UITableViewStyleGrouped])) {
self.result = r;
self.scan = s;
self.title = NSLocalizedString(@"ScanViewController title", @"Scan");
@@ -86,9 +86,10 @@
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:DatetimeIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 34) reuseIdentifier:DatetimeIdentifier] autorelease];
- cell.font = [UIFont systemFontOfSize:[UIFont systemFontSize] * 2.0 / 3.0];
- cell.textColor = [UIColor grayColor];
- cell.textAlignment = UITextAlignmentCenter;
+ UILabel *label = [cell textLabel];
+ label.font = [UIFont systemFontOfSize:[UIFont systemFontSize] * 2.0 / 3.0];
+ label.textColor = [UIColor grayColor];
+ label.textAlignment = UITextAlignmentCenter;
}
return cell;
}
@@ -152,15 +153,18 @@
if (indexPath.section == 0) {
if (indexPath.row == 0) {
cell = [self titleCellInTableView:tableView];
- cell.image = [result icon];
- cell.text = [[result class] typeName];
+ UIImageView *imageView = cell.imageView;
+ imageView.image = [result icon];
+ UILabel *textLabel = cell.textLabel;
+ textLabel.text = [[result class] typeName];
} else if (indexPath.row == 1) {
cell = [self bodyCellInTableView:tableView];
UITextView *textView = (UITextView *)[cell viewWithTag:TEXT_VIEW_TAG];
textView.text = [result stringForDisplay];
} else if (indexPath.row == 2) {
cell = [self datetimeCellInTableView:tableView];
- cell.text = [dateFormatter stringFromDate:[scan stamp]];
+ UILabel *textLabel = cell.textLabel;
+ textLabel.text = [dateFormatter stringFromDate:[scan stamp]];
}
} else if (indexPath.section == 1) {
cell = [self buttonCellInTableView:tableView];
diff --git a/iphone/Classes/ScannedImageView.m b/iphone/Classes/ScannedImageView.m
index a41cbd8..494b894 100644
--- a/iphone/Classes/ScannedImageView.m
+++ b/iphone/Classes/ScannedImageView.m
@@ -25,7 +25,7 @@
@implementation ScannedImageView
- (id)initWithFrame:(CGRect)frame {
- if (self = [super initWithFrame:frame]) {
+ if ((self = [super initWithFrame:frame])) {
resultPoints = [[NSMutableArray alloc] initWithCapacity:10];
}
return self;
diff --git a/iphone/Classes/ShowMapAction.h b/iphone/Classes/ShowMapAction.h
index 2e26e03..3f30423 100644
--- a/iphone/Classes/ShowMapAction.h
+++ b/iphone/Classes/ShowMapAction.h
@@ -28,7 +28,7 @@
@property (nonatomic, copy) NSString *location;
-- initWithLocation:(NSString *)location;
-+ actionWithLocation:(NSString *)location;
+- (id)initWithLocation:(NSString *)location;
++ (id)actionWithLocation:(NSString *)location;
@end
diff --git a/iphone/Classes/ShowMapAction.m b/iphone/Classes/ShowMapAction.m
index 7ec13eb..f3817a2 100644
--- a/iphone/Classes/ShowMapAction.m
+++ b/iphone/Classes/ShowMapAction.m
@@ -32,14 +32,14 @@ static NSURL * URLForLocation(NSString *location) {
return [NSURL URLWithString:urlString];
}
-- initWithLocation:(NSString *)l {
+- (id)initWithLocation:(NSString *)l {
if ((self = [super initWithURL:URLForLocation(l)]) != nil) {
self.location = l;
}
return self;
}
-+ actionWithLocation:(NSString *)location {
++ (id)actionWithLocation:(NSString *)location {
return [[[self alloc] initWithLocation:location] autorelease];
}
diff --git a/iphone/Classes/TelParsedResult.h b/iphone/Classes/TelParsedResult.h
index ec028ce..6d7789d 100644
--- a/iphone/Classes/TelParsedResult.h
+++ b/iphone/Classes/TelParsedResult.h
@@ -28,6 +28,6 @@
@property (nonatomic, copy) NSString *number;
-- initWithNumber:(NSString *)n;
+- (id)initWithNumber:(NSString *)n;
@end
diff --git a/iphone/Classes/TelParsedResult.m b/iphone/Classes/TelParsedResult.m
index 8a47efc..d431189 100644
--- a/iphone/Classes/TelParsedResult.m
+++ b/iphone/Classes/TelParsedResult.m
@@ -26,7 +26,7 @@
@synthesize number;
-- initWithNumber:(NSString *)n {
+- (id)initWithNumber:(NSString *)n {
if ((self = [super init]) != nil) {
self.number = n;
}
diff --git a/iphone/Classes/TelResultParser.m b/iphone/Classes/TelResultParser.m
index 1756b5c..9012210 100644
--- a/iphone/Classes/TelResultParser.m
+++ b/iphone/Classes/TelResultParser.m
@@ -26,6 +26,10 @@
@implementation TelResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange telRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (telRange.location == 0) {
diff --git a/iphone/Classes/TextParsedResult.h b/iphone/Classes/TextParsedResult.h
index 690235a..c716104 100644
--- a/iphone/Classes/TextParsedResult.h
+++ b/iphone/Classes/TextParsedResult.h
@@ -29,6 +29,6 @@
@property (nonatomic, copy) NSString *text;
-- initWithString:(NSString *)s;
+- (id)initWithString:(NSString *)s;
@end
diff --git a/iphone/Classes/TextParsedResult.m b/iphone/Classes/TextParsedResult.m
index 4e1dd34..1572456 100644
--- a/iphone/Classes/TextParsedResult.m
+++ b/iphone/Classes/TextParsedResult.m
@@ -27,7 +27,7 @@
@synthesize text;
-- initWithString:(NSString *)s {
+- (id)initWithString:(NSString *)s {
if ((self = [super init]) != nil) {
self.text = s;
}
diff --git a/iphone/Classes/TextResultParser.m b/iphone/Classes/TextResultParser.m
index f68094b..fcc6cbe 100644
--- a/iphone/Classes/TextResultParser.m
+++ b/iphone/Classes/TextResultParser.m
@@ -24,6 +24,10 @@
@implementation TextResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
return [[[TextParsedResult alloc] initWithString:s] autorelease];
}
diff --git a/iphone/Classes/TwoDDecoderResult.h b/iphone/Classes/TwoDDecoderResult.h
index 963faaa..62263ea 100644
--- a/iphone/Classes/TwoDDecoderResult.h
+++ b/iphone/Classes/TwoDDecoderResult.h
@@ -29,7 +29,7 @@
@property (nonatomic, copy) NSString *text;
@property (nonatomic, retain) NSArray *points;
-+ resultWithText:(NSString *)text points:(NSArray *)points;
-- initWithText:(NSString *)text points:(NSArray *)points;
++ (id)resultWithText:(NSString *)text points:(NSArray *)points;
+- (id)initWithText:(NSString *)text points:(NSArray *)points;
@end
diff --git a/iphone/Classes/TwoDDecoderResult.m b/iphone/Classes/TwoDDecoderResult.m
index 5860354..d83f66b 100644
--- a/iphone/Classes/TwoDDecoderResult.m
+++ b/iphone/Classes/TwoDDecoderResult.m
@@ -27,11 +27,11 @@
@synthesize text;
@synthesize points;
-+ resultWithText:(NSString *)text points:(NSArray *)points {
++ (id)resultWithText:(NSString *)text points:(NSArray *)points {
return [[[self alloc] initWithText:text points:points] autorelease];
}
-- initWithText:(NSString *)t points:(NSArray *)p {
+- (id)initWithText:(NSString *)t points:(NSArray *)p {
if ((self = [super init]) != nil) {
self.text = t;
self.points = p;
@@ -45,5 +45,8 @@
[super dealloc];
}
+- (NSString *)description {
+ return [NSString stringWithFormat:@"<%@: %p> %@", [self class], self, self.text];
+}
@end
diff --git a/iphone/Classes/URIParsedResult.h b/iphone/Classes/URIParsedResult.h
index 5f78e9a..ae957e7 100644
--- a/iphone/Classes/URIParsedResult.h
+++ b/iphone/Classes/URIParsedResult.h
@@ -33,10 +33,10 @@
NSURL *URL;
}
-- initWithURLString:(NSString *)s title:(NSString *)t URL:(NSURL *)ur;
-- initWithURLString:(NSString *)s title:(NSString *)t;
-- initWithURLString:(NSString *)s URL:(NSURL *)ur;
-- initWithURLString:(NSString *)s;
+- (id)initWithURLString:(NSString *)s title:(NSString *)t URL:(NSURL *)ur;
+- (id)initWithURLString:(NSString *)s title:(NSString *)t;
+- (id)initWithURLString:(NSString *)s URL:(NSURL *)ur;
+- (id)initWithURLString:(NSString *)s;
@property (nonatomic, retain) NSString *urlString;
@property (nonatomic, retain) NSString *title;
diff --git a/iphone/Classes/URIParsedResult.m b/iphone/Classes/URIParsedResult.m
index 8b9af8c..0ab9833 100644
--- a/iphone/Classes/URIParsedResult.m
+++ b/iphone/Classes/URIParsedResult.m
@@ -35,7 +35,7 @@
return [OpenUrlAction actionWithURL:self.URL];
}
-- initWithURLString:(NSString *)s title:(NSString *)t URL:(NSURL *)url {
+- (id)initWithURLString:(NSString *)s title:(NSString *)t URL:(NSURL *)url {
if ((self = [super init]) != nil) {
self.urlString = s;
self.title = t;
@@ -44,15 +44,15 @@
return self;
}
-- initWithURLString:(NSString *)s URL:(NSURL *)url {
+- (id)initWithURLString:(NSString *)s URL:(NSURL *)url {
return [self initWithURLString:s title:nil URL:url];
}
-- initWithURLString:(NSString *)s title:(NSString *)t {
+- (id)initWithURLString:(NSString *)s title:(NSString *)t {
return [self initWithURLString:s title:t URL:[NSURL URLWithString:s]];
}
-- initWithURLString:(NSString *)s {
+- (id)initWithURLString:(NSString *)s {
return [self initWithURLString:s title:nil URL:[NSURL URLWithString:s]];
}
diff --git a/iphone/Classes/URLResultParser.m b/iphone/Classes/URLResultParser.m
index 1d30458..df93f19 100644
--- a/iphone/Classes/URLResultParser.m
+++ b/iphone/Classes/URLResultParser.m
@@ -53,6 +53,10 @@
@implementation URLResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange prefixRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (prefixRange.location == 0) {
diff --git a/iphone/Classes/URLTOResultParser.m b/iphone/Classes/URLTOResultParser.m
index dcab150..73f2fc0 100644
--- a/iphone/Classes/URLTOResultParser.m
+++ b/iphone/Classes/URLTOResultParser.m
@@ -26,6 +26,10 @@
@implementation URLTOResultParser
++ (void)load {
+ [ResultParser registerResultParserClass:self];
+}
+
+ (ParsedResult *)parsedResultForString:(NSString *)s {
NSRange prefixRange = [s rangeOfString:PREFIX options:NSCaseInsensitiveSearch];
if (prefixRange.location == 0) {
diff --git a/iphone/Classes/ZXingAppDelegate.m b/iphone/Classes/ZXingAppDelegate.m
index e30c424..df3cb5f 100644
--- a/iphone/Classes/ZXingAppDelegate.m
+++ b/iphone/Classes/ZXingAppDelegate.m
@@ -48,20 +48,18 @@
[window makeKeyAndVisible];
// pick and decode using the first available source type in priority order
-#define N_SOURCE_TYPES 3
- UIImagePickerControllerSourceType sourceTypes[N_SOURCE_TYPES] = {
+ UIImagePickerControllerSourceType sourceTypes[] = {
UIImagePickerControllerSourceTypeCamera,
UIImagePickerControllerSourceTypeSavedPhotosAlbum,
UIImagePickerControllerSourceTypePhotoLibrary
};
- for (int i = 0; i < N_SOURCE_TYPES; i++) {
+ for (int i = 0; i < sizeof(sourceTypes) / sizeof(*sourceTypes); i++) {
if ([UIImagePickerController isSourceTypeAvailable:sourceTypes[i]]) {
[viewController pickAndDecodeFromSource:sourceTypes[i]];
break;
}
}
-#undef N_SOURCE_TYPES
}
- (void)dealloc {
diff --git a/iphone/ZXing.xcodeproj/project.pbxproj b/iphone/ZXing.xcodeproj/project.pbxproj
index e2197b1..792fc64 100755
--- a/iphone/ZXing.xcodeproj/project.pbxproj
+++ b/iphone/ZXing.xcodeproj/project.pbxproj
@@ -61,7 +61,7 @@
855A668C0DF5E757007B394F /* TelParsedResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A666A0DF5E757007B394F /* TelParsedResult.m */; };
855A668D0DF5E757007B394F /* TextParsedResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A666C0DF5E757007B394F /* TextParsedResult.m */; };
855A668E0DF5E757007B394F /* DecoderViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A666E0DF5E757007B394F /* DecoderViewController.m */; };
- 855A668F0DF5E757007B394F /* Decoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A66710DF5E757007B394F /* Decoder.m */; };
+ 855A668F0DF5E757007B394F /* Decoder.mm in Sources */ = {isa = PBXBuildFile; fileRef = 855A66710DF5E757007B394F /* Decoder.mm */; };
855A66900DF5E757007B394F /* ZXingAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A66730DF5E757007B394F /* ZXingAppDelegate.m */; };
855A66910DF5E757007B394F /* ParsedResult.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A66750DF5E757007B394F /* ParsedResult.m */; };
855A66920DF5E757007B394F /* NSString+HTML.m in Sources */ = {isa = PBXBuildFile; fileRef = 855A66770DF5E757007B394F /* NSString+HTML.m */; };
@@ -181,6 +181,8 @@
86C045D81127E58E00F3F43B /* UPCAReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86C045C81127E58E00F3F43B /* UPCAReader.cpp */; };
86C045D91127E58E00F3F43B /* UPCEANReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86C045CA1127E58E00F3F43B /* UPCEANReader.cpp */; };
86C045DA1127E58E00F3F43B /* UPCEReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86C045CC1127E58E00F3F43B /* UPCEReader.cpp */; };
+ 8B2B9BE6118FB42D00437315 /* FormatReader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8B2B9BE3118FB42D00437315 /* FormatReader.mm */; };
+ 8B2B9BE7118FB42D00437315 /* MultiFormatReader.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8B2B9BE4118FB42D00437315 /* MultiFormatReader.mm */; };
AD38DE961154C8D2006BD46A /* DataMatrixReader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD38DE821154C8D2006BD46A /* DataMatrixReader.cpp */; };
AD38DE971154C8D2006BD46A /* BitMatrixParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD38DE851154C8D2006BD46A /* BitMatrixParser.cpp */; };
AD38DE981154C8D2006BD46A /* DataBlock.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AD38DE871154C8D2006BD46A /* DataBlock.cpp */; };
@@ -319,7 +321,7 @@
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D6058910D05DD3D006BFB54 /* Barcodes.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Barcodes.app; sourceTree = BUILT_PRODUCTS_DIR; };
1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
- 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = main.m; sourceTree = "<group>"; };
+ 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.objc; fileEncoding = 4; path = main.m; sourceTree = "<group>"; };
32CA4F630368D1EE00C91783 /* ZXing_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZXing_Prefix.pch; sourceTree = "<group>"; };
85096CCE0E06D45400D660F9 /* SMSAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SMSAction.h; sourceTree = "<group>"; };
85096CCF0E06D45400D660F9 /* SMSAction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SMSAction.m; sourceTree = "<group>"; };
@@ -339,13 +341,13 @@
8514EA6F0DF88C9E00EE78D3 /* ReedSolomonTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ReedSolomonTest.h; sourceTree = "<group>"; };
8514EA720DF88C9E00EE78D3 /* DataMaskTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataMaskTest.cpp; sourceTree = "<group>"; };
8514EA730DF88C9E00EE78D3 /* DataMaskTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataMaskTest.h; sourceTree = "<group>"; };
- 8514EA740DF88C9E00EE78D3 /* ErrorCorrectionLevelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorCorrectionLevelTest.cpp; sourceTree = "<group>"; };
+ 8514EA740DF88C9E00EE78D3 /* ErrorCorrectionLevelTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ErrorCorrectionLevelTest.cpp; path = ../ErrorCorrectionLevelTest.cpp; sourceTree = "<group>"; };
8514EA750DF88C9E00EE78D3 /* ErrorCorrectionLevelTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorCorrectionLevelTest.h; sourceTree = "<group>"; };
- 8514EA760DF88C9E00EE78D3 /* FormatInformationTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormatInformationTest.cpp; sourceTree = "<group>"; };
+ 8514EA760DF88C9E00EE78D3 /* FormatInformationTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FormatInformationTest.cpp; path = ../FormatInformationTest.cpp; sourceTree = "<group>"; };
8514EA770DF88C9E00EE78D3 /* FormatInformationTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatInformationTest.h; sourceTree = "<group>"; };
8514EA780DF88C9E00EE78D3 /* ModeTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ModeTest.cpp; sourceTree = "<group>"; };
8514EA790DF88C9E00EE78D3 /* ModeTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModeTest.h; sourceTree = "<group>"; };
- 8514EA7A0DF88C9E00EE78D3 /* VersionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = VersionTest.cpp; sourceTree = "<group>"; };
+ 8514EA7A0DF88C9E00EE78D3 /* VersionTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VersionTest.cpp; path = ../VersionTest.cpp; sourceTree = "<group>"; };
8514EA7B0DF88C9E00EE78D3 /* VersionTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionTest.h; sourceTree = "<group>"; };
8514EA7C0DF88C9E00EE78D3 /* TestRunner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TestRunner.cpp; sourceTree = "<group>"; };
8514EB190DF8A52700EE78D3 /* libzxingcore.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libzxingcore.a; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -400,7 +402,7 @@
855A666E0DF5E757007B394F /* DecoderViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DecoderViewController.m; sourceTree = "<group>"; };
855A666F0DF5E757007B394F /* DecoderDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecoderDelegate.h; sourceTree = "<group>"; };
855A66700DF5E757007B394F /* Decoder.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = Decoder.h; sourceTree = "<group>"; };
- 855A66710DF5E757007B394F /* Decoder.m */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = Decoder.m; sourceTree = "<group>"; };
+ 855A66710DF5E757007B394F /* Decoder.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = Decoder.mm; sourceTree = "<group>"; };
855A66720DF5E757007B394F /* ZXingAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZXingAppDelegate.h; sourceTree = "<group>"; };
855A66730DF5E757007B394F /* ZXingAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZXingAppDelegate.m; sourceTree = "<group>"; };
855A66740DF5E757007B394F /* ParsedResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ParsedResult.h; sourceTree = "<group>"; };
@@ -663,6 +665,9 @@
86C045CB1127E58E00F3F43B /* UPCEANReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UPCEANReader.h; sourceTree = "<group>"; };
86C045CC1127E58E00F3F43B /* UPCEReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UPCEReader.cpp; sourceTree = "<group>"; };
86C045CD1127E58E00F3F43B /* UPCEReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UPCEReader.h; sourceTree = "<group>"; };
+ 8B2B9BE3118FB42D00437315 /* FormatReader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FormatReader.mm; sourceTree = "<group>"; };
+ 8B2B9BE4118FB42D00437315 /* MultiFormatReader.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MultiFormatReader.mm; sourceTree = "<group>"; };
+ 8B2B9BE5118FB42D00437315 /* FormatReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormatReader.h; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
AD38DE821154C8D2006BD46A /* DataMatrixReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DataMatrixReader.cpp; sourceTree = "<group>"; };
AD38DE831154C8D2006BD46A /* DataMatrixReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DataMatrixReader.h; sourceTree = "<group>"; };
@@ -824,6 +829,9 @@
85D937260E11064700B785E0 /* ScanViewController.m */,
85B1D7ED0E18EB6700514A6A /* ScanCell.h */,
85B1D7EE0E18EB6700514A6A /* ScanCell.m */,
+ 8B2B9BE3118FB42D00437315 /* FormatReader.mm */,
+ 8B2B9BE4118FB42D00437315 /* MultiFormatReader.mm */,
+ 8B2B9BE5118FB42D00437315 /* FormatReader.h */,
855A66520DF5E757007B394F /* ArchiveController.h */,
855A66510DF5E757007B394F /* ArchiveController.m */,
855A66530DF5E757007B394F /* Database.h */,
@@ -832,7 +840,7 @@
855A666E0DF5E757007B394F /* DecoderViewController.m */,
855A666F0DF5E757007B394F /* DecoderDelegate.h */,
855A66700DF5E757007B394F /* Decoder.h */,
- 855A66710DF5E757007B394F /* Decoder.m */,
+ 855A66710DF5E757007B394F /* Decoder.mm */,
855A66720DF5E757007B394F /* ZXingAppDelegate.h */,
855A66730DF5E757007B394F /* ZXingAppDelegate.m */,
855A66760DF5E757007B394F /* NSString+HTML.h */,
@@ -1821,7 +1829,7 @@
855A668C0DF5E757007B394F /* TelParsedResult.m in Sources */,
855A668D0DF5E757007B394F /* TextParsedResult.m in Sources */,
855A668E0DF5E757007B394F /* DecoderViewController.m in Sources */,
- 855A668F0DF5E757007B394F /* Decoder.m in Sources */,
+ 855A668F0DF5E757007B394F /* Decoder.mm in Sources */,
855A66900DF5E757007B394F /* ZXingAppDelegate.m in Sources */,
855A66910DF5E757007B394F /* ParsedResult.m in Sources */,
855A66920DF5E757007B394F /* NSString+HTML.m in Sources */,
@@ -1872,6 +1880,8 @@
AD38DE9C1154C8D2006BD46A /* Detector.cpp in Sources */,
AD38DE9D1154C8D2006BD46A /* MonochromeRectangleDetector.cpp in Sources */,
AD38DE9E1154C8D2006BD46A /* Version.cpp in Sources */,
+ 8B2B9BE6118FB42D00437315 /* FormatReader.mm in Sources */,
+ 8B2B9BE7118FB42D00437315 /* MultiFormatReader.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -2168,10 +2178,20 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
+ GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+ GCC_WARN_MISSING_PARENTHESES = NO;
+ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_SHADOW = YES;
+ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = iphoneos2.2.1;
+ SDKROOT = iphoneos3.1.2;
};
name = "AdHoc Distribution";
};
@@ -2233,6 +2253,10 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
+ GCC_WARN_SHADOW = NO;
+ HEADER_SEARCH_PATHS = "../cpp/core/tests/cppunit-1.12.1/include";
INSTALL_PATH = /usr/local/lib;
PREBINDING = NO;
PRODUCT_NAME = CppUnit;
@@ -2243,18 +2267,11 @@
8555301E0E64248400C7B5DE /* AdHoc Distribution */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(NATIVE_ARCH)";
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
- GCC_MODEL_TUNING = G5;
- INSTALL_PATH = /usr/local/bin;
- ONLY_ACTIVE_ARCH = YES;
- PREBINDING = NO;
+ HEADER_SEARCH_PATHS = (
+ "../cpp/core/tests/cppunit-1.12.1/include",
+ ../cpp/core/src,
+ );
PRODUCT_NAME = "zxingcore-tests";
- SDKROOT = macosx10.5;
- ZERO_LINK = NO;
};
name = "AdHoc Distribution";
};
@@ -2309,7 +2326,10 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
- HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../cpp/core/tests/cppunit-1.12.1/include";
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
+ GCC_WARN_SHADOW = NO;
+ HEADER_SEARCH_PATHS = "../cpp/core/tests/cppunit-1.12.1/include";
INSTALL_PATH = /usr/local/lib;
PREBINDING = NO;
PRODUCT_NAME = CppUnit;
@@ -2324,6 +2344,10 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
+ GCC_WARN_SHADOW = NO;
+ HEADER_SEARCH_PATHS = "../cpp/core/tests/cppunit-1.12.1/include";
INSTALL_PATH = /usr/local/lib;
PREBINDING = NO;
PRODUCT_NAME = CppUnit;
@@ -2334,37 +2358,23 @@
856EAB7B0E1CE8AA00B2E1C7 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(NATIVE_ARCH)";
- COPY_PHASE_STRIP = NO;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../cpp/core/tests/cppunit-1.12.1/include";
- INSTALL_PATH = /usr/local/bin;
- ONLY_ACTIVE_ARCH = YES;
+ HEADER_SEARCH_PATHS = (
+ "../cpp/core/tests/cppunit-1.12.1/include",
+ ../cpp/core/src,
+ );
PREBINDING = NO;
PRODUCT_NAME = "zxingcore-tests";
- SDKROOT = macosx10.5;
};
name = Debug;
};
856EAB7C0E1CE8AA00B2E1C7 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(NATIVE_ARCH)";
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
- GCC_MODEL_TUNING = G5;
- INSTALL_PATH = /usr/local/bin;
- ONLY_ACTIVE_ARCH = YES;
- PREBINDING = NO;
+ HEADER_SEARCH_PATHS = (
+ "../cpp/core/tests/cppunit-1.12.1/include",
+ ../cpp/core/src,
+ );
PRODUCT_NAME = "zxingcore-tests";
- SDKROOT = macosx10.5;
- ZERO_LINK = NO;
};
name = Release;
};
@@ -2373,11 +2383,21 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
+ GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+ GCC_WARN_MISSING_PARENTHESES = NO;
+ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_SHADOW = YES;
+ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
- SDKROOT = iphoneos2.2.1;
+ SDKROOT = iphoneos3.1.2;
};
name = Test;
};
@@ -2409,6 +2429,7 @@
PREBINDING = NO;
PRODUCT_NAME = zxingcore;
SCAN_ALL_SOURCE_FILES_FOR_INCLUDES = YES;
+ SDKROOT = macosx10.5;
};
name = Test;
};
@@ -2429,6 +2450,7 @@
GCC_DYNAMIC_NO_PIC = NO;
GCC_OPTIMIZATION_LEVEL = 0;
PRODUCT_NAME = "Test All";
+ SDKROOT = "Mac OS X 10.5";
};
name = Test;
};
@@ -2441,29 +2463,29 @@
GCC_ENABLE_FIX_AND_CONTINUE = YES;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 0;
- HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../cpp/core/tests/cppunit-1.12.1/include";
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
+ GCC_WARN_SHADOW = NO;
+ HEADER_SEARCH_PATHS = "../cpp/core/tests/cppunit-1.12.1/include";
INSTALL_PATH = /usr/local/lib;
PREBINDING = NO;
PRODUCT_NAME = CppUnit;
+ SDKROOT = macosx10.5;
};
name = Test;
};
856EAC000E1CF73600B2E1C7 /* Test */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(NATIVE_ARCH)";
- COPY_PHASE_STRIP = NO;
- GCC_DYNAMIC_NO_PIC = NO;
- GCC_ENABLE_FIX_AND_CONTINUE = YES;
- GCC_MODEL_TUNING = G5;
- GCC_OPTIMIZATION_LEVEL = 0;
- HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/../cpp/core/tests/cppunit-1.12.1/include";
- INSTALL_PATH = /usr/local/bin;
- ONLY_ACTIVE_ARCH = YES;
- PREBINDING = NO;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
+ GCC_WARN_SHADOW = NO;
+ HEADER_SEARCH_PATHS = (
+ "../cpp/core/tests/cppunit-1.12.1/include",
+ ../cpp/core/src,
+ );
PRODUCT_NAME = "zxingcore-tests";
- SDKROOT = macosx10.5;
+ SDKROOT = "";
};
name = Test;
};
@@ -2472,10 +2494,20 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
+ GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+ GCC_WARN_MISSING_PARENTHESES = NO;
+ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_SHADOW = YES;
+ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = iphoneos2.2.1;
+ SDKROOT = iphoneos3.1.2;
};
name = Distribution;
};
@@ -2537,6 +2569,10 @@
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_MODEL_TUNING = G5;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = NO;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = NO;
+ GCC_WARN_SHADOW = NO;
+ HEADER_SEARCH_PATHS = "../cpp/core/tests/cppunit-1.12.1/include";
INSTALL_PATH = /usr/local/lib;
PREBINDING = NO;
PRODUCT_NAME = CppUnit;
@@ -2547,18 +2583,11 @@
858459740E64181200211F1B /* Distribution */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(NATIVE_ARCH)";
- COPY_PHASE_STRIP = YES;
- DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
- GCC_ENABLE_FIX_AND_CONTINUE = NO;
- GCC_MODEL_TUNING = G5;
- INSTALL_PATH = /usr/local/bin;
- ONLY_ACTIVE_ARCH = YES;
- PREBINDING = NO;
+ HEADER_SEARCH_PATHS = (
+ "../cpp/core/tests/cppunit-1.12.1/include",
+ ../cpp/core/src,
+ );
PRODUCT_NAME = "zxingcore-tests";
- SDKROOT = macosx10.5;
- ZERO_LINK = NO;
};
name = Distribution;
};
@@ -2567,11 +2596,22 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_SYMBOLS_PRIVATE_EXTERN = YES;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
+ GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+ GCC_WARN_MISSING_PARENTHESES = NO;
+ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_SHADOW = YES;
+ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
ONLY_ACTIVE_ARCH = YES;
PREBINDING = NO;
- SDKROOT = iphoneos2.2.1;
+ SDKROOT = iphoneos3.1.2;
};
name = Debug;
};
@@ -2580,10 +2620,20 @@
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_BIT)";
GCC_C_LANGUAGE_STANDARD = c99;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_CHECK_SWITCH_STATEMENTS = YES;
+ GCC_WARN_EFFECTIVE_CPLUSPLUS_VIOLATIONS = YES;
+ GCC_WARN_HIDDEN_VIRTUAL_FUNCTIONS = YES;
+ GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES;
+ GCC_WARN_MISSING_PARENTHESES = NO;
+ GCC_WARN_NON_VIRTUAL_DESTRUCTOR = YES;
+ GCC_WARN_SHADOW = YES;
+ GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
PREBINDING = NO;
- SDKROOT = iphoneos2.2.1;
+ SDKROOT = iphoneos3.1.2;
};
name = Release;
};
diff --git a/iphone/main.m b/iphone/main.m
index 8a87553..a23f47b 100644
--- a/iphone/main.m
+++ b/iphone/main.m
@@ -23,16 +23,6 @@
#import <UIKit/UIKit.h>
-#include <iostream>
-
-class Exception {
-public:
- Exception() {}
- virtual ~Exception() { }
-};
-
-using namespace std;
-
int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
--
Multi-format 1D/2D barcode image processing library
More information about the Pkg-google-commits
mailing list