File indexing completed on 2024-06-16 04:23:16
0001 /* 0002 SPDX-FileCopyrightText: 2006 Roberto Raggi <roberto@kdevelop.org> 0003 SPDX-FileCopyrightText: 2006-2008 Hamish Rodda <rodda@kde.org> 0004 SPDX-FileCopyrightText: 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de> 0005 0006 SPDX-License-Identifier: LGPL-2.0-only 0007 */ 0008 0009 #ifndef KDEVPLATFORM_ARRAYTYPE_H 0010 #define KDEVPLATFORM_ARRAYTYPE_H 0011 0012 #include "abstracttype.h" 0013 0014 namespace KDevelop { 0015 class ArrayTypeData; 0016 0017 class KDEVPLATFORMLANGUAGE_EXPORT ArrayType 0018 : public AbstractType 0019 { 0020 public: 0021 using Ptr = TypePtr<ArrayType>; 0022 0023 /// Default constructor 0024 ArrayType(); 0025 /// Copy constructor. \param rhs type to copy 0026 ArrayType(const ArrayType& rhs); 0027 /// Constructor using raw data. \param data internal data. 0028 explicit ArrayType(ArrayTypeData& data); 0029 /// Destructor 0030 ~ArrayType() override; 0031 0032 ArrayType& operator=(const ArrayType& rhs) = delete; 0033 0034 AbstractType* clone() const override; 0035 0036 bool equals(const AbstractType* rhs) const override; 0037 0038 /** 0039 * Retrieve the dimension of this array type. Multiple-dimensioned 0040 * arrays will have another array type as their elementType(). 0041 * 0042 * \returns the dimension of the array, or zero if the array is dimensionless (eg. int[]) 0043 */ 0044 int dimension () const; 0045 0046 /** 0047 * Set this array type's dimension. 0048 * If @p dimension is zero, the array is considered dimensionless (eg. int[]). 0049 * 0050 * \param dimension new dimension, set to zero for a dimensionless type (eg. int[]) 0051 */ 0052 void setDimension(int dimension); 0053 0054 /** 0055 * Retrieve the element type of the array, e.g. "int" for int[3]. 0056 * 0057 * \returns the element type. 0058 */ 0059 AbstractType::Ptr elementType () const; 0060 0061 /** 0062 * Set the element type of the array, e.g. "int" for int[3]. 0063 */ 0064 void setElementType(const AbstractType::Ptr& type); 0065 0066 QString toString() const override; 0067 0068 uint hash() const override; 0069 0070 WhichType whichType() const override; 0071 0072 void exchangeTypes(TypeExchanger* exchanger) override; 0073 0074 enum { 0075 Identity = 7 0076 }; 0077 0078 using Data = ArrayTypeData; 0079 0080 protected: 0081 void accept0 (TypeVisitor* v) const override; 0082 0083 TYPE_DECLARE_DATA(ArrayType) 0084 }; 0085 } 0086 0087 #endif // KDEVPLATFORM_TYPESYSTEM_H