summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/qrcode
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-04-28 14:56:27 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-28 14:56:27 -0700
commitaef780db30c434e1d681d81852fb13160e72ed1e (patch)
tree24810c630b3b27649c0dd856d795c0069ca5bcd6 /xfa/fxbarcode/qrcode
parent8e957baa851aed4b02511d04a66c0f95387d1e10 (diff)
downloadpdfium-aef780db30c434e1d681d81852fb13160e72ed1e.tar.xz
Replace CFX_PtrArray with typesafe CFX_ArrayTemplate, part 4
Review-Url: https://codereview.chromium.org/1932703003
Diffstat (limited to 'xfa/fxbarcode/qrcode')
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp42
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h19
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp26
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRCoderVersion.h33
-rw-r--r--xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp6
5 files changed, 64 insertions, 62 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
index eb6d194b55..507c91878e 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.cpp
@@ -24,36 +24,40 @@
#include "xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h"
CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
- CBC_QRCoderECB* ecBlocks) {
- m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;
- m_ecBlocks.Add(ecBlocks);
+ CBC_QRCoderECB* ecBlocks)
+ : m_ecCodeWordsPerBlock(ecCodeWordsPerBlock) {
+ m_ecBlocksArray.Add(ecBlocks);
}
+
CBC_QRCoderECBlocks::CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
CBC_QRCoderECB* ecBlocks1,
- CBC_QRCoderECB* ecBlocks2) {
- m_ecCodeWordsPerBlock = ecCodeWordsPerBlock;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
+ CBC_QRCoderECB* ecBlocks2)
+ : m_ecCodeWordsPerBlock(ecCodeWordsPerBlock) {
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
}
+
CBC_QRCoderECBlocks::~CBC_QRCoderECBlocks() {
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- delete ((CBC_QRCoderECB*)(m_ecBlocks[i]));
- }
- m_ecBlocks.RemoveAll();
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ delete m_ecBlocksArray[i];
}
-int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() {
+
+int32_t CBC_QRCoderECBlocks::GetECCodeWordsPerBlock() const {
return m_ecCodeWordsPerBlock;
}
-int32_t CBC_QRCoderECBlocks::GetNumBlocks() {
+
+int32_t CBC_QRCoderECBlocks::GetNumBlocks() const {
int32_t total = 0;
- for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
- total += ((CBC_QRCoderECB*)(m_ecBlocks[i]))->GetCount();
- }
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); i++)
+ total += m_ecBlocksArray[i]->GetCount();
+
return total;
}
-int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() {
+
+int32_t CBC_QRCoderECBlocks::GetTotalECCodeWords() const {
return m_ecCodeWordsPerBlock * GetNumBlocks();
}
-CFX_PtrArray* CBC_QRCoderECBlocks::GetECBlocks() {
- return &m_ecBlocks;
+
+CFX_ArrayTemplate<CBC_QRCoderECB*>* CBC_QRCoderECBlocks::GetECBlocks() {
+ return &m_ecBlocksArray;
}
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
index 5209a5f8d8..cd1539a7b7 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderECBlocks.h
@@ -12,20 +12,21 @@
class CBC_QRCoderECB;
class CBC_QRCoderECBlocks {
- private:
- int32_t m_ecCodeWordsPerBlock;
- CFX_PtrArray m_ecBlocks;
-
public:
CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock, CBC_QRCoderECB* ecBlocks);
CBC_QRCoderECBlocks(int32_t ecCodeWordsPerBlock,
CBC_QRCoderECB* ecBlocks1,
CBC_QRCoderECB* ecBlocks2);
- virtual ~CBC_QRCoderECBlocks();
- int32_t GetECCodeWordsPerBlock();
- int32_t GetNumBlocks();
- int32_t GetTotalECCodeWords();
- CFX_PtrArray* GetECBlocks();
+ ~CBC_QRCoderECBlocks();
+
+ int32_t GetECCodeWordsPerBlock() const;
+ int32_t GetNumBlocks() const;
+ int32_t GetTotalECCodeWords() const;
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* GetECBlocks();
+
+ private:
+ int32_t m_ecCodeWordsPerBlock;
+ CFX_ArrayTemplate<CBC_QRCoderECB*> m_ecBlocksArray;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERECBLOCKS_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
index 1ff557ede2..e92267819c 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.cpp
@@ -53,15 +53,15 @@ CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
CBC_QRCoderECBlocks* ecBlocks3,
CBC_QRCoderECBlocks* ecBlocks4) {
m_versionNumber = versionNumber;
- m_ecBlocks.Add(ecBlocks1);
- m_ecBlocks.Add(ecBlocks2);
- m_ecBlocks.Add(ecBlocks3);
- m_ecBlocks.Add(ecBlocks4);
+ m_ecBlocksArray.Add(ecBlocks1);
+ m_ecBlocksArray.Add(ecBlocks2);
+ m_ecBlocksArray.Add(ecBlocks3);
+ m_ecBlocksArray.Add(ecBlocks4);
int32_t total = 0;
int32_t ecCodeWords = ecBlocks1->GetECCodeWordsPerBlock();
- CFX_PtrArray* ecbArray = ecBlocks1->GetECBlocks();
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* ecbArray = ecBlocks1->GetECBlocks();
for (int32_t i = 0; i < ecbArray->GetSize(); i++) {
- CBC_QRCoderECB* ecBlock = (CBC_QRCoderECB*)((*ecbArray)[i]);
+ CBC_QRCoderECB* ecBlock = (*ecbArray)[i];
total += ecBlock->GetCount() * (ecBlock->GetDataCodeWords() + ecCodeWords);
}
m_totalCodeWords = total;
@@ -326,16 +326,12 @@ CBC_QRCoderVersion::CBC_QRCoderVersion(int32_t versionNumber,
break;
}
}
+
CBC_QRCoderVersion::~CBC_QRCoderVersion() {
- if (m_ecBlocks.GetSize() != 0) {
- int32_t itBeg = 0;
- int32_t itEnd = m_ecBlocks.GetSize();
- while (itBeg != itEnd) {
- delete ((CBC_QRCoderECBlocks*)(m_ecBlocks[itBeg]));
- itBeg++;
- }
- }
+ for (int32_t i = 0; i < m_ecBlocksArray.GetSize(); ++i)
+ delete m_ecBlocksArray[i];
}
+
int32_t CBC_QRCoderVersion::GetVersionNumber() {
return m_versionNumber;
}
@@ -350,7 +346,7 @@ int32_t CBC_QRCoderVersion::GetDimensionForVersion() {
}
CBC_QRCoderECBlocks* CBC_QRCoderVersion::GetECBlocksForLevel(
CBC_QRCoderErrorCorrectionLevel* ecLevel) {
- return (CBC_QRCoderECBlocks*)m_ecBlocks[ecLevel->Ordinal()];
+ return m_ecBlocksArray[ecLevel->Ordinal()];
}
CBC_QRCoderVersion* CBC_QRCoderVersion::GetProvisionalVersionForDimension(
int32_t dimension,
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
index 0cbace0251..05bd71934d 100644
--- a/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
+++ b/xfa/fxbarcode/qrcode/BC_QRCoderVersion.h
@@ -9,26 +9,11 @@
#include "core/fxcrt/include/fx_basic.h"
-class CBC_QRCoderECBlocks;
class CBC_CommonBitMatrix;
+class CBC_QRCoderECBlocks;
class CBC_QRCoderErrorCorrectionLevel;
class CBC_QRCoderVersion {
- private:
- static const int32_t VERSION_DECODE_INFO[34];
- static CFX_PtrArray* VERSION;
- int32_t m_versionNumber;
- int32_t m_totalCodeWords;
- CFX_Int32Array m_alignmentPatternCenters;
- CFX_PtrArray m_ecBlocks;
-
- CBC_QRCoderVersion();
- CBC_QRCoderVersion(int32_t versionNumber,
- CBC_QRCoderECBlocks* ecBlocks1,
- CBC_QRCoderECBlocks* ecBlocks2,
- CBC_QRCoderECBlocks* ecBlocks3,
- CBC_QRCoderECBlocks* ecBlocks4);
-
public:
virtual ~CBC_QRCoderVersion();
static void Initialize();
@@ -49,6 +34,22 @@ class CBC_QRCoderVersion {
static CBC_QRCoderVersion* DecodeVersionInformation(int32_t versionBits,
int32_t& e);
static void Destroy();
+
+ private:
+ CBC_QRCoderVersion();
+ CBC_QRCoderVersion(int32_t versionNumber,
+ CBC_QRCoderECBlocks* ecBlocks1,
+ CBC_QRCoderECBlocks* ecBlocks2,
+ CBC_QRCoderECBlocks* ecBlocks3,
+ CBC_QRCoderECBlocks* ecBlocks4);
+
+ static const int32_t VERSION_DECODE_INFO[34];
+ static CFX_PtrArray* VERSION;
+
+ int32_t m_versionNumber;
+ int32_t m_totalCodeWords;
+ CFX_Int32Array m_alignmentPatternCenters;
+ CFX_ArrayTemplate<CBC_QRCoderECBlocks*> m_ecBlocksArray;
};
#endif // XFA_FXBARCODE_QRCODE_BC_QRCODERVERSION_H_
diff --git a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
index 9805ac9af8..721301cccc 100644
--- a/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
+++ b/xfa/fxbarcode/qrcode/BC_QRDataBlock.cpp
@@ -52,16 +52,16 @@ CFX_PtrArray* CBC_QRDataBlock::GetDataBlocks(
}
CBC_QRCoderECBlocks* ecBlocks = version->GetECBlocksForLevel(ecLevel);
int32_t totalBlocks = 0;
- CFX_PtrArray* ecBlockArray = ecBlocks->GetECBlocks();
+ CFX_ArrayTemplate<CBC_QRCoderECB*>* ecBlockArray = ecBlocks->GetECBlocks();
int32_t i = 0;
for (i = 0; i < ecBlockArray->GetSize(); i++) {
- totalBlocks += ((CBC_QRCoderECB*)(*ecBlockArray)[i])->GetCount();
+ totalBlocks += (*ecBlockArray)[i]->GetCount();
}
std::unique_ptr<CFX_PtrArray> 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];
+ CBC_QRCoderECB* ecBlock = (*ecBlockArray)[j];
for (int32_t k = 0; k < ecBlock->GetCount(); k++) {
int32_t numDataCodewords = ecBlock->GetDataCodeWords();
int32_t numBlockCodewords =