diff --git a/source/zxing/zxing/qrcode/encoder/QRCode.cpp b/source/zxing/zxing/qrcode/encoder/QRCode.cpp index a6572fe..fad09bb 100644 --- a/source/zxing/zxing/qrcode/encoder/QRCode.cpp +++ b/source/zxing/zxing/qrcode/encoder/QRCode.cpp @@ -12,81 +12,91 @@ QRCode::QRCode() : maskPattern_(-1), matrix_ptr_(NULL) {} -const Mode *QRCode::getMode() const +QRCode::~QRCode() { - return mode_ptr_; + if(mode_ptr_) + delete mode_ptr_; + + if(ecLevel_ptr_) + delete ecLevel_ptr_; + + if(version_ptr_) + delete version_ptr_; + + if(matrix_ptr_) + delete matrix_ptr_; } -const ErrorCorrectionLevel *QRCode::getECLevel() const +const Mode* QRCode::getMode() const { - return ecLevel_ptr_; + return mode_ptr_; } -const Version *QRCode::getVersion() const +const ErrorCorrectionLevel* QRCode::getECLevel() const { - return version_ptr_; + return ecLevel_ptr_; +} + +const Version* QRCode::getVersion() const +{ + return version_ptr_; } const int QRCode::getMaskPattern() const { - return maskPattern_; + return maskPattern_; } -const ByteMatrix *QRCode::getMatrix() const +const ByteMatrix* QRCode::getMatrix() const { - return matrix_ptr_; + return matrix_ptr_; } const std::string QRCode::toString() { - std::stringstream result; - result << "<<\n"; - result << " mode: {unimpl}"; - //result << mode_; - result << "\n ecLevel: {unimpl}"; - //result << ecLevel_; - result << "\n version: "; - //result << version_; - result << "\n maskPattern: "; - result << maskPattern_; -// if (matrix_ == null) { -// result.append("\n matrix: null\n"); -// } else { + std::stringstream result; + result << "<<\n"; + result << " mode: {unimpl}"; + result << mode_ptr_; + result << "\n ecLevel: {unimpl}"; + //result << ecLevel_; + result << "\n version: "; + //result << version_; + result << "\n maskPattern: "; + result << maskPattern_; + // if (matrix_ == null) { + // result.append("\n matrix: null\n"); + // } else { result << "\n matrix:\n"; result << matrix_ptr_->toString(); -// } - result << ">>\n"; - return result.str(); + // } + result << ">>\n"; + return result.str(); } -void QRCode::setMode(const Mode& value) +void QRCode::setMode(Mode *value) { - mode_ptr_ = new Mode(value); + mode_ptr_ = value; } -/* - * Make copy constructors for all the used classes. - * Also make destructors for all - */ - -void QRCode::setECLevel(const ErrorCorrectionLevel& value) +void QRCode::setECLevel(ErrorCorrectionLevel* value) { - //ecLevel_ptr_ = value; + ecLevel_ptr_ = value; } -void QRCode::setVersion(const Version& version) +void QRCode::setVersion(Version *version) { - //version_ptr_ = version; + version_ptr_ = version; } void QRCode::setMaskPattern(int value) { - //maskPattern_ptr_ = value; + maskPattern_ = value; } -void QRCode::setMatrix(const ByteMatrix &value) +void QRCode::setMatrix(ByteMatrix *value) { - //matrix_ptr_ = value; + matrix_ptr_ = value; } } diff --git a/source/zxing/zxing/qrcode/encoder/QRCode.h b/source/zxing/zxing/qrcode/encoder/QRCode.h index ace1900..26b5a5a 100644 --- a/source/zxing/zxing/qrcode/encoder/QRCode.h +++ b/source/zxing/zxing/qrcode/encoder/QRCode.h @@ -24,17 +24,18 @@ private: public: QRCode(); + ~QRCode(); const Mode* getMode() const; const ErrorCorrectionLevel* getECLevel() const; const Version* getVersion() const; const int getMaskPattern() const; const ByteMatrix* getMatrix() const; const std::string toString(); - void setMode(const Mode& value); - void setECLevel(const ErrorCorrectionLevel& value); - void setVersion(const Version& version); + void setMode(Mode* value); + void setECLevel(ErrorCorrectionLevel* value); + void setVersion(Version* version); void setMaskPattern(int value); - void setMatrix(const ByteMatrix& value); + void setMatrix(ByteMatrix* value); static bool isValidMaskPattern(int maskPattern) {