1 // Copyright 2014 The PDFium Authors 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_CommonByteMatrix; 16 17 class CBC_QRCoder final { 18 public: 19 static constexpr int32_t kNumMaskPatterns = 8; 20 21 CBC_QRCoder(); 22 ~CBC_QRCoder(); 23 24 static bool IsValidMaskPattern(int32_t maskPattern); 25 26 const CBC_QRCoderErrorCorrectionLevel* GetECLevel() const; 27 int32_t GetVersion() const; 28 int32_t GetMatrixWidth() const; 29 int32_t GetMaskPattern() const; 30 int32_t GetNumTotalBytes() const; 31 int32_t GetNumDataBytes() const; 32 int32_t GetNumRSBlocks() const; 33 std::unique_ptr<CBC_CommonByteMatrix> TakeMatrix(); 34 35 bool IsValid() const; 36 37 void SetECLevel(const CBC_QRCoderErrorCorrectionLevel* ecLevel); 38 void SetVersion(int32_t version); 39 void SetMatrixWidth(int32_t width); 40 void SetMaskPattern(int32_t pattern); 41 void SetNumDataBytes(int32_t bytes); 42 void SetNumTotalBytes(int32_t value); 43 void SetNumECBytes(int32_t value); 44 void SetNumRSBlocks(int32_t block); 45 void SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix); 46 47 private: 48 UnownedPtr<const CBC_QRCoderErrorCorrectionLevel> m_ecLevel; 49 int32_t m_version = -1; 50 int32_t m_matrixWidth = -1; 51 int32_t m_maskPattern = -1; 52 int32_t m_numTotalBytes = -1; 53 int32_t m_numDataBytes = -1; 54 int32_t m_numECBytes = -1; 55 int32_t m_numRSBlocks = -1; 56 std::unique_ptr<CBC_CommonByteMatrix> m_matrix; 57 }; 58 59 #endif // FXBARCODE_QRCODE_BC_QRCODER_H_ 60