1 // Copyright (c) 2008 Roberto Raggi <roberto.raggi@gmail.com> 2 // 3 // Permission is hereby granted, free of charge, to any person obtaining a copy 4 // of this software and associated documentation files (the "Software"), to deal 5 // in the Software without restriction, including without limitation the rights 6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 // copies of the Software, and to permit persons to whom the Software is 8 // furnished to do so, subject to the following conditions: 9 // 10 // The above copyright notice and this permission notice shall be included in 11 // all copies or substantial portions of the Software. 12 // 13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 // THE SOFTWARE. 20 21 #pragma once 22 23 #include "CPlusPlusForwardDeclarations.h" 24 25 26 namespace CPlusPlus { 27 28 class CPLUSPLUS_EXPORT FullySpecifiedType 29 { 30 public: 31 FullySpecifiedType(Type *type = nullptr); 32 ~FullySpecifiedType(); 33 34 bool isValid() const; 35 explicit operator bool() const; 36 37 Type *type() const; 38 void setType(Type *type); 39 40 FullySpecifiedType qualifiedType() const; 41 42 bool isConst() const; 43 void setConst(bool isConst); 44 45 bool isVolatile() const; 46 void setVolatile(bool isVolatile); 47 48 bool isSigned() const; 49 void setSigned(bool isSigned); 50 51 bool isUnsigned() const; 52 void setUnsigned(bool isUnsigned); 53 54 bool isFriend() const; 55 void setFriend(bool isFriend); 56 57 bool isAuto() const; 58 void setAuto(bool isAuto); 59 60 bool isRegister() const; 61 void setRegister(bool isRegister); 62 63 bool isStatic() const; 64 void setStatic(bool isStatic); 65 66 bool isExtern() const; 67 void setExtern(bool isExtern); 68 69 bool isMutable() const; 70 void setMutable(bool isMutable); 71 72 bool isTypedef() const; 73 void setTypedef(bool isTypedef); 74 75 bool isInline() const; 76 void setInline(bool isInline); 77 78 bool isVirtual() const; 79 void setVirtual(bool isVirtual); 80 81 bool isOverride() const; 82 void setOverride(bool isOverride); 83 84 bool isFinal() const; 85 void setFinal(bool isFinal); 86 87 bool isExplicit() const; 88 void setExplicit(bool isExplicit); 89 90 bool isDeprecated() const; 91 void setDeprecated(bool isDeprecated); 92 93 bool isUnavailable() const; 94 void setUnavailable(bool isUnavailable); 95 96 Type &operator*(); 97 const Type &operator*() const; 98 99 Type *operator->(); 100 const Type *operator->() const; 101 102 bool operator == (const FullySpecifiedType &other) const; 103 bool operator != (const FullySpecifiedType &other) const; 104 bool operator < (const FullySpecifiedType &other) const; 105 106 size_t hash() const; 107 108 bool match(const FullySpecifiedType &otherTy, Matcher *matcher = nullptr) const; 109 110 FullySpecifiedType simplified() const; 111 112 unsigned flags() const; 113 void setFlags(unsigned flags); 114 115 private: 116 Type *_type; 117 struct Flags { 118 // cv qualifiers 119 unsigned _isConst: 1; 120 unsigned _isVolatile: 1; 121 122 // sign 123 unsigned _isSigned: 1; 124 unsigned _isUnsigned: 1; 125 126 // storage class specifiers 127 unsigned _isFriend: 1; 128 unsigned _isAuto: 1; 129 unsigned _isRegister: 1; 130 unsigned _isStatic: 1; 131 unsigned _isExtern: 1; 132 unsigned _isMutable: 1; 133 unsigned _isTypedef: 1; 134 135 // function specifiers 136 unsigned _isInline: 1; 137 unsigned _isVirtual: 1; 138 unsigned _isOverride: 1; 139 unsigned _isFinal: 1; 140 unsigned _isExplicit: 1; 141 142 // speficiers from attributes 143 unsigned _isDeprecated: 1; 144 unsigned _isUnavailable: 1; 145 }; 146 union { 147 unsigned _flags; 148 Flags f; 149 }; 150 }; 151 152 } // namespace CPlusPlus 153