• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
19  public:
20   static constexpr int32_t kNumMaskPatterns = 8;
21 
22   CBC_QRCoder();
23   virtual ~CBC_QRCoder();
24 
25   static bool IsValidMaskPattern(int32_t maskPattern);
26 
27   CBC_QRCoderMode* GetMode() const;
28   const CBC_QRCoderErrorCorrectionLevel* GetECLevel() const;
29   int32_t GetVersion() const;
30   int32_t GetMatrixWidth() const;
31   int32_t GetMaskPattern() const;
32   int32_t GetNumTotalBytes() const;
33   int32_t GetNumDataBytes() const;
34   int32_t GetNumECBytes() const;
35   int32_t GetNumRSBlocks() const;
36   CBC_CommonByteMatrix* GetMatrix() const;
37 
38   int32_t At(int32_t x, int32_t y, int32_t& e);
39   bool IsValid();
40 
41   void SetMode(CBC_QRCoderMode* value);
42   void SetECLevel(const CBC_QRCoderErrorCorrectionLevel* ecLevel);
43   void SetVersion(int32_t version);
44   void SetMatrixWidth(int32_t width);
45   void SetMaskPattern(int32_t pattern);
46   void SetNumDataBytes(int32_t bytes);
47   void SetNumTotalBytes(int32_t value);
48   void SetNumECBytes(int32_t value);
49   void SetNumRSBlocks(int32_t block);
50   void SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix);
51 
52  private:
53   UnownedPtr<CBC_QRCoderMode> m_mode;
54   UnownedPtr<const CBC_QRCoderErrorCorrectionLevel> m_ecLevel;
55   int32_t m_version;
56   int32_t m_matrixWidth;
57   int32_t m_maskPattern;
58   int32_t m_numTotalBytes;
59   int32_t m_numDataBytes;
60   int32_t m_numECBytes;
61   int32_t m_numRSBlocks;
62   std::unique_ptr<CBC_CommonByteMatrix> m_matrix;
63 };
64 
65 #endif  // FXBARCODE_QRCODE_BC_QRCODER_H_
66