Ignore:
Timestamp:
Sep 27, 2014, 11:12:13 PM (5 years ago)
Author:
nmedfort
Message:

Modified RE module to use a LLVM-like dyn_cast system; added 'make' functions to hide RE constructors.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_name.h

    r4187 r4194  
    33
    44#include "re_re.h"
    5 
    65#include <string>
    76
    8 class Name : public RE
    9 {
     7namespace re {
     8
     9class Name : public RE {
    1010public:
    11     typedef enum {FixedLength,Unicode,UnicodeCategory} Type;
    12     Name();
    13     Name(const Name * name);
    14     Name(std::string name);
     11    static inline bool classof(const RE * re) {
     12        return re->getClassTypeId() == ClassTypeId::Name;
     13    }
     14    static inline bool classof(const void *) {
     15        return false;
     16    }
     17    virtual RE * clone() const {
     18        return new Name(*this);
     19    }
     20    enum class Type {
     21        FixedLength
     22        ,Unicode
     23        ,UnicodeCategory
     24    };
    1525    void setName(std::string name);
    1626    std::string getName() const;
     
    1929    void setType(const Type type);
    2030    Type getType() const;
    21     ~Name();
     31    virtual ~Name() {}
     32protected:
     33    friend Name * makeName();
     34    friend Name * makeName(const Name *);
     35    friend Name * makeName(std::string, const bool, const Type);
     36    Name();
     37    Name(const Name & name);
     38    Name(std::string name, const bool negated, const Type type);
    2239private:
    2340    std::string mName;
     
    2643};
    2744
     45inline Name::Name()
     46: RE(ClassTypeId::Name)
     47, mName()
     48, mNegated(false)
     49, mType(Type::FixedLength) {
     50
     51}
     52
     53inline Name::Name(std::string name, const bool negated, const Type type)
     54: RE(ClassTypeId::Name)
     55, mName(name)
     56, mNegated(negated)
     57, mType(type) {
     58
     59}
     60
     61inline Name::Name(const Name &name)
     62: RE(ClassTypeId::Name)
     63, mName(name.getName())
     64, mNegated(name.isNegated())
     65, mType(name.getType()) {
     66
     67}
     68
     69inline void Name::setName(std::string name) {
     70    mName = name;
     71}
     72
     73inline std::string Name::getName() const {
     74    return mName;
     75}
     76
     77inline bool Name::isNegated() const {
     78    return mNegated;
     79}
     80
     81inline void Name::setNegated(const bool is_negated) {
     82    mNegated = is_negated;
     83}
     84
     85inline void Name::setType(const Type type) {
     86    mType = type;
     87}
     88
     89inline Name::Type Name::getType() const {
     90    return mType;
     91}
     92
     93inline Name * makeName() {
     94    return new Name();
     95}
     96
     97inline Name * makeName(const Name * name) {
     98    return new Name(*name);
     99}
     100
     101inline Name * makeName(std::string name, const bool negated = false, const Name::Type type = Name::Type::FixedLength) {
     102    return new Name(name, negated, type);
     103}
     104
     105}
     106
    28107#endif // RE_NAME_H
Note: See TracChangeset for help on using the changeset viewer.