summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/datamatrix
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/datamatrix
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/datamatrix')
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixDataBlock.cpp4
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.cpp6
-rw-r--r--xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h36
3 files changed, 20 insertions, 26 deletions
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<ECB*>& 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<CFX_PtrArray> 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<ECB*>& 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<ECB*>& GetECBlocks() { return m_ecBlocksArray; }
private:
int32_t m_ecCodewords;
- CFX_PtrArray m_ecBlocks;
+ CFX_ArrayTemplate<ECB*> m_ecBlocksArray;
};
class CBC_DataMatrixVersion {