Issue 489 update the port
[zxing.git] / cpp / core / src / zxing / qrcode / Version.cpp
index 5e63c82..62c2acf 100644 (file)
@@ -20,9 +20,9 @@
 
 #include <zxing/qrcode/Version.h>
 #include <zxing/qrcode/FormatInformation.h>
-#include <cstdarg>
 #include <limits>
 #include <iostream>
+#include <cstdarg>
 
 namespace zxing {
 namespace qrcode {
@@ -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);
 }
 
@@ -78,7 +76,7 @@ int Version::getVersionNumber() {
   return versionNumber_;
 }
 
-valarray<int> &Version::getAlignmentPatternCenters() {
+vector<int> &Version::getAlignmentPatternCenters() {
   return alignmentPatternCenters_;
 }
 
@@ -102,16 +100,16 @@ 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");
   }
 
   return VERSIONS[versionNumber - 1];
 }
 
-Version::Version(int versionNumber, valarray<int> *alignmentPatternCenters, ECBlocks *ecBlocks1, ECBlocks *ecBlocks2,
+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;
@@ -207,10 +205,10 @@ Ref<BitMatrix> Version::buildFunctionPattern() {
   return functionPattern;
 }
 
-static valarray<int> *intArray(size_t n...) {
+static vector<int> *intArray(size_t n...) {
   va_list ap;
   va_start(ap, n);
-  valarray<int> *result = new valarray<int>(n);
+  vector<int> *result = new vector<int>(n);
   for (size_t i = 0; i < n; i++) {
     (*result)[i] = va_arg(ap, int);
   }