X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=cpp%2Fcore%2Fsrc%2Fzxing%2Foned%2FMultiFormatOneDReader.cpp;h=904601eb6196eb5300461dce6a4018d2d4d5d48a;hb=4c7d60a47387c3b95ce82e35a6c61ba3243f64f5;hp=cfb4b10a79c24efd0aaecfded38322dda7773312;hpb=d39dc833bf39314664b24470f2f572e8534b9379;p=zxing.git diff --git a/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp b/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp index cfb4b10a..904601eb 100644 --- a/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp +++ b/cpp/core/src/zxing/oned/MultiFormatOneDReader.cpp @@ -28,18 +28,34 @@ namespace zxing { namespace oned { - MultiFormatOneDReader::MultiFormatOneDReader(){ - readers = new std::vector(); - readers->push_back(new MultiFormatUPCEANReader()); - readers->push_back(new Code39Reader()); - readers->push_back(new Code128Reader()); - readers->push_back(new ITFReader()); + MultiFormatOneDReader::MultiFormatOneDReader(DecodeHints hints) : readers() { + if (hints.containsFormat(BarcodeFormat_EAN_13) || + hints.containsFormat(BarcodeFormat_EAN_8) || + hints.containsFormat(BarcodeFormat_UPC_A) || + hints.containsFormat(BarcodeFormat_UPC_E)) { + readers.push_back(Ref(new MultiFormatUPCEANReader(hints))); + } + if (hints.containsFormat(BarcodeFormat_CODE_39)) { + readers.push_back(Ref(new Code39Reader())); + } + if (hints.containsFormat(BarcodeFormat_CODE_128)) { + readers.push_back(Ref(new Code128Reader())); + } + if (hints.containsFormat(BarcodeFormat_ITF)) { + readers.push_back(Ref(new ITFReader())); + } + if (readers.size() == 0) { + readers.push_back(Ref(new MultiFormatUPCEANReader(hints))); + readers.push_back(Ref(new Code39Reader())); + readers.push_back(Ref(new Code128Reader())); + readers.push_back(Ref(new ITFReader())); + } } Ref MultiFormatOneDReader::decodeRow(int rowNumber, Ref 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 +64,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 +}