summaryrefslogtreecommitdiff
path: root/xfa/fxbarcode/datamatrix/BC_DataMatrixVersion.h
blob: 8a7935515315c7bf3ee762593cd066b4074ad801 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_
#define XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_

#include "core/include/fxcrt/fx_basic.h"

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; }

  int32_t GetDataCodewords() { return m_dataCodewords; }

 private:
  int32_t m_count;
  int32_t m_dataCodewords;
};

class ECBlocks {
 public:
  ECBlocks(int32_t ecCodewords, ECB* ecBlocks) {
    m_ecCodewords = ecCodewords;
    m_ecBlocks.Add(ecBlocks);
  }

  ECBlocks(int32_t ecCodewords, ECB* ecBlocks1, ECB* ecBlocks2) {
    m_ecCodewords = ecCodewords;
    m_ecBlocks.Add(ecBlocks1);
    m_ecBlocks.Add(ecBlocks2);
  }
  ~ECBlocks() {
    for (int32_t i = 0; i < m_ecBlocks.GetSize(); i++) {
      delete (ECB*)m_ecBlocks[i];
    }
    m_ecBlocks.RemoveAll();
  }

  int32_t GetECCodewords() { return m_ecCodewords; }

  const CFX_PtrArray& GetECBlocks() { return m_ecBlocks; }

 private:
  int32_t m_ecCodewords;
  CFX_PtrArray m_ecBlocks;
};

class CBC_DataMatrixVersion {
 public:
  CBC_DataMatrixVersion(int32_t versionNumber,
                        int32_t symbolSizeRows,
                        int32_t symbolSizeColumns,
                        int32_t dataRegionSizeRows,
                        int32_t dataRegionSizeColumns,
                        ECBlocks* ecBlocks);
  virtual ~CBC_DataMatrixVersion();
  static void Initialize();
  static void Finalize();
  int32_t GetVersionNumber();
  int32_t GetSymbolSizeRows();
  int32_t GetSymbolSizeColumns();
  int32_t GetDataRegionSizeRows();
  int32_t GetDataRegionSizeColumns();
  int32_t GetTotalCodewords();
  ECBlocks* GetECBlocks();
  static CBC_DataMatrixVersion* GetVersionForDimensions(int32_t numRows,
                                                        int32_t numColumns,
                                                        int32_t& e);
  static void ReleaseAll();

 private:
  int32_t m_versionNumber;
  int32_t m_symbolSizeRows;
  int32_t m_symbolSizeColumns;
  int32_t m_dataRegionSizeRows;
  int32_t m_dataRegionSizeColumns;
  ECBlocks* m_ecBlocks;
  int32_t m_totalCodewords;
  static CFX_PtrArray* VERSIONS;
};

#endif  // XFA_FXBARCODE_DATAMATRIX_BC_DATAMATRIXVERSION_H_