mirror of
https://github.com/status-im/qzxing.git
synced 2025-01-13 12:35:37 +00:00
finished initial implementation of QRCode (completed some unfinished portings). This class will be used as the main storing entity. Thus it will hold all the instances of the data containers and will be responsible to deallocate them at the end
This commit is contained in:
parent
61a9f1d55b
commit
af92dfd294
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user