diff options
author | weili <weili@chromium.org> | 2016-08-09 13:45:03 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-08-09 13:45:03 -0700 |
commit | e76203dbefd1df075a063ee019c3908513f6bee5 (patch) | |
tree | 2a763852e1d1de3eee6a67285ea96be2874bfb00 /xfa/fxbarcode/qrcode/BC_QRCoder.h | |
parent | ad5ac7584844b03c5ceed082e5f5158a632405cc (diff) | |
download | pdfium-e76203dbefd1df075a063ee019c3908513f6bee5.tar.xz |
Use smart pointers for class owned pointers in xfa/fxbarcode
For classes under xfa/fxbarcode, use smart pointers instead
of raw pointer to make memory management easier.
Also fix some styling issues along the changes.
BUG=pdfium:518
Review-Url: https://codereview.chromium.org/2221023003
Diffstat (limited to 'xfa/fxbarcode/qrcode/BC_QRCoder.h')
-rw-r--r-- | xfa/fxbarcode/qrcode/BC_QRCoder.h | 56 |
1 files changed, 31 insertions, 25 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoder.h b/xfa/fxbarcode/qrcode/BC_QRCoder.h index bbf7bd4429..bbb37355f2 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCoder.h +++ b/xfa/fxbarcode/qrcode/BC_QRCoder.h @@ -7,37 +7,32 @@ #ifndef XFA_FXBARCODE_QRCODE_BC_QRCODER_H_ #define XFA_FXBARCODE_QRCODE_BC_QRCODER_H_ +#include <memory> + class CBC_QRCoderErrorCorrectionLevel; class CBC_QRCoderMode; class CBC_CommonByteMatrix; class CBC_QRCoder { - private: - CBC_QRCoderMode* m_mode; - CBC_QRCoderErrorCorrectionLevel* m_ecLevel; - int32_t m_version; - int32_t m_matrixWidth; - int32_t m_maskPattern; - int32_t m_numTotalBytes; - int32_t m_numDataBytes; - int32_t m_numECBytes; - int32_t m_numRSBlocks; - CBC_CommonByteMatrix* m_matrix; - public: - static const int32_t NUM_MASK_PATTERNS; + static constexpr int32_t kNumMaskPatterns = 8; + CBC_QRCoder(); virtual ~CBC_QRCoder(); - CBC_QRCoderMode* GetMode(); - CBC_QRCoderErrorCorrectionLevel* GetECLevel(); - int32_t GetVersion(); - int32_t GetMatrixWidth(); - int32_t GetMaskPattern(); - int32_t GetNumTotalBytes(); - int32_t GetNumDataBytes(); - int32_t GetNumECBytes(); - int32_t GetNumRSBlocks(); - CBC_CommonByteMatrix* GetMatrix(); + + static bool IsValidMaskPattern(int32_t maskPattern); + + CBC_QRCoderMode* GetMode() const; + CBC_QRCoderErrorCorrectionLevel* GetECLevel() const; + int32_t GetVersion() const; + int32_t GetMatrixWidth() const; + int32_t GetMaskPattern() const; + int32_t GetNumTotalBytes() const; + int32_t GetNumDataBytes() const; + int32_t GetNumECBytes() const; + int32_t GetNumRSBlocks() const; + CBC_CommonByteMatrix* GetMatrix() const; + int32_t At(int32_t x, int32_t y, int32_t& e); FX_BOOL IsValid(); @@ -50,8 +45,19 @@ class CBC_QRCoder { void SetNumTotalBytes(int32_t value); void SetNumECBytes(int32_t value); void SetNumRSBlocks(int32_t block); - void SetMatrix(CBC_CommonByteMatrix* value); - static FX_BOOL IsValidMaskPattern(int32_t maskPattern); + void SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix); + + private: + CBC_QRCoderMode* m_mode; + CBC_QRCoderErrorCorrectionLevel* m_ecLevel; + int32_t m_version; + int32_t m_matrixWidth; + int32_t m_maskPattern; + int32_t m_numTotalBytes; + int32_t m_numDataBytes; + int32_t m_numECBytes; + int32_t m_numRSBlocks; + std::unique_ptr<CBC_CommonByteMatrix> m_matrix; }; #endif // XFA_FXBARCODE_QRCODE_BC_QRCODER_H_ |