C++ for r2690

git-svn-id: https://zxing.googlecode.com/svn/trunk@2691 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2013-04-25 19:49:15 +00:00
parent 9d1497fd27
commit a3228a81a8
3 changed files with 44 additions and 3 deletions

View file

@ -0,0 +1,35 @@
// -*- mode:c++; tab-width:2; indent-tabs-mode:nil; c-basic-offset:2 -*-
#ifndef __ILLEGAL_STATE_EXCEPTION_H__
#define __ILLEGAL_STATE_EXCEPTION_H__
/*
* Copyright 20011 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may illegal 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 <zxing/ReaderException.h>
namespace zxing {
class IllegalStateException : public ReaderException {
public:
IllegalStateException() throw() {}
IllegalStateException(const char *msg) throw() : ReaderException(msg) {}
~IllegalStateException() throw() {}
};
}
#endif // __ILLEGAL_STATE_EXCEPTION_H__

View file

@ -22,13 +22,14 @@
#include <zxing/common/reedsolomon/ReedSolomonDecoder.h> #include <zxing/common/reedsolomon/ReedSolomonDecoder.h>
#include <zxing/common/reedsolomon/ReedSolomonException.h> #include <zxing/common/reedsolomon/ReedSolomonException.h>
#include <zxing/common/IllegalArgumentException.h> #include <zxing/common/IllegalArgumentException.h>
#include <zxing/IllegalStateException.h>
using namespace std; // remove using std::vector;
using zxing::Ref; using zxing::Ref;
using zxing::ArrayRef; using zxing::ArrayRef;
using zxing::ReedSolomonDecoder; using zxing::ReedSolomonDecoder;
using zxing::GenericGFPoly; using zxing::GenericGFPoly;
using zxing::IllegalStateException;
// VC++ // VC++
using zxing::GenericGF; using zxing::GenericGF;
@ -107,6 +108,10 @@ vector<Ref<GenericGFPoly> > ReedSolomonDecoder::runEuclideanAlgorithm(Ref<Generi
} }
t = q->multiply(tLast)->addOrSubtract(tLastLast); t = q->multiply(tLast)->addOrSubtract(tLastLast);
if (r->getDegree() >= rLast->getDegree()) {
throw IllegalStateException("Division algorithm failed to reduce polynomial?");
}
} }
int sigmaTildeAtZero = t->getCoefficient(0); int sigmaTildeAtZero = t->getCoefficient(0);

View file

@ -38,8 +38,9 @@ public:
ReedSolomonDecoder(Ref<GenericGF> fld); ReedSolomonDecoder(Ref<GenericGF> fld);
~ReedSolomonDecoder(); ~ReedSolomonDecoder();
void decode(ArrayRef<int> received, int twoS); void decode(ArrayRef<int> received, int twoS);
private:
std::vector<Ref<GenericGFPoly> > runEuclideanAlgorithm(Ref<GenericGFPoly> a, Ref<GenericGFPoly> b, int R); std::vector<Ref<GenericGFPoly> > runEuclideanAlgorithm(Ref<GenericGFPoly> a, Ref<GenericGFPoly> b, int R);
private:
ArrayRef<int> findErrorLocations(Ref<GenericGFPoly> errorLocator); ArrayRef<int> findErrorLocations(Ref<GenericGFPoly> errorLocator);
ArrayRef<int> findErrorMagnitudes(Ref<GenericGFPoly> errorEvaluator, ArrayRef<int> errorLocations); ArrayRef<int> findErrorMagnitudes(Ref<GenericGFPoly> errorEvaluator, ArrayRef<int> errorLocations);
}; };