diff options
Diffstat (limited to 'xfa/fxbarcode/qrcode/BC_QRCoder.cpp')
-rw-r--r-- | xfa/fxbarcode/qrcode/BC_QRCoder.cpp | 83 |
1 files changed, 52 insertions, 31 deletions
diff --git a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp index 580ea7ded1..4c7956ed68 100644 --- a/xfa/fxbarcode/qrcode/BC_QRCoder.cpp +++ b/xfa/fxbarcode/qrcode/BC_QRCoder.cpp @@ -20,57 +20,67 @@ * limitations under the License. */ +#include <utility> + #include "xfa/fxbarcode/common/BC_CommonByteMatrix.h" #include "xfa/fxbarcode/qrcode/BC_QRCoder.h" #include "xfa/fxbarcode/qrcode/BC_QRCoderErrorCorrectionLevel.h" #include "xfa/fxbarcode/qrcode/BC_QRCoderMode.h" #include "xfa/fxbarcode/utils.h" -CBC_QRCoder::CBC_QRCoder() { - m_mode = nullptr; - m_ecLevel = nullptr; - m_version = -1; - m_matrixWidth = -1; - m_maskPattern = -1; - m_numTotalBytes = -1; - m_numDataBytes = -1; - m_numECBytes = -1; - m_numRSBlocks = -1; - m_matrix = nullptr; -} -CBC_QRCoder::~CBC_QRCoder() { - delete m_matrix; -} -CBC_QRCoderMode* CBC_QRCoder::GetMode() { +CBC_QRCoder::CBC_QRCoder() + : m_mode(nullptr), + m_ecLevel(nullptr), + m_version(-1), + m_matrixWidth(-1), + m_maskPattern(-1), + m_numTotalBytes(-1), + m_numDataBytes(-1), + m_numECBytes(-1), + m_numRSBlocks(-1) {} + +CBC_QRCoder::~CBC_QRCoder() {} + +CBC_QRCoderMode* CBC_QRCoder::GetMode() const { return m_mode; } -CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() { + +CBC_QRCoderErrorCorrectionLevel* CBC_QRCoder::GetECLevel() const { return m_ecLevel; } -int32_t CBC_QRCoder::GetVersion() { + +int32_t CBC_QRCoder::GetVersion() const { return m_version; } -int32_t CBC_QRCoder::GetMatrixWidth() { + +int32_t CBC_QRCoder::GetMatrixWidth() const { return m_matrixWidth; } -int32_t CBC_QRCoder::GetMaskPattern() { + +int32_t CBC_QRCoder::GetMaskPattern() const { return m_maskPattern; } -int32_t CBC_QRCoder::GetNumTotalBytes() { + +int32_t CBC_QRCoder::GetNumTotalBytes() const { return m_numTotalBytes; } -int32_t CBC_QRCoder::GetNumDataBytes() { + +int32_t CBC_QRCoder::GetNumDataBytes() const { return m_numDataBytes; } -int32_t CBC_QRCoder::GetNumECBytes() { + +int32_t CBC_QRCoder::GetNumECBytes() const { return m_numECBytes; } -int32_t CBC_QRCoder::GetNumRSBlocks() { + +int32_t CBC_QRCoder::GetNumRSBlocks() const { return m_numRSBlocks; } -CBC_CommonByteMatrix* CBC_QRCoder::GetMatrix() { - return m_matrix; + +CBC_CommonByteMatrix* CBC_QRCoder::GetMatrix() const { + return m_matrix.get(); } + int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) { int32_t value = m_matrix->Get(x, y); if (!(value == 0 || value == 1)) { @@ -79,6 +89,7 @@ int32_t CBC_QRCoder::At(int32_t x, int32_t y, int32_t& e) { } return value; } + FX_BOOL CBC_QRCoder::IsValid() { return m_mode && m_ecLevel && m_version != -1 && m_matrixWidth != -1 && m_maskPattern != -1 && m_numTotalBytes != -1 && m_numDataBytes != -1 && @@ -88,37 +99,47 @@ FX_BOOL CBC_QRCoder::IsValid() { m_matrixWidth == m_matrix->GetWidth() && m_matrix->GetWidth() == m_matrix->GetHeight(); } + void CBC_QRCoder::SetMode(CBC_QRCoderMode* value) { m_mode = value; } + void CBC_QRCoder::SetECLevel(CBC_QRCoderErrorCorrectionLevel* ecLevel) { m_ecLevel = ecLevel; } + void CBC_QRCoder::SetVersion(int32_t version) { m_version = version; } + void CBC_QRCoder::SetMatrixWidth(int32_t width) { m_matrixWidth = width; } + void CBC_QRCoder::SetMaskPattern(int32_t pattern) { m_maskPattern = pattern; } + void CBC_QRCoder::SetNumDataBytes(int32_t bytes) { m_numDataBytes = bytes; } + void CBC_QRCoder::SetNumTotalBytes(int32_t value) { m_numTotalBytes = value; } + void CBC_QRCoder::SetNumRSBlocks(int32_t block) { m_numRSBlocks = block; } + void CBC_QRCoder::SetNumECBytes(int32_t value) { m_numECBytes = value; } -FX_BOOL CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) { - return maskPattern >= 0 && maskPattern < NUM_MASK_PATTERNS; + +bool CBC_QRCoder::IsValidMaskPattern(int32_t maskPattern) { + return maskPattern >= 0 && maskPattern < kNumMaskPatterns; } -void CBC_QRCoder::SetMatrix(CBC_CommonByteMatrix* value) { - m_matrix = value; + +void CBC_QRCoder::SetMatrix(std::unique_ptr<CBC_CommonByteMatrix> pMatrix) { + m_matrix = std::move(pMatrix); } -const int32_t CBC_QRCoder::NUM_MASK_PATTERNS = 8; |