mirror of https://github.com/status-im/qzxing.git
vector -> set
This commit is contained in:
parent
49b0e85227
commit
82d4407c78
|
@ -112,9 +112,9 @@ bool QZXing::getTryHarder()
|
||||||
}
|
}
|
||||||
void QZXing::setAllowedExtensions(const QVariantList& extensions)
|
void QZXing::setAllowedExtensions(const QVariantList& extensions)
|
||||||
{
|
{
|
||||||
std::vector<int> allowedExtensions;
|
std::set<int> allowedExtensions;
|
||||||
for (const QVariant& extension: extensions) {
|
for (const QVariant& extension: extensions) {
|
||||||
allowedExtensions.push_back(extension.toInt());
|
allowedExtensions.insert(extension.toInt());
|
||||||
}
|
}
|
||||||
|
|
||||||
allowedExtensions_ = allowedExtensions;
|
allowedExtensions_ = allowedExtensions;
|
||||||
|
|
|
@ -24,6 +24,8 @@
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QVariantList>
|
#include <QVariantList>
|
||||||
|
|
||||||
|
#include <set>
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
class QQmlEngine;
|
class QQmlEngine;
|
||||||
#endif
|
#endif
|
||||||
|
@ -220,7 +222,7 @@ private:
|
||||||
QString charSet_;
|
QString charSet_;
|
||||||
bool tryHarder_;
|
bool tryHarder_;
|
||||||
bool lastDecodeOperationSucceded_;
|
bool lastDecodeOperationSucceded_;
|
||||||
std::vector<int> allowedExtensions_;
|
std::set<int> allowedExtensions_;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true, the decoding operation will take place at a different thread.
|
* If true, the decoding operation will take place at a different thread.
|
||||||
|
|
|
@ -77,6 +77,7 @@ const zxing::DecodeHints DecodeHints::DEFAULT_HINT(
|
||||||
|
|
||||||
DecodeHints::DecodeHints() {
|
DecodeHints::DecodeHints() {
|
||||||
hints = 0;
|
hints = 0;
|
||||||
|
allowedEanExtensions = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
DecodeHints::DecodeHints(const zxing::DecodeHintType &init) {
|
DecodeHints::DecodeHints(const zxing::DecodeHintType &init) {
|
||||||
|
@ -151,11 +152,11 @@ bool DecodeHints::getTryHarder() const {
|
||||||
return (hints & TRYHARDER_HINT) != 0;
|
return (hints & TRYHARDER_HINT) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecodeHints::setAllowedEanExtensions(std::vector<int> toset) {
|
void DecodeHints::setAllowedEanExtensions(std::set<int> toset) {
|
||||||
allowedEanExtensions = toset;
|
allowedEanExtensions = toset;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> DecodeHints::getAllowedEanExtensions() const {
|
std::set<int> DecodeHints::getAllowedEanExtensions() const {
|
||||||
return allowedEanExtensions;
|
return allowedEanExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +182,10 @@ zxing::DecodeHints zxing::operator | (DecodeHints const& l, DecodeHints const& r
|
||||||
if (!result.callback) {
|
if (!result.callback) {
|
||||||
result.callback = r.callback;
|
result.callback = r.callback;
|
||||||
}
|
}
|
||||||
if (result.allowedEanExtensions.empty()) {
|
|
||||||
result.allowedEanExtensions = r.allowedEanExtensions;
|
result.allowedEanExtensions = l.allowedEanExtensions;
|
||||||
}
|
result.allowedEanExtensions.insert(r.allowedEanExtensions.begin(),
|
||||||
|
r.allowedEanExtensions.end());
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
#include <zxing/BarcodeFormat.h>
|
#include <zxing/BarcodeFormat.h>
|
||||||
#include <zxing/ResultPointCallback.h>
|
#include <zxing/ResultPointCallback.h>
|
||||||
|
|
||||||
#include <vector>
|
#include <set>
|
||||||
|
|
||||||
namespace zxing {
|
namespace zxing {
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ class DecodeHints {
|
||||||
private:
|
private:
|
||||||
DecodeHintType hints;
|
DecodeHintType hints;
|
||||||
Ref<ResultPointCallback> callback;
|
Ref<ResultPointCallback> callback;
|
||||||
std::vector<int> allowedEanExtensions;
|
std::set<int> allowedEanExtensions;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static const DecodeHintType AZTEC_HINT;
|
static const DecodeHintType AZTEC_HINT;
|
||||||
|
@ -78,8 +78,8 @@ class DecodeHints {
|
||||||
void setTryHarder(bool toset);
|
void setTryHarder(bool toset);
|
||||||
bool getTryHarder() const;
|
bool getTryHarder() const;
|
||||||
|
|
||||||
void setAllowedEanExtensions(std::vector<int> toset);
|
void setAllowedEanExtensions(std::set<int> toset);
|
||||||
std::vector<int> getAllowedEanExtensions() const;
|
std::set<int> getAllowedEanExtensions() const;
|
||||||
|
|
||||||
void setResultPointCallback(Ref<ResultPointCallback> const&);
|
void setResultPointCallback(Ref<ResultPointCallback> const&);
|
||||||
Ref<ResultPointCallback> getResultPointCallback() const;
|
Ref<ResultPointCallback> getResultPointCallback() const;
|
||||||
|
|
|
@ -177,7 +177,7 @@ Ref<Result> UPCEANReader::decodeRow(int rowNumber,
|
||||||
// continue
|
// continue
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<int> allowedExtensions = hints.getAllowedEanExtensions();
|
std::set<int> allowedExtensions = hints.getAllowedEanExtensions();
|
||||||
if (allowedExtensions.size() > 0) {
|
if (allowedExtensions.size() > 0) {
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
for (int length: allowedExtensions) {
|
for (int length: allowedExtensions) {
|
||||||
|
|
Loading…
Reference in New Issue