mirror of https://github.com/status-im/qzxing.git
added missing methods
This commit is contained in:
parent
635cfab83c
commit
0cd99217df
|
@ -43,8 +43,8 @@ int String::size() const { return int(text_.size()); }
|
|||
|
||||
int String::length() const { return int(text_.size()); }
|
||||
|
||||
Ref<String> String::substring(int i) const {
|
||||
return Ref<String>(new String(text_.substr(i)));
|
||||
Ref<String> String::substring(int i, int j) const {
|
||||
return Ref<String>(new String(text_.substr(i, j)));
|
||||
}
|
||||
|
||||
void String::append(const std::string &tail) {
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
explicit String(const std::string &text);
|
||||
explicit String(int);
|
||||
char charAt(int) const;
|
||||
Ref<String> substring(int) const;
|
||||
Ref<String> substring(int, int = -1) const;
|
||||
const std::string& getText() const;
|
||||
int size() const;
|
||||
void append(std::string const& tail);
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
|
||||
namespace zxing {
|
||||
namespace common {
|
||||
|
@ -48,6 +49,14 @@ class MathUtils {
|
|||
int yDiff = aY - bY;
|
||||
return sqrt(float(xDiff * xDiff + yDiff * yDiff));
|
||||
}
|
||||
|
||||
static inline int sum(std::vector<int> array) {
|
||||
int count = 0;
|
||||
for (int a : array) {
|
||||
count += a;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -221,4 +221,24 @@ void OneDReader::recordPattern(Ref<BitArray> row,
|
|||
}
|
||||
}
|
||||
|
||||
void OneDReader::recordPatternInReverse(Ref<BitArray> row,
|
||||
int start,
|
||||
vector<int>& counters)
|
||||
{
|
||||
// This could be more efficient I guess
|
||||
int numTransitionsLeft = int(counters.size());
|
||||
bool last = row->get(start);
|
||||
while (start > 0 && numTransitionsLeft >= 0) {
|
||||
if (row->get(--start) != last) {
|
||||
numTransitionsLeft--;
|
||||
last = !last;
|
||||
}
|
||||
}
|
||||
if (numTransitionsLeft >= 0)
|
||||
{
|
||||
throw NotFoundException();
|
||||
}
|
||||
recordPattern(row, start + 1, counters);
|
||||
}
|
||||
|
||||
OneDReader::~OneDReader() {}
|
||||
|
|
|
@ -72,6 +72,10 @@ public:
|
|||
static void recordPattern(Ref<BitArray> row,
|
||||
int start,
|
||||
std::vector<int>& counters);
|
||||
|
||||
static void recordPatternInReverse(Ref<BitArray> row,
|
||||
int start,
|
||||
std::vector<int>& counters);
|
||||
virtual ~OneDReader();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue