File indexing completed on 2024-04-28 15:52:49
0001 /* 0002 SPDX-FileCopyrightText: 2011 Sven Brauch <svenbrauch@googlemail.com> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef INDEXEDCONTAINER_H 0008 #define INDEXEDCONTAINER_H 0009 0010 #include "structuretype.h" 0011 #include <language/duchain/types/typesystemdata.h> 0012 0013 #include "phpduchainexport.h" 0014 0015 using namespace KDevelop; 0016 0017 namespace Php { 0018 0019 KDEVPHPDUCHAIN_EXPORT DECLARE_LIST_MEMBER_HASH(IndexedContainerData, m_values, IndexedType) 0020 0021 class KDEVPHPDUCHAIN_EXPORT IndexedContainerData : public Php::StructureTypeData 0022 { 0023 public: 0024 /// Constructor 0025 IndexedContainerData() 0026 : Php::StructureTypeData() 0027 { 0028 initializeAppendedLists(m_dynamic); 0029 } 0030 /// Copy constructor. \param rhs data to copy 0031 IndexedContainerData( const IndexedContainerData& rhs ) 0032 : Php::StructureTypeData(rhs) 0033 { 0034 initializeAppendedLists(m_dynamic); 0035 copyListsFrom(rhs); 0036 } 0037 0038 ~IndexedContainerData() { 0039 freeAppendedLists(); 0040 }; 0041 0042 START_APPENDED_LISTS_BASE(IndexedContainerData, StructureTypeData) 0043 APPENDED_LIST_FIRST(IndexedContainerData, IndexedType, m_values) 0044 END_APPENDED_LISTS(IndexedContainerData, m_values) 0045 }; 0046 0047 0048 class KDEVPHPDUCHAIN_EXPORT IndexedContainer : public Php::StructureType 0049 { 0050 public: 0051 typedef TypePtr<IndexedContainer> Ptr; 0052 0053 IndexedContainer(); 0054 IndexedContainer(const IndexedContainer& rhs); 0055 IndexedContainer(IndexedContainerData& data); 0056 void addEntry(AbstractType::Ptr typeToAdd); 0057 AbstractType* clone() const override; 0058 uint hash() const override; 0059 int typesCount() const; 0060 const IndexedType& typeAt(int index) const; 0061 void replaceType(int index, AbstractType::Ptr newType); 0062 QString toString() const override; 0063 // "toString"s only the container type, not the content; used in declarationnavigationcontext to create 0064 // separate links for the content and container type 0065 // by keeping toString separate, it is possible to have a pretty type in mixed types etc. without additional 0066 // efforts being necessary 0067 QString containerToString() const; 0068 0069 bool equals(const AbstractType* rhs) const override; 0070 0071 enum { 0072 Identity = 52 0073 }; 0074 0075 typedef IndexedContainerData Data; 0076 0077 protected: 0078 TYPE_DECLARE_DATA(IndexedContainer); 0079 }; 0080 0081 } 0082 0083 #endif // INDEXEDCONTAINER_H