File indexing completed on 2024-05-12 04:37:56
0001 /* 0002 SPDX-FileCopyrightText: 2002-2005 Roberto Raggi <roberto@kdevelop.org> 0003 SPDX-FileCopyrightText: 2006 Adam Treat <treat@kde.org> 0004 SPDX-FileCopyrightText: 2006 Hamish Rodda <rodda@kde.org> 0005 SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de> 0006 0007 SPDX-License-Identifier: LGPL-2.0-only 0008 */ 0009 0010 #ifndef KDEVPLATFORM_CLASSMEMBERDECLARATION_H 0011 #define KDEVPLATFORM_CLASSMEMBERDECLARATION_H 0012 0013 #include "declaration.h" 0014 0015 namespace KDevelop { 0016 class ClassMemberDeclarationData; 0017 /** 0018 * Represents a single class member definition in a definition-use chain. 0019 */ 0020 class KDEVPLATFORMLANGUAGE_EXPORT ClassMemberDeclaration 0021 : public Declaration 0022 { 0023 public: 0024 ClassMemberDeclaration(const ClassMemberDeclaration& rhs); 0025 ClassMemberDeclaration(const RangeInRevision& range, DUContext* context); 0026 explicit ClassMemberDeclaration(ClassMemberDeclarationData& dd); 0027 ~ClassMemberDeclaration() override; 0028 0029 ClassMemberDeclaration& operator=(const ClassMemberDeclaration& rhs) = delete; 0030 0031 AccessPolicy accessPolicy() const; 0032 void setAccessPolicy(AccessPolicy accessPolicy); 0033 0034 enum StorageSpecifier { 0035 StaticSpecifier = 0x1 /**< indicates static member */, 0036 AutoSpecifier = 0x2 /**< indicates automatic determination of member access */, 0037 FriendSpecifier = 0x4 /**< indicates friend member */, 0038 ExternSpecifier = 0x8 /**< indicates external declaration */, 0039 RegisterSpecifier = 0x10 /**< indicates register */, 0040 MutableSpecifier = 0x20/**< indicates a mutable member */ 0041 }; 0042 Q_DECLARE_FLAGS(StorageSpecifiers, StorageSpecifier) 0043 0044 void setStorageSpecifiers(StorageSpecifiers specifiers); 0045 0046 bool isStatic() const; 0047 void setStatic(bool isStatic); 0048 0049 bool isAuto() const; 0050 void setAuto(bool isAuto); 0051 0052 bool isFriend() const; 0053 void setFriend(bool isFriend); 0054 0055 bool isRegister() const; 0056 void setRegister(bool isRegister); 0057 0058 bool isExtern() const; 0059 void setExtern(bool isExtern); 0060 0061 bool isMutable() const; 0062 void setMutable(bool isMutable); 0063 0064 /** 0065 * \returns The offset of the field in bits or -1 if unknown or not applicable. 0066 */ 0067 int64_t bitOffsetOf() const; 0068 0069 /** 0070 * Set the offset to given number of bits. Use -1 to represent unknown offset. 0071 */ 0072 void setBitOffsetOf(int64_t bitOffsetOf); 0073 0074 enum BitWidthSpecialValue { 0075 NotABitField = -1, ///< this member is not a bit-field or a parsing error occurred 0076 ValueDependentBitWidth = -2 ///< bit width depends on a template parameter 0077 }; 0078 0079 /** 0080 * \returns The width in bits or a BitWidthSpecialValue. 0081 */ 0082 int bitWidth() const; 0083 0084 /** 0085 * Set the width to a given number of bits or to a BitWidthSpecialValue. 0086 */ 0087 void setBitWidth(int bitWidth); 0088 0089 enum { 0090 Identity = 9 0091 }; 0092 0093 protected: 0094 ClassMemberDeclaration(ClassMemberDeclarationData& dd, const RangeInRevision& range); 0095 0096 DUCHAIN_DECLARE_DATA(ClassMemberDeclaration) 0097 0098 private: 0099 Declaration* clonePrivate() const override; 0100 }; 0101 0102 Q_DECLARE_OPERATORS_FOR_FLAGS(ClassMemberDeclaration::StorageSpecifiers) 0103 } 0104 0105 #endif // KDEVPLATFORM_CLASSMEMBERDECLARATION_H