Ignore:
Timestamp:
Jul 28, 2018, 6:26:56 PM (11 months ago)
Author:
cameron
Message:

GetStringValue? method for string properties

File:
1 edited

Legend:

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

    r5748 r6134  
    4444    virtual const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern);
    4545    virtual const UnicodeSet GetReflexiveSet();
     46    virtual const std::string GetStringValue(UCD::codepoint_t cp);
    4647
    4748    virtual const std::string & GetPropertyValueGrepString();
     
    199200        return false;
    200201    }
    201     StringPropertyObject(UCD::property_t p, const UnicodeSet && nullSet, const UnicodeSet && mapsToSelf, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> && cps)
     202    StringPropertyObject(UCD::property_t p, const UnicodeSet && nullSet, const UnicodeSet && mapsToSelf, const char * string_buffer,
     203                         const std::vector<unsigned> && offsets, const std::vector<UCD::codepoint_t> && cps)
    202204    : PropertyObject(p, ClassTypeId::StringProperty)
    203205    , mNullCodepointSet(std::move(nullSet))
    204206    , mSelfCodepointSet(std::move(mapsToSelf))
    205207    , mStringBuffer(string_buffer)
    206     , mBufSize(bufsize)
     208    , mStringOffsets(offsets)
    207209    , mExplicitCps(cps)
    208210    {
     
    212214    const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
    213215    const UnicodeSet GetReflexiveSet() override;
     216    const std::string GetStringValue(UCD::codepoint_t cp) override;
    214217   
    215218private:
    216219    const UnicodeSet mNullCodepointSet;  // codepoints for which the property value is the null string.
    217220    const UnicodeSet mSelfCodepointSet;  // codepoints for which the property value is the codepoint itself.
    218     const char * mStringBuffer;  // buffer holding all string values for other codepoints, in sorted order.
    219     unsigned mBufSize;
    220     const std::vector<UCD::codepoint_t> mExplicitCps;
    221 
     221    // Codepoints other than those in these two sets are explicitly represented.
     222    const char * mStringBuffer;  // buffer holding all string values for explicit codepoints, in sorted order.
     223    const std::vector<unsigned> mStringOffsets;        // the offsets of each string within the buffer.
     224    //unsigned mBufSize;                               // mStringOffsets has one extra element for buffer size.
     225    const std::vector<UCD::codepoint_t> mExplicitCps;  // the codepoints having explicit strings
    222226};
    223227   
     
    230234        return false;
    231235    }
    232     StringOverridePropertyObject(UCD::property_t p, PropertyObject & baseObj, const UnicodeSet && overriddenSet, const char * string_buffer, unsigned bufsize, const std::vector<UCD::codepoint_t> && cps)
     236    StringOverridePropertyObject(UCD::property_t p, PropertyObject & baseObj, const UnicodeSet && overriddenSet, const char * string_buffer,
     237                                 const std::vector<unsigned> && offsets, const std::vector<UCD::codepoint_t> && cps)
    233238    : PropertyObject(p, ClassTypeId::StringOverrideProperty)
    234239    , mBaseObject(baseObj)
    235240    , mOverriddenSet(std::move(overriddenSet))
    236241    , mStringBuffer(string_buffer)
    237     , mBufSize(bufsize)
     242    , mStringOffsets(offsets)
    238243    , mExplicitCps(cps)
    239244    {
     
    243248    const UnicodeSet GetCodepointSetMatchingPattern(re::RE * pattern) override;
    244249    const UnicodeSet GetReflexiveSet() override;
    245    
     250    const std::string GetStringValue(UCD::codepoint_t cp) override;
     251
    246252private:
    247253    PropertyObject & mBaseObject;  // the base object that provides default values for this property unless overridden.
    248254    const UnicodeSet mOverriddenSet;   // codepoints for which the baseObject value is overridden.
    249255    const char * mStringBuffer;  // buffer holding all string values for overridden codepoints, in sorted order.
    250     unsigned mBufSize;
     256    const std::vector<unsigned> mStringOffsets;        // the offsets of each string within the buffer.
     257    //unsigned mBufSize;                               // mStringOffsets has one extra element for buffer size.
    251258    const std::vector<codepoint_t> mExplicitCps;
    252    
    253259};
    254260   
Note: See TracChangeset for help on using the changeset viewer.