Ignore:
Timestamp:
Oct 18, 2017, 9:35:52 AM (2 years ago)
Author:
cameron
Message:

Update scanmatch callback protocol to use line start/end pointers; add finalize callback for buffer end

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.cpp

    r5685 r5694  
    6161public:
    6262   
    63     PropertyValueAccumulator(const char * searchBuffer, std::vector<std::string> & accumulatedPropertyValues)
    64     : mSearchBuffer(searchBuffer), mParsedPropertyValueSet(accumulatedPropertyValues) {}
    65    
    66     void accumulate_match(const size_t lineNum, size_t line_start, size_t line_end) override;
     63    PropertyValueAccumulator(std::vector<std::string> & accumulatedPropertyValues)
     64    : mParsedPropertyValueSet(accumulatedPropertyValues) {}
     65   
     66    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
    6767private:
    68     const char * mSearchBuffer;
    6968    std::vector<std::string> & mParsedPropertyValueSet;
    7069};
    71 void PropertyValueAccumulator::accumulate_match(const size_t lineNum, size_t line_start, size_t line_end) {
     70void PropertyValueAccumulator::accumulate_match(const size_t lineNum, char * line_start, char * line_end) {
    7271    assert (line_start <= line_end);
    73     mParsedPropertyValueSet.emplace_back(mSearchBuffer + line_start, mSearchBuffer + line_end);
     72    mParsedPropertyValueSet.emplace_back(line_start, line_end);
    7473}
    7574
     
    9190    std::memset(aligned + n, 0, m);
    9291   
    93     PropertyValueAccumulator accum(aligned, accumulatedValues);
     92    PropertyValueAccumulator accum(accumulatedValues);
    9493    grepBuffer(pattern, aligned, n, & accum);
    9594    alloc.deallocate(aligned, 0);
    9695   
    97     UnicodeSet a;
     96    UnicodeSet a = UnicodeSet();
    9897    for (auto v : accumulatedValues) {
    9998        int e = GetPropertyValueEnumCode(v);
     
    214213    std::memset(aligned + n, 0, m);
    215214   
    216     PropertyValueAccumulator accum(aligned, accumulatedValues);
     215    PropertyValueAccumulator accum(accumulatedValues);
    217216    grepBuffer(pattern, aligned, n, & accum);
    218217    alloc.deallocate(aligned, 0);
    219218   
    220     UnicodeSet a;
     219    UnicodeSet a = UnicodeSet();
    221220    for (auto v : accumulatedValues) {
    222221        int e = baseObj->GetPropertyValueEnumCode(v);
     
    271270const unsigned firstCodepointLengthAndVal(const std::string & s, codepoint_t & cp) {
    272271    size_t lgth = s.length();
     272    cp = 0;
    273273    if (lgth == 0) return 0;
    274274    unsigned char s0 = s[0];
     
    293293    : mCodepointTableByLineNum(cps), mDefaultValueSet(defaultValueSet) {}
    294294   
    295     void accumulate_match(const size_t lineNum, size_t line_start, size_t line_end) override;
     295    void accumulate_match(const size_t lineNum, char * line_start, char * line_end) override;
    296296    UnicodeSet getAccumulatedSet() { return mAccumSet; }
    297297private:
     
    300300    UnicodeSet mAccumSet;
    301301};
    302 void SetByLineNumberAccumulator::accumulate_match(const size_t lineNum, size_t line_start, size_t line_end) {
     302void SetByLineNumberAccumulator::accumulate_match(const size_t lineNum, char * line_start, char * line_end) {
    303303    if (lineNum >= mCodepointTableByLineNum.size()) mAccumSet = mAccumSet + mDefaultValueSet;
    304304    else mAccumSet.insert(mCodepointTableByLineNum[lineNum]);
     
    309309    if (value_spec == "NaN") return mNaNCodepointSet;
    310310    else {
    311         UnicodeSet result_set;
     311        UnicodeSet result_set = UnicodeSet();
    312312        unsigned val_bytes = value_spec.length();
    313313        const char * value_str = value_spec.c_str();
     
    338338    if (value_spec == "") return mNullCodepointSet;
    339339    else {
    340         UnicodeSet result_set;
     340        UnicodeSet result_set = UnicodeSet();
    341341        unsigned val_bytes = value_spec.length();
    342342        codepoint_t cp;
Note: See TracChangeset for help on using the changeset viewer.