Changeset 5684 for icGREP


Ignore:
Timestamp:
Oct 9, 2017, 7:04:53 PM (19 months ago)
Author:
cameron
Message:

Regular expressions for extension property (scx)

Location:
icGREP/icgrep-devel/icgrep/UCD
Files:
2 edited

Legend:

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

    r5683 r5684  
    7474}
    7575
    76     const UnicodeSet EnumeratedPropertyObject::GetCodepointSetMatchingPattern(re::RE * pattern) {
    77    
    78    
    79         AlignedAllocator<char, 32> alloc;
    80         std::vector<std::string> accumulatedValues;
    81        
    82         const std::string & str = GetPropertyValueGrepString();
    83        
    84         const unsigned segmentSize = 8;
    85         const auto n = str.length();
    86         const auto w = 256 * segmentSize;
    87         const auto m = w - (n % w);
    88        
    89         char * aligned = alloc.allocate(n + m, 0);
    90         std::memcpy(aligned, str.data(), n);
    91         std::memset(aligned + n, 0, m);
    92        
    93         PropertyValueAccumulator accum(aligned, accumulatedValues);
    94         grepBuffer(pattern, aligned, n, & accum);
    95         alloc.deallocate(aligned, 0);
    96        
    97         UnicodeSet a;
    98         for (auto v : accumulatedValues) {
    99             int e = GetPropertyValueEnumCode(v);
    100             a = a + GetCodepointSet(e);
    101         }
    102         return a;
     76const UnicodeSet EnumeratedPropertyObject::GetCodepointSetMatchingPattern(re::RE * pattern) {
     77
     78
     79    AlignedAllocator<char, 32> alloc;
     80    std::vector<std::string> accumulatedValues;
     81   
     82    const std::string & str = GetPropertyValueGrepString();
     83   
     84    const unsigned segmentSize = 8;
     85    const auto n = str.length();
     86    const auto w = 256 * segmentSize;
     87    const auto m = w - (n % w);
     88   
     89    char * aligned = alloc.allocate(n + m, 0);
     90    std::memcpy(aligned, str.data(), n);
     91    std::memset(aligned + n, 0, m);
     92   
     93    PropertyValueAccumulator accum(aligned, accumulatedValues);
     94    grepBuffer(pattern, aligned, n, & accum);
     95    alloc.deallocate(aligned, 0);
     96   
     97    UnicodeSet a;
     98    for (auto v : accumulatedValues) {
     99        int e = GetPropertyValueEnumCode(v);
     100        a = a + GetCodepointSet(e);
     101    }
     102    return a;
    103103}
    104104
     
    196196    return cast<EnumeratedPropertyObject>(property_object_table[base_property])->GetPropertyValueEnumCode(value_spec);
    197197}
     198   
     199const UnicodeSet ExtensionPropertyObject::GetCodepointSetMatchingPattern(re::RE * pattern) {
     200    AlignedAllocator<char, 32> alloc;
     201    std::vector<std::string> accumulatedValues;
     202   
     203    EnumeratedPropertyObject * baseObj = cast<EnumeratedPropertyObject>(property_object_table[base_property]);
     204   
     205    const std::string & str = baseObj->GetPropertyValueGrepString();
     206   
     207    const unsigned segmentSize = 8;
     208    const auto n = str.length();
     209    const auto w = 256 * segmentSize;
     210    const auto m = w - (n % w);
     211   
     212    char * aligned = alloc.allocate(n + m, 0);
     213    std::memcpy(aligned, str.data(), n);
     214    std::memset(aligned + n, 0, m);
     215   
     216    PropertyValueAccumulator accum(aligned, accumulatedValues);
     217    grepBuffer(pattern, aligned, n, & accum);
     218    alloc.deallocate(aligned, 0);
     219   
     220    UnicodeSet a;
     221    for (auto v : accumulatedValues) {
     222        int e = baseObj->GetPropertyValueEnumCode(v);
     223        a = a + GetCodepointSet(e);
     224    }
     225    return a;
     226}
     227
    198228
    199229const std::string & ExtensionPropertyObject::GetPropertyValueGrepString() {
  • icGREP/icgrep-devel/icgrep/UCD/PropertyObjects.h

    r5683 r5684  
    156156    const UnicodeSet GetCodepointSet(const std::string & value_spec) override;
    157157    const UnicodeSet & GetCodepointSet(const int property_enum_val) const;
     158    const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
    158159
    159160private:
Note: See TracChangeset for help on using the changeset viewer.