port r2064 to C++

git-svn-id: https://zxing.googlecode.com/svn/trunk@2203 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
smparkes@smparkes.net 2012-02-17 21:05:44 +00:00
parent 8fde7556cf
commit 3b4a8bcd52
2 changed files with 6 additions and 5 deletions

View file

@ -16,8 +16,8 @@
*/
#include <zxing/common/CharacterSetECI.h>
#include <sstream>
#include <zxing/common/IllegalArgumentException.h>
#include <zxing/FormatException.h>
using std::string;
@ -94,9 +94,7 @@ void CharacterSetECI::addCharacterSet(int const* values, char const* const* name
CharacterSetECI* CharacterSetECI::getCharacterSetECIByValue(int value) {
if (value < 0 || value >= 900) {
std::ostringstream oss;
oss << "Bad ECI value: " << value;
throw IllegalArgumentException(oss.str().c_str());
throw FormatException();
}
return VALUE_TO_ECI[value];
}

View file

@ -275,6 +275,9 @@ void DecodedBitStreamParser::decodeAlphanumericSegment(Ref<BitSource> bits_,
ostringstream bytes;
// Read two characters at a time
while (count > 1) {
if (bits.available() < 11) {
throw FormatException();
}
int nextTwoCharsBits = bits.readBits(11);
bytes << toAlphaNumericChar(nextTwoCharsBits / 45);
bytes << toAlphaNumericChar(nextTwoCharsBits % 45);
@ -324,7 +327,7 @@ namespace {
int secondThirdBytes = bits.readBits(16);
return ((firstByte & 0x1F) << 16) | secondThirdBytes;
}
throw IllegalArgumentException("Bad ECI bits starting with byte " + firstByte);
throw FormatException();
}
}