summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp')
-rw-r--r--xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp114
1 files changed, 56 insertions, 58 deletions
diff --git a/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp
index d3d68541c4..b6323041f9 100644
--- a/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp
+++ b/xfa/fxbarcode/datamatrix/BC_SymbolInfo.cpp
@@ -20,67 +20,66 @@
* limitations under the License.
*/
+#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h"
+
#include "xfa/fxbarcode/BC_Dimension.h"
#include "xfa/fxbarcode/common/BC_CommonBitMatrix.h"
#include "xfa/fxbarcode/datamatrix/BC_DataMatrixSymbolInfo144.h"
#include "xfa/fxbarcode/datamatrix/BC_Encoder.h"
-#include "xfa/fxbarcode/datamatrix/BC_SymbolInfo.h"
#include "xfa/fxbarcode/datamatrix/BC_SymbolShapeHint.h"
-#define SYMBOLS_COUNT 30
+namespace {
+
+const size_t kSymbolsCount = 30;
+
+CBC_SymbolInfo* g_symbols[kSymbolsCount] = {
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
+ nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
+
+} // namespace
-CBC_SymbolInfo* CBC_SymbolInfo::m_PROD_SYMBOLS[30] = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
-CBC_SymbolInfo* CBC_SymbolInfo::m_symbols[30] = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
void CBC_SymbolInfo::Initialize() {
- m_PROD_SYMBOLS[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1);
- m_PROD_SYMBOLS[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1);
- m_PROD_SYMBOLS[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1);
- m_PROD_SYMBOLS[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1);
- m_PROD_SYMBOLS[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2);
- m_PROD_SYMBOLS[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1);
- m_PROD_SYMBOLS[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1);
- m_PROD_SYMBOLS[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1);
- m_PROD_SYMBOLS[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1);
- m_PROD_SYMBOLS[9] = new CBC_SymbolInfo(TRUE, 22, 18, 16, 10, 2);
- m_PROD_SYMBOLS[10] = new CBC_SymbolInfo(FALSE, 30, 20, 20, 20, 1);
- m_PROD_SYMBOLS[11] = new CBC_SymbolInfo(TRUE, 32, 24, 16, 14, 2);
- m_PROD_SYMBOLS[12] = new CBC_SymbolInfo(FALSE, 36, 24, 22, 22, 1);
- m_PROD_SYMBOLS[13] = new CBC_SymbolInfo(FALSE, 44, 28, 24, 24, 1);
- m_PROD_SYMBOLS[14] = new CBC_SymbolInfo(TRUE, 49, 28, 22, 14, 2);
- m_PROD_SYMBOLS[15] = new CBC_SymbolInfo(FALSE, 62, 36, 14, 14, 4);
- m_PROD_SYMBOLS[16] = new CBC_SymbolInfo(FALSE, 86, 42, 16, 16, 4);
- m_PROD_SYMBOLS[17] = new CBC_SymbolInfo(FALSE, 114, 48, 18, 18, 4);
- m_PROD_SYMBOLS[18] = new CBC_SymbolInfo(FALSE, 144, 56, 20, 20, 4);
- m_PROD_SYMBOLS[19] = new CBC_SymbolInfo(FALSE, 174, 68, 22, 22, 4);
- m_PROD_SYMBOLS[20] = new CBC_SymbolInfo(FALSE, 204, 84, 24, 24, 4, 102, 42);
- m_PROD_SYMBOLS[21] = new CBC_SymbolInfo(FALSE, 280, 112, 14, 14, 16, 140, 56);
- m_PROD_SYMBOLS[22] = new CBC_SymbolInfo(FALSE, 368, 144, 16, 16, 16, 92, 36);
- m_PROD_SYMBOLS[23] = new CBC_SymbolInfo(FALSE, 456, 192, 18, 18, 16, 114, 48);
- m_PROD_SYMBOLS[24] = new CBC_SymbolInfo(FALSE, 576, 224, 20, 20, 16, 144, 56);
- m_PROD_SYMBOLS[25] = new CBC_SymbolInfo(FALSE, 696, 272, 22, 22, 16, 174, 68);
- m_PROD_SYMBOLS[26] = new CBC_SymbolInfo(FALSE, 816, 336, 24, 24, 16, 136, 56);
- m_PROD_SYMBOLS[27] =
- new CBC_SymbolInfo(FALSE, 1050, 408, 18, 18, 36, 175, 68);
- m_PROD_SYMBOLS[28] =
- new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62);
- m_PROD_SYMBOLS[29] = new CBC_DataMatrixSymbolInfo144();
- for (int32_t i = 0; i < SYMBOLS_COUNT; i++) {
- m_symbols[i] = m_PROD_SYMBOLS[i];
- }
+ g_symbols[0] = new CBC_SymbolInfo(FALSE, 3, 5, 8, 8, 1);
+ g_symbols[1] = new CBC_SymbolInfo(FALSE, 5, 7, 10, 10, 1);
+ g_symbols[2] = new CBC_SymbolInfo(TRUE, 5, 7, 16, 6, 1);
+ g_symbols[3] = new CBC_SymbolInfo(FALSE, 8, 10, 12, 12, 1);
+ g_symbols[4] = new CBC_SymbolInfo(TRUE, 10, 11, 14, 6, 2);
+ g_symbols[5] = new CBC_SymbolInfo(FALSE, 12, 12, 14, 14, 1);
+ g_symbols[6] = new CBC_SymbolInfo(TRUE, 16, 14, 24, 10, 1);
+ g_symbols[7] = new CBC_SymbolInfo(FALSE, 18, 14, 16, 16, 1);
+ g_symbols[8] = new CBC_SymbolInfo(FALSE, 22, 18, 18, 18, 1);
+ g_symbols[9] = new CBC_SymbolInfo(TRUE, 22, 18, 16, 10, 2);
+ g_symbols[10] = new CBC_SymbolInfo(FALSE, 30, 20, 20, 20, 1);
+ g_symbols[11] = new CBC_SymbolInfo(TRUE, 32, 24, 16, 14, 2);
+ g_symbols[12] = new CBC_SymbolInfo(FALSE, 36, 24, 22, 22, 1);
+ g_symbols[13] = new CBC_SymbolInfo(FALSE, 44, 28, 24, 24, 1);
+ g_symbols[14] = new CBC_SymbolInfo(TRUE, 49, 28, 22, 14, 2);
+ g_symbols[15] = new CBC_SymbolInfo(FALSE, 62, 36, 14, 14, 4);
+ g_symbols[16] = new CBC_SymbolInfo(FALSE, 86, 42, 16, 16, 4);
+ g_symbols[17] = new CBC_SymbolInfo(FALSE, 114, 48, 18, 18, 4);
+ g_symbols[18] = new CBC_SymbolInfo(FALSE, 144, 56, 20, 20, 4);
+ g_symbols[19] = new CBC_SymbolInfo(FALSE, 174, 68, 22, 22, 4);
+ g_symbols[20] = new CBC_SymbolInfo(FALSE, 204, 84, 24, 24, 4, 102, 42);
+ g_symbols[21] = new CBC_SymbolInfo(FALSE, 280, 112, 14, 14, 16, 140, 56);
+ g_symbols[22] = new CBC_SymbolInfo(FALSE, 368, 144, 16, 16, 16, 92, 36);
+ g_symbols[23] = new CBC_SymbolInfo(FALSE, 456, 192, 18, 18, 16, 114, 48);
+ g_symbols[24] = new CBC_SymbolInfo(FALSE, 576, 224, 20, 20, 16, 144, 56);
+ g_symbols[25] = new CBC_SymbolInfo(FALSE, 696, 272, 22, 22, 16, 174, 68);
+ g_symbols[26] = new CBC_SymbolInfo(FALSE, 816, 336, 24, 24, 16, 136, 56);
+ g_symbols[27] = new CBC_SymbolInfo(FALSE, 1050, 408, 18, 18, 36, 175, 68);
+ g_symbols[28] = new CBC_SymbolInfo(FALSE, 1304, 496, 20, 20, 36, 163, 62);
+ g_symbols[29] = new CBC_DataMatrixSymbolInfo144();
}
+
void CBC_SymbolInfo::Finalize() {
- for (int32_t i = 0; i < SYMBOLS_COUNT; i++) {
- delete m_PROD_SYMBOLS[i];
- m_PROD_SYMBOLS[i] = NULL;
- m_symbols[i] = NULL;
+ for (size_t i = 0; i < kSymbolsCount; i++) {
+ delete g_symbols[i];
+ g_symbols[i] = nullptr;
}
}
+
CBC_SymbolInfo::CBC_SymbolInfo(FX_BOOL rectangular,
int32_t dataCapacity,
int32_t errorCodewords,
@@ -134,7 +133,7 @@ CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
SymbolShapeHint shape,
FX_BOOL fail,
int32_t& e) {
- return lookup(dataCodewords, shape, NULL, NULL, fail, e);
+ return lookup(dataCodewords, shape, nullptr, nullptr, fail, e);
}
CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
SymbolShapeHint shape,
@@ -142,8 +141,8 @@ CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
CBC_Dimension* maxSize,
FX_BOOL fail,
int32_t& e) {
- for (int32_t i = 0; i < SYMBOLS_COUNT; i++) {
- CBC_SymbolInfo* symbol = m_symbols[i];
+ for (size_t i = 0; i < kSymbolsCount; i++) {
+ CBC_SymbolInfo* symbol = g_symbols[i];
if (shape == FORCE_SQUARE && symbol->m_rectangular) {
continue;
}
@@ -152,24 +151,23 @@ CBC_SymbolInfo* CBC_SymbolInfo::lookup(int32_t dataCodewords,
}
if (minSize && (symbol->getSymbolWidth(e) < minSize->getWidth() ||
symbol->getSymbolHeight(e) < minSize->getHeight())) {
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
continue;
}
if (maxSize && (symbol->getSymbolWidth(e) > maxSize->getWidth() ||
symbol->getSymbolHeight(e) > maxSize->getHeight())) {
- BC_EXCEPTION_CHECK_ReturnValue(e, NULL);
+ BC_EXCEPTION_CHECK_ReturnValue(e, nullptr);
continue;
}
if (dataCodewords <= symbol->m_dataCapacity) {
return symbol;
}
}
- if (fail) {
+ if (fail)
e = BCExceptionIllegalDataCodewords;
- return NULL;
- }
- return NULL;
+ return nullptr;
}
+
int32_t CBC_SymbolInfo::getHorizontalDataRegions(int32_t& e) {
switch (m_dataRegions) {
case 1: