1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef FXBARCODE_QRCODE_BC_QRCODER_H_
8 #define FXBARCODE_QRCODE_BC_QRCODER_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/unowned_ptr.h"
13 
14 class CBC_QRCoderErrorCorrectionLevel;
15 class CBC_QRCoderMode;
16 class CBC_CommonByteMatrix;
17 
18 class CBC_QRCoder final {
19  public:
20   static constexpr int32_t kNumMaskPatterns = 8;
21 
22   CBC_QRCoder();
23   ~CBC_QRCoder();
24 
25   static bool IsValidMaskPattern(int32_t maskPattern);
26 
27   const CBC_QRCoderErrorCorrectionLevel* GetECLevel() const;
28   int32_t GetVersion() const;
29   int32_t GetMatrixWidth() const;
30   int32_t GetMaskPattern() const;
31   int32_t GetNumTotalBytes() const;
32   int32_t GetNumDataBytes() const;
33   int32_t GetNumRSBlocks() const;
34   const CBC_CommonByteMatrix* GetMatrix() const;
35 
36   bool IsValid() const;
37 
38   void SetECLevel(const CBC_QRCoderErrorCorrectionLevel* ecLevel);
39   void SetVersion(int32_t version);
40   void SetMatrixWidth(int32_t width);
41   void SetMaskPattern(int32_t pattern);
42   void SetNumDataBytes(int32_t bytes);
43   void SetNumTotalBytes(int32_t value);
44   void SetNumECBytes(int32_t value);
45   void SetNumRSBlocks(int32_t block);
46   void SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix);
47 
48  private:
49   UnownedPtr<const CBC_QRCoderErrorCorrectionLevel> m_ecLevel;
50   int32_t m_version = -1;
51   int32_t m_matrixWidth = -1;
52   int32_t m_maskPattern = -1;
53   int32_t m_numTotalBytes = -1;
54   int32_t m_numDataBytes = -1;
55   int32_t m_numECBytes = -1;
56   int32_t m_numRSBlocks = -1;
57   std::unique_ptr<CBC_CommonByteMatrix> m_matrix;
58 };
59 
60 #endif  // FXBARCODE_QRCODE_BC_QRCODER_H_
61