소스 검색

implemented rollerMatch offset()

master
Pete McNeil 2 년 전
부모
커밋
ec3e973066
1개의 변경된 파일12개의 추가작업 그리고 7개의 파일을 삭제
  1. 12
    7
      roller.hpp

+ 12
- 7
roller.hpp 파일 보기

@@ -63,9 +63,9 @@ namespace codedweller {
}

template <class D, class T>
void compute(D data, bool caseSensitive, T& matcher, T& masker) {
size_t ingest = std::min(sizeof(matcher.value()), data.size());
for(size_t count = 0; count < ingest; count++) {
void compute(D data, bool caseSensitive, T& matcher, T& masker, size_t& matchLength) {
matchLength = std::min(sizeof(matcher.value()), data.size());
for(size_t count = 0; count < matchLength; count++) {
unsigned char theByte = data.at(count);
matcher.add(roller::applyCaseSensitivity(theByte, caseSensitive));
masker.add(roller::appropriateBitMask(theByte, caseSensitive));
@@ -77,18 +77,19 @@ namespace codedweller {
private:
uint_fast32_t match;
uint_fast32_t mask;
size_t matchLength;

public:
RollerMatch32(const std::vector<unsigned char> pattern, bool caseSensitive=true) {
Roller32 matcher, masker;
roller::compute(pattern, caseSensitive, matcher, masker);
roller::compute(pattern, caseSensitive, matcher, masker, matchLength);
match = matcher.value();
mask = masker.value();
}

RollerMatch32(const std::string pattern, bool caseSensitive=true) {
Roller32 matcher, masker;
roller::compute(pattern, caseSensitive, matcher, masker);
roller::compute(pattern, caseSensitive, matcher, masker, matchLength);
match = matcher.value();
mask = masker.value();
}
@@ -97,24 +98,26 @@ namespace codedweller {
return (match == (roller.value() & mask));
}

size_t offset() { return matchLength; }
};

class RollerMatch64 {
private:
uint_fast64_t match;
uint_fast64_t mask;
size_t matchLength;

public:
RollerMatch64(const std::vector<unsigned char> pattern, bool caseSensitive=true) {
Roller64 matcher, masker;
roller::compute(pattern, caseSensitive, matcher, masker);
roller::compute(pattern, caseSensitive, matcher, masker, matchLength);
match = matcher.value();
mask = masker.value();
}

RollerMatch64(const std::string pattern, bool caseSensitive=true) {
Roller64 matcher, masker;
roller::compute(pattern, caseSensitive, matcher, masker);
roller::compute(pattern, caseSensitive, matcher, masker, matchLength);
match = matcher.value();
mask = masker.value();
}
@@ -122,6 +125,8 @@ namespace codedweller {
bool matches(const Roller64 roller) {
return (match == (roller.value() & mask));
}

size_t offset() { return matchLength; }
};
}


Loading…
취소
저장