Ignore:
Timestamp:
Dec 23, 2017, 7:59:51 AM (15 months ago)
Author:
cameron
Message:

isa and dyn_cast for Alphabets

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/cc/alphabet.h

    r5797 r5800  
    2222public:
    2323    const std::string & getName() const { return mAlphabetName;}
     24    enum class ClassTypeId : unsigned {UnicodeMappableAlphabet, CodeUnitAlphabet, MultiplexedAlphabet};
     25    inline ClassTypeId getClassTypeId() const {
     26        return mClassTypeId;
     27    }
     28
    2429protected:
    25     Alphabet(std::string alphabetName) : mAlphabetName(alphabetName) {}
     30    Alphabet(std::string name, ClassTypeId k) : mAlphabetName(name), mClassTypeId(k) {}
    2631private:
    27     std::string mAlphabetName;
     32    const std::string mAlphabetName;
     33    const ClassTypeId mClassTypeId;
    2834};
    2935
     
    4147                            std::vector <UCD::codepoint_t> aboveCommon);
    4248   
     49    static inline bool classof(const Alphabet * a) {
     50        return a->getClassTypeId() == ClassTypeId::UnicodeMappableAlphabet;
     51    }
     52    static inline bool classof(const void *) {return false;}
    4353    //  The Unicode codepoint of the nth character (the character whose alphabet code is n).
    4454    UCD::codepoint_t toUnicode(const unsigned n) const;
     
    5666public:
    5767    CodeUnitAlphabet(std::string alphabetName, uint8_t codeUnitBits);
     68    static inline bool classof(const Alphabet * a) {
     69        return a->getClassTypeId() == ClassTypeId::CodeUnitAlphabet;
     70    }
     71    static inline bool classof(const void *) {return false;}
    5872    uint8_t getCodeUnitBitWidth() { return mCodeUnitBits;}
    5973   
Note: See TracChangeset for help on using the changeset viewer.