mirror of https://github.com/status-im/qzxing.git
completed implementation of QrCode::toString
This commit is contained in:
parent
3c18b88aed
commit
fe43ed8788
|
@ -61,10 +61,11 @@ public:
|
|||
bool operator==(const Mode& other);
|
||||
bool operator!=(const Mode& other);
|
||||
|
||||
std::string getName() const { return name_; }
|
||||
|
||||
std::string toString() const {
|
||||
return getName();
|
||||
std::string getName() const {
|
||||
if(name_ == "")
|
||||
return "null";
|
||||
else
|
||||
return name_;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -45,22 +45,36 @@ const std::string QRCode::toString()
|
|||
{
|
||||
std::stringstream result;
|
||||
result << "<<";
|
||||
// result << "\n mode: {unimpl}";
|
||||
// result << mode_;
|
||||
result << "\n ecLevel: {unimpl}";
|
||||
//result << ecLevel_;
|
||||
result << "\n version: {unimpl}";
|
||||
//result << version_;
|
||||
|
||||
result << "\n mode: ";
|
||||
result << mode_.getName();
|
||||
|
||||
result << "\n ecLevel: ";
|
||||
if(!ecLevel_ptr_.empty())
|
||||
result << ecLevel_ptr_->name();
|
||||
else
|
||||
result << "null";
|
||||
|
||||
result << "\n version: ";
|
||||
if(!version_ptr_.empty())
|
||||
{
|
||||
std::string version_str;
|
||||
std::ostringstream convert;
|
||||
convert << version_ptr_->getVersionNumber();
|
||||
version_str = convert.str();
|
||||
result << version_str;
|
||||
}
|
||||
else
|
||||
result << "null";
|
||||
|
||||
result << "\n maskPattern: ";
|
||||
result << maskPattern_;
|
||||
// if (matrix_ == null) {
|
||||
// result.append("\n matrix: null\n");
|
||||
// } else {
|
||||
|
||||
if (matrix_ptr_)
|
||||
result << "\n matrix:\n" << matrix_ptr_->toString();
|
||||
else
|
||||
result << "\n matrix: null\n";
|
||||
// }
|
||||
|
||||
result << "\n>>";
|
||||
return result.str();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ private:
|
|||
}
|
||||
|
||||
static QString itemToString(qrcode::Mode& item) {
|
||||
return QString::fromStdString(item.toString());
|
||||
return QString::fromStdString(item.getName());
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -50,9 +50,9 @@ void QRCodeTests::testToString1() {
|
|||
QRCode qrCode;
|
||||
std::string expected =
|
||||
"<<\n"
|
||||
// " mode: null\n"
|
||||
" ecLevel: {unimpl}\n"
|
||||
" version: {unimpl}\n"
|
||||
" mode: null\n"
|
||||
" ecLevel: null\n"
|
||||
" version: null\n"
|
||||
" maskPattern: -1\n"
|
||||
" matrix: null\n"
|
||||
"\n>>";
|
||||
|
@ -74,11 +74,9 @@ void QRCodeTests::testToString2()
|
|||
}
|
||||
qrCode.setMatrix(matrix);
|
||||
std::string expected = "<<\n"
|
||||
//" mode: BYTE\n"
|
||||
//" ecLevel: H\n"
|
||||
" ecLevel: {unimpl}\n"
|
||||
//" version: 1\n"
|
||||
" version: {unimpl}\n"
|
||||
" mode: BYTE\n"
|
||||
" ecLevel: H\n"
|
||||
" version: 1\n"
|
||||
" maskPattern: 3\n"
|
||||
" matrix:\n"
|
||||
" 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0\n"
|
||||
|
|
Loading…
Reference in New Issue