Changeset View
Changeset View
Standalone View
Standalone View
duchain/types/indexedcontainer.h
- This file was added.
1 | /** | ||||
---|---|---|---|---|---|
2 | This file is part of KDevelop | ||||
3 | Copyright (C) 2011 Sven Brauch <svenbrauch@googlemail.com> | ||||
4 | | ||||
5 | This program is free software: you can redistribute it and/or modify | ||||
6 | it under the terms of the GNU General Public License as published by | ||||
7 | the Free Software Foundation, either version 2 of the License, or | ||||
8 | (at your option) any later version. | ||||
9 | | ||||
10 | This program is distributed in the hope that it will be useful, | ||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
13 | GNU General Public License for more details. | ||||
14 | | ||||
15 | You should have received a copy of the GNU General Public License | ||||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
17 | **/ | ||||
18 | | ||||
19 | | ||||
20 | #ifndef INDEXEDCONTAINER_H | ||||
21 | #define INDEXEDCONTAINER_H | ||||
22 | | ||||
23 | #include "structuretype.h" | ||||
24 | #include <language/duchain/types/typesystemdata.h> | ||||
25 | | ||||
26 | #include "phpduchainexport.h" | ||||
27 | | ||||
28 | using namespace KDevelop; | ||||
29 | | ||||
30 | namespace Php { | ||||
31 | | ||||
32 | KDEVPHPDUCHAIN_EXPORT DECLARE_LIST_MEMBER_HASH(IndexedContainerData, m_values, IndexedType) | ||||
33 | | ||||
34 | class KDEVPHPDUCHAIN_EXPORT IndexedContainerData : public Php::StructureTypeData | ||||
35 | { | ||||
36 | public: | ||||
37 | /// Constructor | ||||
38 | IndexedContainerData() | ||||
39 | : Php::StructureTypeData() | ||||
40 | { | ||||
41 | initializeAppendedLists(m_dynamic); | ||||
42 | } | ||||
43 | /// Copy constructor. \param rhs data to copy | ||||
44 | IndexedContainerData( const IndexedContainerData& rhs ) | ||||
45 | : Php::StructureTypeData(rhs) | ||||
46 | { | ||||
47 | initializeAppendedLists(m_dynamic); | ||||
48 | copyListsFrom(rhs); | ||||
49 | } | ||||
50 | | ||||
51 | ~IndexedContainerData() { | ||||
52 | freeAppendedLists(); | ||||
53 | }; | ||||
54 | | ||||
55 | START_APPENDED_LISTS_BASE(IndexedContainerData, StructureTypeData) | ||||
56 | APPENDED_LIST_FIRST(IndexedContainerData, IndexedType, m_values) | ||||
57 | END_APPENDED_LISTS(IndexedContainerData, m_values) | ||||
58 | }; | ||||
59 | | ||||
60 | | ||||
61 | class KDEVPHPDUCHAIN_EXPORT IndexedContainer : public Php::StructureType | ||||
62 | { | ||||
63 | public: | ||||
64 | typedef TypePtr<IndexedContainer> Ptr; | ||||
65 | | ||||
66 | IndexedContainer(); | ||||
67 | IndexedContainer(const IndexedContainer& rhs); | ||||
68 | IndexedContainer(IndexedContainerData& data); | ||||
69 | void addEntry(AbstractType::Ptr typeToAdd); | ||||
70 | AbstractType* clone() const override; | ||||
71 | uint hash() const override; | ||||
72 | int typesCount() const; | ||||
73 | const IndexedType& typeAt(int index) const; | ||||
74 | void replaceType(int index, AbstractType::Ptr newType); | ||||
75 | QString toString() const override; | ||||
76 | // "toString"s only the container type, not the content; used in declarationnavigationcontext to create | ||||
77 | // separate links for the content and container type | ||||
78 | // by keeping toString separate, it is possible to have a pretty type in mixed types etc. without additional | ||||
79 | // efforts being necessary | ||||
80 | QString containerToString() const; | ||||
81 | | ||||
82 | bool equals(const AbstractType* rhs) const override; | ||||
83 | | ||||
84 | enum { | ||||
85 | // #warning check identity value (59) | ||||
86 | Identity = 59 | ||||
87 | }; | ||||
88 | | ||||
89 | typedef IndexedContainerData Data; | ||||
90 | | ||||
91 | protected: | ||||
92 | TYPE_DECLARE_DATA(IndexedContainer); | ||||
93 | }; | ||||
94 | | ||||
95 | } | ||||
96 | | ||||
97 | #endif // INDEXEDCONTAINER_H |