From aef780db30c434e1d681d81852fb13160e72ed1e Mon Sep 17 00:00:00 2001 From: tsepez Date: Thu, 28 Apr 2016 14:56:27 -0700 Subject: Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 4 Review-Url: https://codereview.chromium.org/1932703003 --- .../datamatrix/BC_DataMatrixDataBlock.cpp | 4 +-- xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp | 6 ++-- xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h | 36 +++++++++------------- 3 files changed, 20 insertions(+), 26 deletions(-) (limited to 'xfa/fxbarcode/datamatrix') diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp index 89c09c22a8..c70f8b1fc9 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp @@ -39,10 +39,10 @@ CFX_PtrArray* CBC_DataMatrixDataBlock::GetDataBlocks( int32_t& e) { ECBlocks* ecBlocks = version->GetECBlocks(); int32_t totalBlocks = 0; - const CFX_PtrArray& ecBlockArray = ecBlocks->GetECBlocks(); + const CFX_ArrayTemplate& ecBlockArray = ecBlocks->GetECBlocks(); int32_t i; for (i = 0; i < ecBlockArray.GetSize(); i++) { - totalBlocks += ((ECB*)ecBlockArray[i])->GetCount(); + totalBlocks += ecBlockArray[i]->GetCount(); } std::unique_ptr result(new CFX_PtrArray()); result->SetSize(totalBlocks); diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp index 50131f3dc2..e441a29e44 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp @@ -51,10 +51,10 @@ CBC_DataMatrixVersion::CBC_DataMatrixVersion(int32_t versionNumber, m_ecBlocks = ecBlocks; int32_t total = 0; int32_t ecCodewords = ecBlocks->GetECCodewords(); - const CFX_PtrArray& ecbArray = ecBlocks->GetECBlocks(); + const CFX_ArrayTemplate& ecbArray = ecBlocks->GetECBlocks(); for (int32_t i = 0; i < ecbArray.GetSize(); i++) { - total += ((ECB*)ecbArray[i])->GetCount() * - (((ECB*)ecbArray[i])->GetDataCodewords() + ecCodewords); + total += ecbArray[i]->GetCount() * + (ecbArray[i]->GetDataCodewords() + ecCodewords); } m_totalCodewords = total; } diff --git a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h index 9e8e801d8e..74433cc4f2 100644 --- a/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h +++ b/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h @@ -13,14 +13,11 @@ class CBC_DataMatrixVersion; class ECB { public: - ECB(int32_t count, int32_t dataCodewords) { - m_count = count; - m_dataCodewords = dataCodewords; - } - - int32_t GetCount() { return m_count; } + ECB(int32_t count, int32_t dataCodewords) + : m_count(count), m_dataCodewords(dataCodewords) {} - int32_t GetDataCodewords() { return m_dataCodewords; } + int32_t GetCount() const { return m_count; } + int32_t GetDataCodewords() const { return m_dataCodewords; } private: int32_t m_count; @@ -29,30 +26,27 @@ class ECB { class ECBlocks { public: - ECBlocks(int32_t ecCodewords, ECB* ecBlocks) { - m_ecCodewords = ecCodewords; - m_ecBlocks.Add(ecBlocks); + ECBlocks(int32_t ecCodewords, ECB* ecBlocks) : m_ecCodewords(ecCodewords) { + m_ecBlocksArray.Add(ecBlocks); } - ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) { - m_ecCodewords = ecCodewords; - m_ecBlocks.Add(ecBlocks1); - m_ecBlocks.Add(ecBlocks2); + ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) + : m_ecCodewords(ecCodewords) { + m_ecBlocksArray.Add(ecBlocks1); + m_ecBlocksArray.Add(ecBlocks2); } + ~ECBlocks() { - for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) { - delete (ECB*)m_ecBlocks[i]; - } - m_ecBlocks.RemoveAll(); + for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++) + delete m_ecBlocksArray[i]; } int32_t GetECCodewords() { return m_ecCodewords; } - - const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; } + const CFX_ArrayTemplate& GetECBlocks() { return m_ecBlocksArray; } private: int32_t m_ecCodewords; - CFX_PtrArray m_ecBlocks; + CFX_ArrayTemplate m_ecBlocksArray; }; class CBC_DataMatrixVersion { -- cgit v1.2.3