+
+namespace zxing {
+/**
+ * This provides an easy abstraction to read bits at a time from a sequence of bytes, where the
+ * number of bits read is not often a multiple of 8.
+ *
+ * This class is not thread-safe.
+ *
+ * @author srowen@google.com (Sean Owen)
+ * @author christian.brunschen@gmail.com (Christian Brunschen)
+ */
+class BitSource : public Counted {
+ typedef unsigned char byte;
+private:
+ ArrayRef bytes_;
+ int byteOffset_;
+ int bitOffset_;
+public:
+ /**
+ * @param bytes bytes from which this will read bits. Bits will be read from the first byte first.
+ * Bits are read within a byte from most-significant to least-significant bit.
+ */
+ BitSource(ArrayRef &bytes) :
+ bytes_(bytes), byteOffset_(0), bitOffset_(0) {
+ }
+
+
+ /**
+ * @param numBits number of bits to read
+ * @return int representing the bits read. The bits will appear as the least-significant
+ * bits of the int
+ * @throws IllegalArgumentException if numBits isn't in [1,32]
+ */
+ int readBits(int numBits);
+
+ /**
+ * @return number of bits that can be read successfully
+ */
+ int available();
+};
+
+}
+
+#endif // __BIT_SOURCE_H__
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/Counted.cpp b/symbian/ZXingBarcodeReader/group/zxing/common/Counted.cpp
new file mode 100644
index 000000000..fb2a99b06
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/Counted.cpp
@@ -0,0 +1,32 @@
+/*
+ * Counted.cpp
+ * zxing
+ *
+ * Created by Christian Brunschen on 07/05/2008.
+ * Copyright 2008 Google UK. All rights reserved.
+ *
+ * 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.
+ */
+
+#include
+
+namespace zxing {
+
+using namespace std;
+
+template
+ostream& operator<<(ostream &out, Ref& ref) {
+ out << "Ref(" << (ref.object_ ? (*ref.object_) : "NULL") << ")";
+ return out;
+}
+}
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/Counted.h b/symbian/ZXingBarcodeReader/group/zxing/common/Counted.h
new file mode 100644
index 000000000..dd0f84552
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/Counted.h
@@ -0,0 +1,202 @@
+#ifndef __COUNTED_H__
+#define __COUNTED_H__
+
+/*
+ * Counted.h
+ * zxing
+ *
+ * Created by Christian Brunschen on 07/05/2008.
+ * Copyright 2008 Google UK. All rights reserved.
+ *
+ * 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.
+ */
+
+//#define DEBUG_COUNTING
+//using namespace std;
+
+#include
+
+#ifdef DEBUG_COUNTING
+#include
+#endif
+
+namespace zxing {
+
+/* base class for reference-counted objects */
+class Counted {
+private:
+ unsigned int count_;
+public:
+ Counted() :
+ count_(0) {
+#ifdef DEBUG_COUNTING
+ cout << "instantiating " << typeid(*this).name() << " " << this <<
+ " @ " << count_ << "\n";
+#endif
+ }
+ virtual ~Counted() {
+ }
+ virtual Counted *retain() {
+#ifdef DEBUG_COUNTING
+ cout << "retaining " << typeid(*this).name() << " " << this <<
+ " @ " << count_;
+#endif
+ count_++;
+#ifdef DEBUG_COUNTING
+ cout << "->" << count_ << "\n";
+#endif
+ return this;
+ }
+ virtual void release() {
+#ifdef DEBUG_COUNTING
+ cout << "releasing " << typeid(*this).name() << " " << this <<
+ " @ " << count_;
+#endif
+ if (count_ == 0 || count_ == 54321) {
+#ifdef DEBUG_COUNTING
+ cout << "\nOverreleasing already-deleted object " << this << "!!!\n";
+#endif
+ throw 4711;
+ }
+ count_--;
+#ifdef DEBUG_COUNTING
+ cout << "->" << count_ << "\n";
+#endif
+ if (count_ == 0) {
+#ifdef DEBUG_COUNTING
+ cout << "deleting " << typeid(*this).name() << " " << this << "\n";
+#endif
+ count_ = 0xDEADF001;
+ delete this;
+ }
+ }
+
+
+ /* return the current count for denugging purposes or similar */
+ int count() const {
+ return count_;
+ }
+};
+
+/* counting reference to reference-counted objects */
+template class Ref {
+private:
+public:
+ T *object_;
+ explicit Ref(T *o = 0) :
+ object_(0) {
+#ifdef DEBUG_COUNTING
+ cout << "instantiating Ref " << this << " from pointer" << o << "\n";
+#endif
+ reset(o);
+ }
+
+ explicit Ref(const T &o) :
+ object_(0) {
+#ifdef DEBUG_COUNTING
+ cout << "instantiating Ref " << this << " from reference\n";
+#endif
+ reset(const_cast(&o));
+ }
+
+ Ref(const Ref &other) :
+ object_(0) {
+#ifdef DEBUG_COUNTING
+ cout << "instantiating Ref " << this << " from Ref " << &other << "\n";
+#endif
+ reset(other.object_);
+ }
+
+ template
+ Ref(const Ref &other) :
+ object_(0) {
+#ifdef DEBUG_COUNTING
+ cout << "instantiating Ref " << this << " from reference\n";
+#endif
+ reset(other.object_);
+ }
+
+ ~Ref() {
+#ifdef DEBUG_COUNTING
+ cout << "destroying Ref " << this << " with " <<
+ (object_ ? typeid(*object_).name() : "NULL") << " " << object_ << "\n";
+#endif
+ if (object_) {
+ object_->release();
+ }
+ }
+
+ void reset(T *o) {
+#ifdef DEBUG_COUNTING
+ cout << "resetting Ref " << this << " from " <<
+ (object_ ? typeid(*object_).name() : "NULL") << " " << object_ <<
+ " to " << (o ? typeid(*o).name() : "NULL") << " " << o << "\n";
+#endif
+ if (o) {
+ o->retain();
+ }
+ if (object_ != 0) {
+ object_->release();
+ }
+ object_ = o;
+ }
+ Ref& operator=(const Ref &other) {
+ reset(other.object_);
+ return *this;
+ }
+ template
+ Ref& operator=(const Ref &other) {
+ reset(other.object_);
+ return *this;
+ }
+ Ref& operator=(T* o) {
+ reset(o);
+ return *this;
+ }
+ template
+ Ref& operator=(Y* o) {
+ reset(o);
+ return *this;
+ }
+
+ T& operator*() {
+ return *object_;
+ }
+ T* operator->() {
+ return object_;
+ }
+ operator T*() {
+ return object_;
+ }
+
+ bool operator==(const int x) {
+ return x == 0 ? object_ == 0 : false;
+ }
+ bool operator==(const Ref &other) const {
+ return object_ == other.object_ || *object_ == *(other.object_);
+ }
+ template
+ bool operator==(const Ref &other) const {
+ return object_ == other.object_ || *object_ == *(other.object_);
+ }
+
+ bool operator!=(const int x) {
+ return x == 0 ? object_ != 0 : true;
+ }
+
+ template
+ friend std::ostream& operator<<(std::ostream &out, Ref& ref);
+};
+}
+
+#endif // __COUNTED_H__
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/DecoderResult.cpp b/symbian/ZXingBarcodeReader/group/zxing/common/DecoderResult.cpp
new file mode 100644
index 000000000..86b11f810
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/DecoderResult.cpp
@@ -0,0 +1,37 @@
+/*
+ * DecoderResult.cpp
+ * zxing
+ *
+ * Created by Christian Brunschen on 20/05/2008.
+ * Copyright 2008 ZXing authors All rights reserved.
+ *
+ * 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.
+ */
+
+#include
+
+namespace zxing {
+
+DecoderResult::DecoderResult(ArrayRef rawBytes, Ref text) :
+ rawBytes_(rawBytes), text_(text) {
+}
+
+ArrayRef DecoderResult::getRawBytes() {
+ return rawBytes_;
+}
+
+Ref DecoderResult::getText() {
+ return text_;
+}
+
+}
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/DecoderResult.h b/symbian/ZXingBarcodeReader/group/zxing/common/DecoderResult.h
new file mode 100644
index 000000000..1e3e42b2a
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/DecoderResult.h
@@ -0,0 +1,44 @@
+#ifndef __DECODER_RESULT_H__
+#define __DECODER_RESULT_H__
+
+/*
+ * DecoderResult.h
+ * zxing
+ *
+ * Created by Christian Brunschen on 20/05/2008.
+ * Copyright 2008 ZXing authors All rights reserved.
+ *
+ * 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.
+ */
+
+#include
+#include
+#include
+#include
+
+namespace zxing {
+
+class DecoderResult : public Counted {
+private:
+ ArrayRef rawBytes_;
+ Ref text_;
+
+public:
+ DecoderResult(ArrayRef rawBytes, Ref text);
+ ArrayRef getRawBytes();
+ Ref getText();
+};
+
+}
+
+#endif // __DECODER_RESULT_H__
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/DetectorResult.cpp b/symbian/ZXingBarcodeReader/group/zxing/common/DetectorResult.cpp
new file mode 100644
index 000000000..a314cfe79
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/DetectorResult.cpp
@@ -0,0 +1,41 @@
+/*
+ * DetectorResult.cpp
+ * zxing
+ *
+ * Created by Christian Brunschen on 14/05/2008.
+ * Copyright 2008 ZXing authors All rights reserved.
+ *
+ * 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.
+ */
+
+#include
+
+namespace zxing {
+
+DetectorResult::DetectorResult(Ref bits, std::vector[ > points, Ref transform) :
+ bits_(bits), points_(points), transform_(transform) {
+}
+
+Ref DetectorResult::getBits() {
+ return bits_;
+}
+
+std::vector][ > DetectorResult::getPoints() {
+ return points_;
+}
+
+Ref DetectorResult::getTransform() {
+ return transform_;
+}
+
+}
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/DetectorResult.h b/symbian/ZXingBarcodeReader/group/zxing/common/DetectorResult.h
new file mode 100644
index 000000000..ba8f9a821
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/DetectorResult.h
@@ -0,0 +1,47 @@
+#ifndef __DETECTOR_RESULT_H__
+#define __DETECTOR_RESULT_H__
+
+/*
+ * DetectorResult.h
+ * zxing
+ *
+ * Created by Christian Brunschen on 14/05/2008.
+ * Copyright 2008 ZXing authors All rights reserved.
+ *
+ * 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.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+
+namespace zxing {
+
+class DetectorResult : public Counted {
+private:
+ Ref bits_;
+ std::vector][ > points_;
+ Ref transform_;
+
+public:
+ DetectorResult(Ref bits, std::vector][ > points, Ref transform);
+ Ref getBits();
+ std::vector][ > getPoints();
+ Ref getTransform();
+};
+}
+
+#endif // __DETECTOR_RESULT_H__
diff --git a/symbian/ZXingBarcodeReader/group/zxing/common/EdgeDetector.cpp b/symbian/ZXingBarcodeReader/group/zxing/common/EdgeDetector.cpp
new file mode 100644
index 000000000..3f0b403cc
--- /dev/null
+++ b/symbian/ZXingBarcodeReader/group/zxing/common/EdgeDetector.cpp
@@ -0,0 +1,190 @@
+/*
+ * EdgeDetector.cpp
+ * zxing
+ *
+ * Created by Ralf Kistner on 7/12/2009.
+ * Copyright 2008 ZXing authors All rights reserved.
+ *
+ * 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.
+ */
+
+#include
+#include ]