From 2e6864282e65c55ff6809f5aaae011b31c3a361a Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Wed, 24 Feb 2016 18:20:51 -0800 Subject: Get rid of CBC_AutoPtr and use std::unique_ptr instead. Also fix IWYU in various fxbarcode headers. R=dsinclair@chromium.org Review URL: https://codereview.chromium.org/1734823002 . --- xfa/src/fxbarcode/BC_UtilRSS.cpp | 7 +- .../common/BC_CommonPerspectiveTransform.cpp | 11 ++- .../common/BC_GlobalHistogramBinarizer.cpp | 14 +-- .../fxbarcode/common/BC_GlobalHistogramBinarizer.h | 1 + .../fxbarcode/common/BC_WhiteRectangleDetector.cpp | 45 ++++----- .../common/reedsolomon/BC_ReedSolomon.cpp | 10 +- .../common/reedsolomon/BC_ReedSolomonDecoder.cpp | 108 +++++++++------------ .../common/reedsolomon/BC_ReedSolomonGF256Poly.cpp | 31 +++--- .../common/reedsolomon/BC_ReedSolomonGF256Poly.h | 3 + .../datamatrix/BC_DataMatrixBitMatrixParser.cpp | 7 +- .../datamatrix/BC_DataMatrixDataBlock.cpp | 5 +- .../fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp | 8 +- .../fxbarcode/datamatrix/BC_DataMatrixDecoder.h | 3 + .../fxbarcode/datamatrix/BC_DataMatrixDetector.cpp | 64 ++++++------ .../fxbarcode/datamatrix/BC_DataMatrixDetector.h | 2 + .../fxbarcode/datamatrix/BC_DataMatrixReader.cpp | 13 +-- xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h | 5 +- xfa/src/fxbarcode/oned/BC_OneDReader.h | 3 +- xfa/src/fxbarcode/oned/BC_OneDimReader.cpp | 8 +- xfa/src/fxbarcode/oned/BC_OneDimReader.h | 6 +- xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp | 7 +- xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h | 5 +- xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp | 14 +-- xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp | 16 +-- xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h | 8 +- xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp | 8 +- xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h | 6 +- xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp | 26 +++-- xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h | 5 +- xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp | 10 +- xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h | 2 + xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp | 13 +-- xfa/src/fxbarcode/qrcode/BC_QRDetector.h | 4 +- .../fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp | 8 +- .../fxbarcode/qrcode/BC_QRFinderPatternFinder.h | 2 + xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp | 12 ++- xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h | 4 +- xfa/src/fxbarcode/utils.h | 37 ------- 38 files changed, 269 insertions(+), 272 deletions(-) diff --git a/xfa/src/fxbarcode/BC_UtilRSS.cpp b/xfa/src/fxbarcode/BC_UtilRSS.cpp index 958f192358..dcc12e2268 100644 --- a/xfa/src/fxbarcode/BC_UtilRSS.cpp +++ b/xfa/src/fxbarcode/BC_UtilRSS.cpp @@ -22,6 +22,8 @@ #include "xfa/src/fxbarcode/BC_UtilRSS.h" +#include + #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/utils.h" @@ -32,9 +34,8 @@ CFX_Int32Array* CBC_UtilRSS::GetRssWidths(int32_t val, int32_t elements, int32_t maxWidth, FX_BOOL noNarrow) { - CFX_Int32Array* iTemp = new CFX_Int32Array; - iTemp->SetSize(elements); - CBC_AutoPtr widths(iTemp); + std::unique_ptr widths(new CFX_Int32Array); + widths->SetSize(elements); int32_t bar; int32_t narrowMask = 0; for (bar = 0; bar < elements - 1; bar++) { diff --git a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp index c0e982cb63..897d9537fd 100644 --- a/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp +++ b/xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.cpp @@ -20,8 +20,11 @@ * limitations under the License. */ -#include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h" + +#include + +#include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/utils.h" CBC_CommonPerspectiveTransform::CBC_CommonPerspectiveTransform(FX_FLOAT a11, @@ -61,9 +64,9 @@ CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral(FX_FLOAT x0, FX_FLOAT y2p, FX_FLOAT x3p, FX_FLOAT y3p) { - CBC_AutoPtr qToS( + std::unique_ptr qToS( QuadrilateralToSquare(x0, y0, x1, y1, x2, y2, x3, y3)); - CBC_AutoPtr sToQ( + std::unique_ptr sToQ( SquareToQuadrilateral(x0p, y0p, x1p, y1p, x2p, y2p, x3p, y3p)); return sToQ->Times(*(qToS.get())); } @@ -123,7 +126,7 @@ CBC_CommonPerspectiveTransform::QuadrilateralToSquare(FX_FLOAT x0, FX_FLOAT y2, FX_FLOAT x3, FX_FLOAT y3) { - CBC_AutoPtr temp1( + std::unique_ptr temp1( SquareToQuadrilateral(x0, y0, x1, y1, x2, y2, x3, y3)); return temp1->BuildAdjoint(); } diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp index 6c3920483c..8babc9c78f 100644 --- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp +++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.cpp @@ -20,11 +20,14 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" + +#include + #include "xfa/src/fxbarcode/BC_Binarizer.h" #include "xfa/src/fxbarcode/BC_LuminanceSource.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" #include "xfa/src/fxbarcode/utils.h" const int32_t LUMINANCE_BITS = 5; @@ -41,7 +44,7 @@ CBC_CommonBitArray* CBC_GlobalHistogramBinarizer::GetBlackRow( int32_t& e) { CBC_LuminanceSource* source = GetLuminanceSource(); int32_t width = source->GetWidth(); - CBC_AutoPtr result(new CBC_CommonBitArray(width)); + std::unique_ptr result(new CBC_CommonBitArray(width)); InitArrays(width); CFX_ByteArray* localLuminances = source->GetRow(y, m_luminance, e); if (e != BCExceptionNO) { @@ -75,9 +78,8 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) { CBC_LuminanceSource* source = GetLuminanceSource(); int32_t width = source->GetWidth(); int32_t height = source->GetHeight(); - CBC_CommonBitMatrix* BitMatrixTemp = new CBC_CommonBitMatrix(); - BitMatrixTemp->Init(width, height); - CBC_AutoPtr matrix(BitMatrixTemp); + std::unique_ptr matrix(new CBC_CommonBitMatrix()); + matrix->Init(width, height); InitArrays(width); CFX_Int32Array localBuckets; localBuckets.Copy(m_buckets); @@ -95,7 +97,7 @@ CBC_CommonBitMatrix* CBC_GlobalHistogramBinarizer::GetBlackMatrix(int32_t& e) { } int32_t blackPoint = EstimateBlackPoint(localBuckets, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr localLuminances(source->GetMatrix()); + std::unique_ptr localLuminances(source->GetMatrix()); for (y = 0; y < height; y++) { int32_t offset = y * width; for (int32_t x = 0; x < width; x++) { diff --git a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h index a74187e767..c0ffaaa28d 100644 --- a/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h +++ b/xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h @@ -8,6 +8,7 @@ #define XFA_SRC_FXBARCODE_COMMON_BC_GLOBALHISTOGRAMBINARIZER_H_ #include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/BC_Binarizer.h" class CBC_CommonBinarizer; class CBC_CommonBitArray; diff --git a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp index ed5899da37..cc1b435f00 100644 --- a/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp +++ b/xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.cpp @@ -20,9 +20,12 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" + +#include + #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" -#include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" #include "xfa/src/fxbarcode/utils.h" const int32_t CBC_WhiteRectangleDetector::INIT_SIZE = 30; @@ -124,53 +127,45 @@ CFX_PtrArray* CBC_WhiteRectangleDetector::Detect(int32_t& e) { } if (!sizeExceeded && atLeastOneBlackPointFoundOnBorder) { int32_t maxSize = right - left; - CBC_AutoPtr z(NULL); + std::unique_ptr z; for (int32_t i = 1; i < maxSize; i++) { - z = CBC_AutoPtr( - GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), - (FX_FLOAT)(left + i), (FX_FLOAT)(down))); - if (z.get()) { + z.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(down - i), + (FX_FLOAT)(left + i), (FX_FLOAT)(down))); + if (z) break; - } } if (z.get() == NULL) { e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_AutoPtr t(NULL); + std::unique_ptr t; for (int32_t j = 1; j < maxSize; j++) { - t = CBC_AutoPtr( - GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), - (FX_FLOAT)(left + j), (FX_FLOAT)up)); - if (t.get()) { + t.reset(GetBlackPointOnSegment((FX_FLOAT)left, (FX_FLOAT)(up + j), + (FX_FLOAT)(left + j), (FX_FLOAT)up)); + if (t) break; - } } if (t.get() == NULL) { e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_AutoPtr x(NULL); + std::unique_ptr x; for (int32_t k = 1; k < maxSize; k++) { - x = CBC_AutoPtr( - GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), - (FX_FLOAT)(right - k), (FX_FLOAT)up)); - if (x.get()) { + x.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(up + k), + (FX_FLOAT)(right - k), (FX_FLOAT)up)); + if (x) break; - } } if (x.get() == NULL) { e = BCExceptionNotFound; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_AutoPtr y(NULL); + std::unique_ptr y; for (int32_t m = 1; m < maxSize; m++) { - y = CBC_AutoPtr( - GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), - (FX_FLOAT)(right - m), (FX_FLOAT)down)); - if (y.get()) { + y.reset(GetBlackPointOnSegment((FX_FLOAT)right, (FX_FLOAT)(down - m), + (FX_FLOAT)(right - m), (FX_FLOAT)down)); + if (y) break; - } } if (y.get() == NULL) { e = BCExceptionNotFound; diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp index 78c5bdc5e2..3e6de6ef06 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.cpp @@ -21,6 +21,9 @@ */ #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomon.h" + +#include + #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" @@ -74,12 +77,11 @@ void CBC_ReedSolomonEncoder::Encode(CFX_Int32Array* toEncode, CBC_ReedSolomonGF256Poly info; info.Init(m_field, &infoCoefficients, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_ReedSolomonGF256Poly* rsg = info.MultiplyByMonomial(ecBytes, 1, e); + std::unique_ptr infoTemp( + info.MultiplyByMonomial(ecBytes, 1, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr infoTemp(rsg); - CFX_PtrArray* pa = infoTemp->Divide(generator, e); + std::unique_ptr temp(infoTemp->Divide(generator, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr temp(pa); CBC_ReedSolomonGF256Poly* remainder = (CBC_ReedSolomonGF256Poly*)(temp->operator[](1)); CFX_Int32Array* coefficients = remainder->GetCoefficients(); diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp index 86c8a60c39..abdcaf0c88 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.cpp @@ -21,6 +21,10 @@ */ #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" + +#include +#include + #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" @@ -51,23 +55,22 @@ void CBC_ReedSolomonDecoder::Decode(CFX_Int32Array* received, CBC_ReedSolomonGF256Poly syndrome; syndrome.Init(m_field, &syndromeCoefficients, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_ReedSolomonGF256Poly* rsg = m_field->BuildMonomial(twoS, 1, e); + std::unique_ptr temp( + m_field->BuildMonomial(twoS, 1, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr temp(rsg); - CFX_PtrArray* pa = RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e); + std::unique_ptr sigmaOmega( + RunEuclideanAlgorithm(temp.get(), &syndrome, twoS, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr sigmaOmega(pa); - CBC_AutoPtr sigma( + std::unique_ptr sigma( (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[0]); - CBC_AutoPtr omega( + std::unique_ptr omega( (CBC_ReedSolomonGF256Poly*)(*sigmaOmega)[1]); - CFX_Int32Array* ia1 = FindErrorLocations(sigma.get(), e); + std::unique_ptr errorLocations( + FindErrorLocations(sigma.get(), e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr errorLocations(ia1); - CFX_Int32Array* ia2 = - FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e); + std::unique_ptr errorMagnitudes( + FindErrorMagnitudes(omega.get(), errorLocations.get(), dataMatrix, e)); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_AutoPtr errorMagnitudes(ia2); for (int32_t k = 0; k < errorLocations->GetSize(); k++) { int32_t position = received->GetSize() - 1 - m_field->Log((*errorLocations)[k], e); @@ -90,42 +93,33 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( a = b; b = temp; } - CBC_ReedSolomonGF256Poly* rsg1 = a->Clone(e); + std::unique_ptr rLast(a->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr rLast(rsg1); - CBC_ReedSolomonGF256Poly* rsg2 = b->Clone(e); + std::unique_ptr r(b->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr r(rsg2); - CBC_ReedSolomonGF256Poly* rsg3 = m_field->GetOne()->Clone(e); + std::unique_ptr sLast(m_field->GetOne()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr sLast(rsg3); - CBC_ReedSolomonGF256Poly* rsg4 = m_field->GetZero()->Clone(e); + std::unique_ptr s(m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr s(rsg4); - CBC_ReedSolomonGF256Poly* rsg5 = m_field->GetZero()->Clone(e); + std::unique_ptr tLast(m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr tLast(rsg5); - CBC_ReedSolomonGF256Poly* rsg6 = m_field->GetOne()->Clone(e); + std::unique_ptr t(m_field->GetOne()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr t(rsg6); while (r->GetDegree() >= R / 2) { - CBC_AutoPtr rLastLast = rLast; - CBC_AutoPtr sLastLast = sLast; - CBC_AutoPtr tLastlast = tLast; - rLast = r; - sLast = s; - tLast = t; + std::unique_ptr rLastLast = std::move(rLast); + std::unique_ptr sLastLast = std::move(sLast); + std::unique_ptr tLastlast = std::move(tLast); + rLast = std::move(r); + sLast = std::move(s); + tLast = std::move(t); if (rLast->IsZero()) { e = BCExceptionR_I_1IsZero; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_ReedSolomonGF256Poly* rsg7 = rLastLast->Clone(e); + r.reset(rLastLast->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr rTemp(rsg7); - r = rTemp; - CBC_ReedSolomonGF256Poly* rsg8 = m_field->GetZero()->Clone(e); + std::unique_ptr q(m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr q(rsg8); int32_t denominatorLeadingTerm = rLast->GetCoefficients(rLast->GetDegree()); int32_t dltInverse = m_field->Inverse(denominatorLeadingTerm, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); @@ -133,37 +127,27 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( int32_t degreeDiff = r->GetDegree() - rLast->GetDegree(); int32_t scale = m_field->Multiply(r->GetCoefficients(r->GetDegree()), dltInverse); - CBC_ReedSolomonGF256Poly* rsgp1 = - m_field->BuildMonomial(degreeDiff, scale, e); + std::unique_ptr build( + m_field->BuildMonomial(degreeDiff, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr build(rsgp1); - CBC_ReedSolomonGF256Poly* rsgp2 = q->AddOrSubtract(build.get(), e); + q.reset(q->AddOrSubtract(build.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp(rsgp2); - q = temp; - CBC_ReedSolomonGF256Poly* rsgp3 = - rLast->MultiplyByMonomial(degreeDiff, scale, e); + std::unique_ptr multiply( + rLast->MultiplyByMonomial(degreeDiff, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr multiply(rsgp3); - CBC_ReedSolomonGF256Poly* rsgp4 = r->AddOrSubtract(multiply.get(), e); + r.reset(r->AddOrSubtract(multiply.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp3(rsgp4); - r = temp3; } - CBC_ReedSolomonGF256Poly* rsg9 = q->Multiply(sLast.get(), e); + std::unique_ptr temp1( + q->Multiply(sLast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp1(rsg9); - CBC_ReedSolomonGF256Poly* rsg10 = temp1->AddOrSubtract(sLastLast.get(), e); + s.reset(temp1->AddOrSubtract(sLastLast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp2(rsg10); - s = temp2; - CBC_ReedSolomonGF256Poly* rsg11 = q->Multiply(tLast.get(), e); + std::unique_ptr temp5( + q->Multiply(tLast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp5(rsg11); - CBC_ReedSolomonGF256Poly* rsg12 = temp5->AddOrSubtract(tLastlast.get(), e); + t.reset(temp5->AddOrSubtract(tLastlast.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp6(rsg12); - t = temp6; } int32_t sigmaTildeAtZero = t->GetCoefficients(0); if (sigmaTildeAtZero == 0) { @@ -172,12 +156,10 @@ CFX_PtrArray* CBC_ReedSolomonDecoder::RunEuclideanAlgorithm( } int32_t inverse = m_field->Inverse(sigmaTildeAtZero, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_ReedSolomonGF256Poly* rsg13 = t->Multiply(inverse, e); + std::unique_ptr sigma(t->Multiply(inverse, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr sigma(rsg13); - CBC_ReedSolomonGF256Poly* rsg14 = r->Multiply(inverse, e); + std::unique_ptr omega(r->Multiply(inverse, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr omega(rsg14); CFX_PtrArray* temp = new CFX_PtrArray; temp->Add(sigma.release()); temp->Add(omega.release()); @@ -188,13 +170,13 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorLocations( int32_t& e) { int32_t numErrors = errorLocator->GetDegree(); if (numErrors == 1) { - CBC_AutoPtr temp(new CFX_Int32Array); + std::unique_ptr temp(new CFX_Int32Array); temp->Add(errorLocator->GetCoefficients(1)); return temp.release(); } CFX_Int32Array* tempT = new CFX_Int32Array; tempT->SetSize(numErrors); - CBC_AutoPtr result(tempT); + std::unique_ptr result(tempT); int32_t ie = 0; for (int32_t i = 1; i < 256 && ie < numErrors; i++) { if (errorLocator->EvaluateAt(i) == 0) { @@ -217,7 +199,7 @@ CFX_Int32Array* CBC_ReedSolomonDecoder::FindErrorMagnitudes( int32_t s = errorLocations->GetSize(); CFX_Int32Array* temp = new CFX_Int32Array; temp->SetSize(s); - CBC_AutoPtr result(temp); + std::unique_ptr result(temp); for (int32_t i = 0; i < s; i++) { int32_t xiInverse = m_field->Inverse(errorLocations->operator[](i), e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp index baafde023a..f138009ffa 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.cpp @@ -20,9 +20,12 @@ * limitations under the License. */ -#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h" +#include + +#include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" + CBC_ReedSolomonGF256Poly::CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients) { if (field == NULL) { @@ -216,12 +219,11 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, e = BCExceptionDivideByZero; BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } - CBC_ReedSolomonGF256Poly* rsg1 = m_field->GetZero()->Clone(e); + std::unique_ptr quotient( + m_field->GetZero()->Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr quotient(rsg1); - CBC_ReedSolomonGF256Poly* rsg2 = Clone(e); + std::unique_ptr remainder(Clone(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr remainder(rsg2); int32_t denominatorLeadingTerm = other->GetCoefficients(other->GetDegree()); int32_t inverseDenominatorLeadingTeam = m_field->Inverse(denominatorLeadingTerm, e); @@ -231,23 +233,16 @@ CFX_PtrArray* CBC_ReedSolomonGF256Poly::Divide(CBC_ReedSolomonGF256Poly* other, int32_t scale = m_field->Multiply(remainder->GetCoefficients((remainder->GetDegree())), inverseDenominatorLeadingTeam); - CBC_ReedSolomonGF256Poly* rsg3 = - other->MultiplyByMonomial(degreeDifference, scale, e); + std::unique_ptr term( + other->MultiplyByMonomial(degreeDifference, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr term(rsg3); - CBC_ReedSolomonGF256Poly* rsg4 = - m_field->BuildMonomial(degreeDifference, scale, e); + std::unique_ptr iteratorQuotient( + m_field->BuildMonomial(degreeDifference, scale, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr iteratorQuotient(rsg4); - CBC_ReedSolomonGF256Poly* rsg5 = - quotient->AddOrSubtract(iteratorQuotient.get(), e); + quotient.reset(quotient->AddOrSubtract(iteratorQuotient.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp(rsg5); - quotient = temp; - CBC_ReedSolomonGF256Poly* rsg6 = remainder->AddOrSubtract(term.get(), e); + remainder.reset(remainder->AddOrSubtract(term.get(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr temp1(rsg6); - remainder = temp1; } CFX_PtrArray* tempPtrA = new CFX_PtrArray; tempPtrA->Add(quotient.release()); diff --git a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h index 8f2642dd87..71e4a09dd3 100644 --- a/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h +++ b/xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256Poly.h @@ -7,7 +7,10 @@ #ifndef XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ #define XFA_SRC_FXBARCODE_COMMON_REEDSOLOMON_BC_REEDSOLOMONGF256POLY_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_ReedSolomonGF256; + class CBC_ReedSolomonGF256Poly { public: CBC_ReedSolomonGF256Poly(CBC_ReedSolomonGF256* field, int32_t coefficients); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp index be13c8580f..9315b167e7 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.cpp @@ -20,8 +20,11 @@ * limitations under the License. */ -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" + +#include + +#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" #include "xfa/src/fxbarcode/utils.h" @@ -63,7 +66,7 @@ CBC_DataMatrixVersion* CBC_DataMatrixBitMatrixParser::ReadVersion( return temp; } CFX_ByteArray* CBC_DataMatrixBitMatrixParser::ReadCodewords(int32_t& e) { - CBC_AutoPtr result(new CFX_ByteArray()); + std::unique_ptr result(new CFX_ByteArray()); result->SetSize(m_version->GetTotalCodewords()); int32_t resultOffset = 0; int32_t row = 4; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp index 4728bb3572..6ccb2f75d9 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp @@ -21,6 +21,9 @@ */ #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" + +#include + #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" #include "xfa/src/fxbarcode/utils.h" @@ -41,7 +44,7 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( for (i = 0; i < ecBlockArray.GetSize(); i++) { totalBlocks += ((ECB*)ecBlockArray[i])->GetCount(); } - CBC_AutoPtr result(new CFX_PtrArray()); + std::unique_ptr result(new CFX_PtrArray()); result->SetSize(totalBlocks); int32_t numResultBlocks = 0; int32_t j; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp index 49a1d1654a..423cefc65f 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.cpp @@ -20,13 +20,16 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" + +#include + #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixBitMatrixParser.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDataBlock.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecodedBitStreamParser.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixVersion.h" CBC_DataMatrixDecoder::CBC_DataMatrixDecoder() { @@ -46,9 +49,8 @@ CBC_CommonDecoderResult* CBC_DataMatrixDecoder::Decode( parser.Init(bits, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_DataMatrixVersion* version = parser.GetVersion(); - CFX_ByteArray* byteTemp = parser.ReadCodewords(e); + std::unique_ptr codewords(parser.ReadCodewords(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr codewords(byteTemp); CFX_PtrArray* dataBlocks = CBC_DataMatrixDataBlock::GetDataBlocks(codewords.get(), version, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h index 011a8b8e72..d80a51247f 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h @@ -7,9 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ #define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDECODER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_ReedSolomonDecoder; class CBC_CommonDecoderResult; class CBC_CommonBitMatrix; + class CBC_DataMatrixDecoder { public: CBC_DataMatrixDecoder(); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp index b89ef7066b..c29c64862a 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.cpp @@ -20,12 +20,14 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" + #include +#include #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/BC_WhiteRectangleDetector.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" @@ -121,10 +123,10 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { } else { topRight = pointD; } - int32_t dimensionTop = CBC_AutoPtr( + int32_t dimensionTop = std::unique_ptr( TransitionsBetween(topLeft, topRight)) ->GetTransitions(); - int32_t dimensionRight = CBC_AutoPtr( + int32_t dimensionRight = std::unique_ptr( TransitionsBetween(bottomRight, topRight)) ->GetTransitions(); if ((dimensionTop & 0x01) == 1) { @@ -135,24 +137,24 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { dimensionRight++; } dimensionRight += 2; - CBC_AutoPtr bits(NULL); - CBC_AutoPtr correctedTopRight(NULL); + std::unique_ptr bits; + std::unique_ptr correctedTopRight; if (4 * dimensionTop >= 7 * dimensionRight || 4 * dimensionRight >= 7 * dimensionTop) { - correctedTopRight = CBC_AutoPtr( + correctedTopRight.reset( CorrectTopRightRectangular(bottomLeft, bottomRight, topLeft, topRight, dimensionTop, dimensionRight)); if (correctedTopRight.get() == NULL) { - correctedTopRight = CBC_AutoPtr(topRight); + correctedTopRight.reset(topRight); } else { delete topRight; topRight = NULL; } - dimensionTop = CBC_AutoPtr( + dimensionTop = std::unique_ptr( TransitionsBetween(topLeft, correctedTopRight.get())) ->GetTransitions(); dimensionRight = - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(bottomRight, correctedTopRight.get())) ->GetTransitions(); if ((dimensionTop & 0x01) == 1) { @@ -161,34 +163,34 @@ CBC_QRDetectorResult* CBC_DataMatrixDetector::Detect(int32_t& e) { if ((dimensionRight & 0x01) == 1) { dimensionRight++; } - bits = CBC_AutoPtr( - SampleGrid(m_image, topLeft, bottomLeft, bottomRight, - correctedTopRight.get(), dimensionTop, dimensionRight, e)); + bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, + correctedTopRight.get(), dimensionTop, dimensionRight, + e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } else { int32_t dimension = std::min(dimensionRight, dimensionTop); - correctedTopRight = CBC_AutoPtr( + correctedTopRight.reset( CorrectTopRight(bottomLeft, bottomRight, topLeft, topRight, dimension)); if (correctedTopRight.get() == NULL) { - correctedTopRight = CBC_AutoPtr(topRight); + correctedTopRight.reset(topRight); } else { delete topRight; topRight = NULL; } int32_t dimensionCorrected = - std::max(CBC_AutoPtr( + std::max(std::unique_ptr( TransitionsBetween(topLeft, correctedTopRight.get())) ->GetTransitions(), - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(bottomRight, correctedTopRight.get())) ->GetTransitions()); dimensionCorrected++; if ((dimensionCorrected & 0x01) == 1) { dimensionCorrected++; } - bits = CBC_AutoPtr(SampleGrid( - m_image, topLeft, bottomLeft, bottomRight, correctedTopRight.get(), - dimensionCorrected, dimensionCorrected, e)); + bits.reset(SampleGrid(m_image, topLeft, bottomLeft, bottomRight, + correctedTopRight.get(), dimensionCorrected, + dimensionCorrected, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); } CFX_PtrArray* result = new CFX_PtrArray; @@ -210,13 +212,13 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( int32_t norm = Distance(topLeft, topRight); FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; - CBC_AutoPtr c1(new CBC_ResultPoint( + std::unique_ptr c1(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); corr = Distance(bottomLeft, topLeft) / (FX_FLOAT)dimensionRight; norm = Distance(bottomRight, topRight); cos = (topRight->GetX() - bottomRight->GetX()) / norm; sin = (topRight->GetY() - bottomRight->GetY()) / norm; - CBC_AutoPtr c2(new CBC_ResultPoint( + std::unique_ptr c2(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); if (!IsValid(c1.get())) { if (IsValid(c2.get())) { @@ -227,19 +229,19 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRightRectangular( return c1.release(); } int32_t l1 = FXSYS_abs(dimensionTop - - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(topLeft, c1.get())) ->GetTransitions()) + FXSYS_abs(dimensionRight - - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(bottomRight, c1.get())) ->GetTransitions()); int32_t l2 = FXSYS_abs(dimensionTop - - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(topLeft, c2.get())) ->GetTransitions()) + FXSYS_abs(dimensionRight - - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(bottomRight, c2.get())) ->GetTransitions()); if (l1 <= l2) { @@ -257,13 +259,13 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( int32_t norm = Distance(topLeft, topRight); FX_FLOAT cos = (topRight->GetX() - topLeft->GetX()) / norm; FX_FLOAT sin = (topRight->GetY() - topLeft->GetY()) / norm; - CBC_AutoPtr c1(new CBC_ResultPoint( + std::unique_ptr c1(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); corr = Distance(bottomLeft, bottomRight) / (FX_FLOAT)dimension; norm = Distance(bottomRight, topRight); cos = (topRight->GetX() - bottomRight->GetX()) / norm; sin = (topRight->GetY() - bottomRight->GetY()) / norm; - CBC_AutoPtr c2(new CBC_ResultPoint( + std::unique_ptr c2(new CBC_ResultPoint( topRight->GetX() + corr * cos, topRight->GetY() + corr * sin)); if (!IsValid(c1.get())) { if (IsValid(c2.get())) { @@ -273,16 +275,16 @@ CBC_ResultPoint* CBC_DataMatrixDetector::CorrectTopRight( } else if (!IsValid(c2.get())) { return c1.release(); } - int32_t l1 = FXSYS_abs(CBC_AutoPtr( + int32_t l1 = FXSYS_abs(std::unique_ptr( TransitionsBetween(topLeft, c1.get())) ->GetTransitions() - - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(bottomRight, c1.get())) ->GetTransitions()); - int32_t l2 = FXSYS_abs(CBC_AutoPtr( + int32_t l2 = FXSYS_abs(std::unique_ptr( TransitionsBetween(topLeft, c2.get())) ->GetTransitions() - - CBC_AutoPtr( + std::unique_ptr( TransitionsBetween(bottomRight, c2.get())) ->GetTransitions()); return l1 <= l2 ? c1.release() : c2.release(); diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h index 5ab8f9d060..123f75101b 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ #define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXDETECTOR_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_WhiteRectangleDetector; class CBC_ResultPoint; diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp index 2586751107..36a238b007 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.cpp @@ -20,12 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" + +#include + #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDecoder.h" #include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixDetector.h" -#include "xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" #include "xfa/src/fxbarcode/utils.h" @@ -47,13 +50,11 @@ CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, CBC_DataMatrixDetector detector(cdr); detector.Init(e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_QRDetectorResult* ddr = detector.Detect(e); + std::unique_ptr detectorResult(detector.Detect(e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr detectorResult(ddr); - CBC_CommonDecoderResult* ResultTemp = - m_decoder->Decode(detectorResult->GetBits(), e); + std::unique_ptr decodeResult( + m_decoder->Decode(detectorResult->GetBits(), e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr decodeResult(ResultTemp); return decodeResult->GetText(); } CFX_ByteString CBC_DataMatrixReader::Decode(CBC_BinaryBitmap* image, diff --git a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h index 51d22588aa..5389c4857b 100644 --- a/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h +++ b/xfa/src/fxbarcode/datamatrix/BC_DataMatrixReader.h @@ -7,10 +7,11 @@ #ifndef XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ #define XFA_SRC_FXBARCODE_DATAMATRIX_BC_DATAMATRIXREADER_H_ +#include "xfa/src/fxbarcode/BC_Reader.h" + class CBC_BinaryBitmap; class CBC_DataMatrixDecoder; -class CBC_Reader; -class CBC_DataMatrixReader; + class CBC_DataMatrixReader : public CBC_Reader { public: CBC_DataMatrixReader(); diff --git a/xfa/src/fxbarcode/oned/BC_OneDReader.h b/xfa/src/fxbarcode/oned/BC_OneDReader.h index 5a55d1f5e2..27a1a3d7ee 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDReader.h +++ b/xfa/src/fxbarcode/oned/BC_OneDReader.h @@ -7,9 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ #define XFA_SRC_FXBARCODE_ONED_BC_ONEDREADER_H_ -#include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/BC_Reader.h" -class CBC_Reader; class CBC_BinaryBitmap; class CBC_CommonBitArray; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp index 74f0db4068..da1f47bfe8 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OneDimReader.cpp @@ -20,10 +20,13 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" + +#include + #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" #include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OneDimReader.h" #include "xfa/src/fxbarcode/utils.h" const int32_t CBC_OneDimReader::MAX_AVG_VARIANCE = (int32_t)(256 * 0.48f); @@ -73,9 +76,8 @@ CFX_ByteString CBC_OneDimReader::DecodeRow(int32_t rowNumber, CBC_CommonBitArray* row, int32_t hints, int32_t& e) { - CFX_Int32Array* StartPattern = FindStartGuardPattern(row, e); + std::unique_ptr result(FindStartGuardPattern(row, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr result(StartPattern); CFX_ByteString temp = DecodeRow(rowNumber, row, result.get(), hints, e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); return temp; diff --git a/xfa/src/fxbarcode/oned/BC_OneDimReader.h b/xfa/src/fxbarcode/oned/BC_OneDimReader.h index 0a3e3c3d5d..3374bec63a 100644 --- a/xfa/src/fxbarcode/oned/BC_OneDimReader.h +++ b/xfa/src/fxbarcode/oned/BC_OneDimReader.h @@ -7,9 +7,11 @@ #ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ #define XFA_SRC_FXBARCODE_ONED_BC_ONEDIMREADER_H_ -class CBC_OneDReader; +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" + class CBC_CommonBitArray; -class CBC_OneDimReader; + class CBC_OneDimReader : public CBC_OneDReader { private: const static int32_t MAX_AVG_VARIANCE; diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp index d7caf68226..3cbad1eade 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp +++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.cpp @@ -20,13 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" + #include +#include #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/BC_Reader.h" #include "xfa/src/fxbarcode/common/BC_CommonBitArray.h" #include "xfa/src/fxbarcode/oned/BC_OneDReader.h" -#include "xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h" #include "xfa/src/fxbarcode/oned/BC_OnedCode39Reader.h" #include "xfa/src/fxbarcode/utils.h" @@ -46,9 +48,8 @@ CFX_ByteString CBC_OnedCodaBarReader::DecodeRow(int32_t rowNumber, CBC_CommonBitArray* row, int32_t hints, int32_t& e) { - CFX_Int32Array* int32Ptr = FindAsteriskPattern(row, e); + std::unique_ptr start(FindAsteriskPattern(row, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr start(int32Ptr); (*start)[1] = 0; int32_t nextStart = (*start)[1]; int32_t end = row->GetSize(); diff --git a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h index e1cf9d8698..cbb47fb554 100644 --- a/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h +++ b/xfa/src/fxbarcode/oned/BC_OnedCodaBarReader.h @@ -7,9 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ #define XFA_SRC_FXBARCODE_ONED_BC_ONEDCODABARREADER_H_ +#include "core/include/fxcrt/fx_basic.h" +#include "xfa/src/fxbarcode/oned/BC_OneDReader.h" + class CBC_CommonBitArray; class CBC_OneDReader; -class CBC_OnedCodaBarReader; + class CBC_OnedCodaBarReader : public CBC_OneDReader { public: CBC_OnedCodaBarReader(); diff --git a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp b/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp index d44995385a..7426d95d4c 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.cpp @@ -20,8 +20,11 @@ * limitations under the License. */ -#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h" + +#include + +#include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDataMask.h" @@ -140,13 +143,12 @@ CFX_ByteArray* CBC_QRBitMatrixParser::ReadCodewords(int32_t& e) { int32_t dimension = m_bitMatrix->GetDimension(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); dataMask->UnmaskBitMatirx(m_bitMatrix, dimension); - CBC_CommonBitMatrix* cbm = version->BuildFunctionPattern(e); + std::unique_ptr functionPattern( + version->BuildFunctionPattern(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr functionPattern(cbm); FX_BOOL readingUp = TRUE; - CFX_ByteArray* temp = new CFX_ByteArray; - temp->SetSize(version->GetTotalCodeWords()); - CBC_AutoPtr result(temp); + std::unique_ptr result(new CFX_ByteArray); + result->SetSize(version->GetTotalCodeWords()); int32_t resultOffset = 0; int32_t currentByte = 0; int32_t bitsRead = 0; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp index c594230428..896a3a107b 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.cpp @@ -20,6 +20,10 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" + +#include + #include "xfa/src/fxbarcode/BC_Binarizer.h" #include "xfa/src/fxbarcode/BC_BinaryBitmap.h" #include "xfa/src/fxbarcode/BC_BufferedImageLuminanceSource.h" @@ -29,9 +33,6 @@ #include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/src/fxbarcode/common/BC_GlobalHistogramBinarizer.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" @@ -54,13 +55,12 @@ CFX_ByteString CBC_QRCodeReader::Decode(CBC_BinaryBitmap* image, CBC_CommonBitMatrix* matrix = image->GetMatrix(e); BC_EXCEPTION_CHECK_ReturnValue(e, ""); CBC_QRDetector detector(matrix); - CBC_QRDetectorResult* qdr = detector.Detect(hints, e); + std::unique_ptr detectorResult( + detector.Detect(hints, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr detectorResult(qdr); - CBC_CommonDecoderResult* qdr2 = - m_decoder->Decode(detectorResult->GetBits(), 0, e); + std::unique_ptr decodeResult( + m_decoder->Decode(detectorResult->GetBits(), 0, e)); BC_EXCEPTION_CHECK_ReturnValue(e, ""); - CBC_AutoPtr decodeResult(qdr2); return (decodeResult->GetText()); } CFX_ByteString CBC_QRCodeReader::Decode(const CFX_WideString& filename, diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h index 98bf976e06..bcb08fa21e 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRCodeReader.h @@ -7,6 +7,11 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODEREADER_H_ +#include + +#include "core/include/fxcrt/fx_string.h" +#include "xfa/src/fxbarcode/BC_Reader.h" + class CBC_QRDetector; class CBC_BinaryBitmap; class CBC_QRCoderDecoder; @@ -18,7 +23,8 @@ class CBC_QRDetectorResult; class CBC_QRCoderErrorCorrectionLevel; class CBC_QRCoderMode; class CBC_QRDataMask; -class CBC_QRCodeReader; +class CFX_DIBitmap; + class CBC_QRCodeReader : public CBC_Reader { private: CBC_QRCoderDecoder* m_decoder; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp index ebaa40fd12..dd310217d4 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.cpp @@ -20,12 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" + +#include + #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/BC_CommonDecoderResult.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonDecoder.h" #include "xfa/src/fxbarcode/common/reedsolomon/BC_ReedSolomonGF256.h" #include "xfa/src/fxbarcode/qrcode/BC_QRBitMatrixParser.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderFormatInformation.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" @@ -69,9 +72,8 @@ CBC_CommonDecoderResult* CBC_QRCoderDecoder::Decode(CBC_CommonBitMatrix* bits, CBC_QRCoderFormatInformation* temp = parser.ReadFormatInformation(e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); CBC_QRCoderErrorCorrectionLevel* ecLevel = temp->GetErrorCorrectionLevel(); - CFX_ByteArray* ba = parser.ReadCodewords(e); + std::unique_ptr codewords(parser.ReadCodewords(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr codewords(ba); CFX_PtrArray* dataBlocks = CBC_QRDataBlock::GetDataBlocks(codewords.get(), version, ecLevel, e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h index 26952ee9e0..e2e53a796c 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderDecoder.h @@ -7,12 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERDECODER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_ReedSolomonDecoder; class CBC_CommonDecoderResult; -class CBC_QRBitMatrixParser; -class CBC_QRCoderVersion; -class CBC_QRDataBlock; + class CBC_QRCoderDecoder { private: CBC_ReedSolomonDecoder* m_rsDecoder; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp index a451ab50b8..eb31ddc301 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.cpp @@ -20,7 +20,10 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" + #include +#include #include "xfa/src/fxbarcode/BC_UtilCodingConvert.h" #include "xfa/src/fxbarcode/common/BC_CommonByteArray.h" @@ -31,8 +34,6 @@ #include "xfa/src/fxbarcode/qrcode/BC_QRCoderBitVector.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderBlockPair.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMaskUtil.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMatrixUtil.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderMode.h" @@ -408,10 +409,9 @@ void CBC_QRCoderEncoder::EncodeWithSpecifyVersion( qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), &finalBits, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - pDecoder->Init(); - CBC_AutoPtr matrix(pDecoder); + std::unique_ptr matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); BC_EXCEPTION_CHECK_ReturnVoid(e); @@ -499,10 +499,9 @@ catchException: qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), &finalBits, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - pDecoder->Init(); - CBC_AutoPtr matrix(pDecoder); + std::unique_ptr matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); BC_EXCEPTION_CHECK_ReturnVoid(e); @@ -550,10 +549,9 @@ void CBC_QRCoderEncoder::Encode(const CFX_WideString& content, qrCode->GetNumDataBytes(), qrCode->GetNumRSBlocks(), &finalBits, e); BC_EXCEPTION_CHECK_ReturnVoid(e); - CBC_CommonByteMatrix* pDecoder = new CBC_CommonByteMatrix( - qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth()); - pDecoder->Init(); - CBC_AutoPtr matrix(pDecoder); + std::unique_ptr matrix(new CBC_CommonByteMatrix( + qrCode->GetMatrixWidth(), qrCode->GetMatrixWidth())); + matrix->Init(); int32_t maskPattern = ChooseMaskPattern( &finalBits, qrCode->GetECLevel(), qrCode->GetVersion(), matrix.get(), e); BC_EXCEPTION_CHECK_ReturnVoid(e); diff --git a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h index 05fc2f8551..27e5b65494 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRCoderEncoder.h @@ -7,6 +7,9 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRCODERENCODER_H_ +#include "core/include/fxcrt/fx_basic.h" +#include "core/include/fxcrt/fx_string.h" + class Make_Pair; class CBC_QRCoder; class CBC_QRCoderErrorCorrectionLevel; @@ -14,7 +17,7 @@ class CBC_QRCoderMode; class CBC_QRCoderBitVector; class CBC_CommonByteArray; class CBC_CommonByteMatrix; -class CBC_QRCoderEncoder; + class CBC_QRCoderEncoder { private: const static int32_t m_alphaNumbericTable[96]; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp index 75ad077521..185e16c5b7 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.cpp @@ -20,10 +20,13 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" + +#include + #include "xfa/src/fxbarcode/qrcode/BC_QRCoderECB.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderECBlocks.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h" #include "xfa/src/fxbarcode/utils.h" CBC_QRDataBlock::CBC_QRDataBlock(int32_t numDataCodewords, @@ -54,9 +57,8 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks( for (i = 0; i < ecBlockArray->GetSize(); i++) { totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount(); } - CFX_PtrArray* datablock = new CFX_PtrArray(); - datablock->SetSize(totalBlocks); - CBC_AutoPtr result(datablock); + std::unique_ptr result(new CFX_PtrArray()); + result->SetSize(totalBlocks); int32_t numResultBlocks = 0; for (int32_t j = 0; j < ecBlockArray->GetSize(); j++) { CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)(*ecBlockArray)[j]; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h index 63ee10ef06..6146c41465 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRDataBlock.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRDATABLOCK_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_QRCoderVersion; class CBC_QRCoderECBlocks; class CBC_QRCoderECB; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp index 1fd8742690..72ce42fc4c 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRDetector.cpp @@ -20,14 +20,16 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRDetector.h" + #include +#include #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" #include "xfa/src/fxbarcode/qrcode/BC_QRAlignmentPatternFinder.h" #include "xfa/src/fxbarcode/qrcode/BC_QRCoderVersion.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRDetector.h" #include "xfa/src/fxbarcode/qrcode/BC_QRDetectorResult.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" @@ -37,9 +39,8 @@ CBC_QRDetector::CBC_QRDetector(CBC_CommonBitMatrix* image) : m_image(image) {} CBC_QRDetector::~CBC_QRDetector() {} CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) { CBC_QRFinderPatternFinder finder(m_image); - CBC_QRFinderPatternInfo* qpi = finder.Find(hints, e); + std::unique_ptr info(finder.Find(hints, e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr info(qpi); CBC_QRDetectorResult* qdr = ProcessFinderPatternInfo(info.get(), e); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); return qdr; @@ -47,9 +48,9 @@ CBC_QRDetectorResult* CBC_QRDetector::Detect(int32_t hints, int32_t& e) { CBC_QRDetectorResult* CBC_QRDetector::ProcessFinderPatternInfo( CBC_QRFinderPatternInfo* info, int32_t& e) { - CBC_AutoPtr topLeft(info->GetTopLeft()); - CBC_AutoPtr topRight(info->GetTopRight()); - CBC_AutoPtr bottomLeft(info->GetBottomLeft()); + std::unique_ptr topLeft(info->GetTopLeft()); + std::unique_ptr topRight(info->GetTopRight()); + std::unique_ptr bottomLeft(info->GetBottomLeft()); FX_FLOAT moduleSize = CalculateModuleSize(topLeft.get(), topRight.get(), bottomLeft.get()); if (moduleSize < 1.0f) { diff --git a/xfa/src/fxbarcode/qrcode/BC_QRDetector.h b/xfa/src/fxbarcode/qrcode/BC_QRDetector.h index 45d2f5345f..b76a656f07 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRDetector.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRDetector.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRDETECTOR_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_ResultPoint; class CBC_CommonBitMatrix; class CBC_QRDetectorResult; @@ -17,7 +19,7 @@ class CBC_QRCoderVersion; class CBC_QRGridSampler; class CBC_QRAlignmentPatternFinder; class CBC_QRAlignmentPattern; -class CBC_QRDetector; + class CBC_QRDetector { private: CBC_CommonBitMatrix* m_image; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp index d143e276bb..f5a3c7aead 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.cpp @@ -20,12 +20,15 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" + +#include + #include "core/include/fxcrt/fx_basic.h" #include "xfa/src/fxbarcode/BC_ResultPoint.h" #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/qrcode/BC_FinderPatternInfo.h" #include "xfa/src/fxbarcode/qrcode/BC_QRFinderPattern.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h" #include "xfa/src/fxbarcode/utils.h" const int32_t CBC_QRFinderPatternFinder::CENTER_QUORUM = 2; @@ -158,9 +161,8 @@ CBC_QRFinderPatternInfo* CBC_QRFinderPatternFinder::Find(int32_t hint, } } } - CFX_PtrArray* ptr = SelectBestpatterns(e); + std::unique_ptr patternInfo(SelectBestpatterns(e)); BC_EXCEPTION_CHECK_ReturnValue(e, NULL); - CBC_AutoPtr patternInfo(ptr); OrderBestPatterns(patternInfo.get()); return new CBC_QRFinderPatternInfo(patternInfo.get()); } diff --git a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h index 7f9209d214..aa731b6cdb 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRFinderPatternFinder.h @@ -7,6 +7,8 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRFINDERPATTERNFINDER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_QRFinderPattern; class CBC_ResultPoint; diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp index 7b9fe7b4f3..87f0fd072e 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp +++ b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.cpp @@ -20,9 +20,12 @@ * limitations under the License. */ +#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" + +#include + #include "xfa/src/fxbarcode/common/BC_CommonBitMatrix.h" #include "xfa/src/fxbarcode/common/BC_CommonPerspectiveTransform.h" -#include "xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h" #include "xfa/src/fxbarcode/utils.h" CBC_QRGridSampler CBC_QRGridSampler::m_gridSampler; @@ -107,13 +110,12 @@ CBC_CommonBitMatrix* CBC_QRGridSampler::SampleGrid(CBC_CommonBitMatrix* image, FX_FLOAT p4FromX, FX_FLOAT p4FromY, int32_t& e) { - CBC_AutoPtr transform( + std::unique_ptr transform( CBC_CommonPerspectiveTransform::QuadrilateralToQuadrilateral( p1ToX, p1ToY, p2ToX, p2ToY, p3ToX, p3ToY, p4ToX, p4ToY, p1FromX, p1FromY, p2FromX, p2FromY, p3FromX, p3FromY, p4FromX, p4FromY)); - CBC_CommonBitMatrix* tempBitM = new CBC_CommonBitMatrix(); - tempBitM->Init(dimensionX, dimensionY); - CBC_AutoPtr bits(tempBitM); + std::unique_ptr bits(new CBC_CommonBitMatrix()); + bits->Init(dimensionX, dimensionY); CFX_FloatArray points; points.SetSize(dimensionX << 1); for (int32_t y = 0; y < dimensionY; y++) { diff --git a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h index a3f412435d..8d6b96a2b2 100644 --- a/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h +++ b/xfa/src/fxbarcode/qrcode/BC_QRGridSampler.h @@ -7,10 +7,12 @@ #ifndef XFA_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ #define XFA_SRC_FXBARCODE_QRCODE_BC_QRGRIDSAMPLER_H_ +#include "core/include/fxcrt/fx_basic.h" + class CBC_CommonBitMatrix; class CBC_CommonPerspectiveTransform; class CBC_CommonDefaultGridSampler; -class CBC_QRGridSampler; + class CBC_QRGridSampler { private: static CBC_QRGridSampler m_gridSampler; diff --git a/xfa/src/fxbarcode/utils.h b/xfa/src/fxbarcode/utils.h index 37d2ce775b..23830d5656 100644 --- a/xfa/src/fxbarcode/utils.h +++ b/xfa/src/fxbarcode/utils.h @@ -19,44 +19,7 @@ void BC_FX_ByteString_Append(CFX_ByteString& dst, int32_t count, FX_CHAR c); void BC_FX_ByteString_Append(CFX_ByteString& dst, const CFX_ByteArray& ba); typedef FX_BOOL (*BC_PtrArrayCompareCallback)(void* l, void* r); void BC_FX_PtrArray_Sort(CFX_PtrArray& src, BC_PtrArrayCompareCallback fun); -template -class CBC_AutoPtr { - public: - typedef _Ty element_type; - explicit CBC_AutoPtr(_Ty* _P = 0) : _Owns(_P != 0), _Ptr(_P) {} - CBC_AutoPtr(const CBC_AutoPtr<_Ty>& _Y) - : _Owns(_Y._Owns), _Ptr(_Y.release()) {} - CBC_AutoPtr<_Ty>& operator=(const CBC_AutoPtr<_Ty>& _Y) { - if (this != &_Y) { - if (_Ptr != _Y.get()) { - if (_Owns) { - delete _Ptr; - } - _Owns = _Y._Owns; - } else if (_Y._Owns) { - _Owns = TRUE; - } - _Ptr = _Y.release(); - } - return (*this); - } - ~CBC_AutoPtr() { - if (_Owns) { - delete _Ptr; - } - } - _Ty& operator*() const { return (*get()); } - _Ty* operator->() const { return (get()); } - _Ty* get() const { return (_Ptr); } - _Ty* release() const { - ((CBC_AutoPtr<_Ty>*)this)->_Owns = FALSE; - return (_Ptr); - } - private: - FX_BOOL _Owns; - _Ty* _Ptr; -}; #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) #include #elif(_FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_LINUX_DESKTOP_ || \ -- cgit v1.2.3