[182] | 1 | #pragma once
|
---|
[4] | 2 |
|
---|
[406] | 3 | class EnumMember
|
---|
| 4 | {
|
---|
| 5 | std::string name;
|
---|
| 6 | std::string value;
|
---|
| 7 | int sourceIndex;
|
---|
[817] | 8 |
|
---|
[4] | 9 | public:
|
---|
[406] | 10 | EnumMember( const std::string &name, const std::string &value, int sourceIndex )
|
---|
| 11 | : name( name )
|
---|
| 12 | , value( value )
|
---|
| 13 | , sourceIndex( sourceIndex )
|
---|
| 14 | {
|
---|
| 15 | }
|
---|
[817] | 16 |
|
---|
| 17 | EnumMember(EnumMember&& y)
|
---|
| 18 | : name(std::move(y.name))
|
---|
| 19 | , value(std::move(y.value))
|
---|
| 20 | , sourceIndex(std::move(y.sourceIndex))
|
---|
| 21 | {
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | EnumMember(EnumMember const& y)
|
---|
| 25 | : name(y.name)
|
---|
| 26 | , value(y.value)
|
---|
| 27 | , sourceIndex(y.sourceIndex)
|
---|
| 28 | {
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | EnumMember& operator =(EnumMember&& y)
|
---|
| 32 | {
|
---|
| 33 | name = std::move(y.name);
|
---|
| 34 | value = std::move(y.value);
|
---|
| 35 | sourceIndex = std::move(y.sourceIndex);
|
---|
| 36 | return *this;
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | EnumMember& operator =(EnumMember const& y)
|
---|
| 40 | {
|
---|
| 41 | return *this = std::move(EnumMember(y));
|
---|
| 42 | }
|
---|
| 43 |
|
---|
[406] | 44 | const std::string &GetName() const
|
---|
| 45 | {
|
---|
| 46 | return name;
|
---|
| 47 | }
|
---|
| 48 | const std::string &GetValueStr() const
|
---|
| 49 | {
|
---|
| 50 | return value;
|
---|
| 51 | }
|
---|
| 52 | int GetSourceIndex() const
|
---|
| 53 | {
|
---|
| 54 | return sourceIndex;
|
---|
| 55 | }
|
---|
[4] | 56 | };
|
---|
| 57 |
|
---|
[406] | 58 | class EnumInfo
|
---|
| 59 | : public Symbol
|
---|
| 60 | {
|
---|
[103] | 61 |
|
---|
[4] | 62 | BOOL bConst;
|
---|
| 63 |
|
---|
[406] | 64 | std::vector<EnumMember> members;
|
---|
[4] | 65 | public:
|
---|
| 66 |
|
---|
[406] | 67 | EnumInfo( const NamespaceScopes &namespaceScopes, const std::string &name )
|
---|
| 68 | : Symbol( namespaceScopes, name )
|
---|
| 69 | {
|
---|
| 70 | }
|
---|
[4] | 71 |
|
---|
[817] | 72 | EnumInfo(EnumInfo&& y)
|
---|
| 73 | : Symbol(std::move(y))
|
---|
| 74 | , bConst(std::move(y.bConst))
|
---|
| 75 | , members(std::move(y.members))
|
---|
| 76 | {
|
---|
| 77 | }
|
---|
| 78 |
|
---|
| 79 | EnumInfo(EnumInfo const& y)
|
---|
| 80 | : Symbol(y)
|
---|
| 81 | , bConst(y.bConst)
|
---|
| 82 | , members(y.members)
|
---|
| 83 | {
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | EnumInfo& operator =(EnumInfo&& y)
|
---|
| 87 | {
|
---|
| 88 | Symbol::operator =(std::move(y));
|
---|
| 89 | bConst = std::move(y.bConst);
|
---|
| 90 | members = std::move(y.members);
|
---|
| 91 | return *this;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | EnumInfo& operator =(EnumInfo const& y)
|
---|
| 95 | {
|
---|
| 96 | return *this = std::move(EnumInfo(y));
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[406] | 99 | const std::vector<EnumMember> &GetMembers() const
|
---|
[103] | 100 | {
|
---|
[406] | 101 | return members;
|
---|
[103] | 102 | }
|
---|
[406] | 103 |
|
---|
| 104 | const EnumMember &GetEnumMember( const std::string &memberName ) const
|
---|
[103] | 105 | {
|
---|
[750] | 106 | foreach( const EnumMember &member, members )
|
---|
[406] | 107 | {
|
---|
| 108 | if( member.GetName() == memberName )
|
---|
| 109 | {
|
---|
| 110 | return member;
|
---|
| 111 | }
|
---|
| 112 | }
|
---|
| 113 | throw;
|
---|
[103] | 114 | }
|
---|
[547] | 115 |
|
---|
| 116 | std::vector<EnumMember> &GetEnumMembers()
|
---|
| 117 | {
|
---|
| 118 | return members;
|
---|
| 119 | }
|
---|
[406] | 120 | };
|
---|
[4] | 121 |
|
---|
[406] | 122 | class EnumInfoCollection
|
---|
| 123 | : public std::vector<EnumInfo>
|
---|
| 124 | {
|
---|
[4] | 125 | public:
|
---|
[406] | 126 | const EnumInfo *Find( const Symbol &symbol ) const
|
---|
| 127 | {
|
---|
| 128 | const EnumInfoCollection &thisEnumInfoCollection = *this;
|
---|
[750] | 129 | foreach( const EnumInfo &enumInfo, thisEnumInfoCollection )
|
---|
[406] | 130 | {
|
---|
| 131 | if( enumInfo.IsEqualSymbol( symbol ) )
|
---|
| 132 | {
|
---|
| 133 | return &enumInfo;
|
---|
| 134 | }
|
---|
| 135 | }
|
---|
| 136 | return NULL;
|
---|
| 137 | };
|
---|
[817] | 138 |
|
---|
| 139 | EnumInfoCollection() {}
|
---|
| 140 |
|
---|
| 141 | private:
|
---|
| 142 | EnumInfoCollection(EnumInfoCollection const&);
|
---|
| 143 | EnumInfoCollection& operator =(EnumInfoCollection const&);
|
---|
[4] | 144 | };
|
---|