• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdevelop API Reference
  • KDE Home
  • Contact Us
 

kdevplatform/language/duchain

  • sources
  • kfour-appscomplete
  • kdevelop
  • kdevplatform
  • language
  • duchain
  • types
containertypes.h
Go to the documentation of this file.
1 /*
2  * This file is part of KDevelop
3  * Copyright (C) 2011-2014 Sven Brauch <[email protected]>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Library 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 Library General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef KDEVPLATFORM_CONTAINER_TYPES_H
20 #define KDEVPLATFORM_CONTAINER_TYPES_H
21 
22 #include "structuretype.h"
23 #include "typesystemdata.h"
24 #include "typeutils.h"
25 #include "../duchainlock.h"
26 
27 #include <language/languageexport.h>
28 
29 namespace KDevelop {
30 class KDEVPLATFORMLANGUAGE_EXPORT ListTypeData
31  : public KDevelop::StructureTypeData
32 {
33 public:
34  ListTypeData()
35  : KDevelop::StructureTypeData()
36  , m_contentType() { }
37 
38  ListTypeData(const ListTypeData& rhs)
39  : KDevelop::StructureTypeData(rhs)
40  , m_contentType(rhs.m_contentType) { }
41 
42  explicit ListTypeData(const KDevelop::StructureTypeData& rhs)
43  : KDevelop::StructureTypeData(rhs)
44  , m_contentType() { }
45 
46  ~ListTypeData() = default;
47 
48  ListTypeData& operator=(const ListTypeData& rhs) = delete;
49 
50  IndexedType m_contentType;
51 };
52 
83 class KDEVPLATFORMLANGUAGE_EXPORT ListType
84  : public KDevelop::StructureType
85 {
86 public:
87  using Ptr = TypePtr<ListType>;
88 
89  ListType();
90  ListType(const ListType& rhs);
91  explicit ListType(StructureTypeData& data);
92 
93  ListType& operator=(const ListType& rhs) = delete;
94 
112  template <typename LanguageUnsureType>
113  void addContentType(const AbstractType::Ptr& typeToAdd)
114  {
115  auto newContentType = TypeUtils::mergeTypes<LanguageUnsureType>(contentType().abstractType(), typeToAdd);
116  d_func_dynamic()->m_contentType = IndexedType(newContentType);
117  }
118 
122  void replaceContentType(const AbstractType::Ptr& newType);
123 
127  IndexedType contentType() const;
128 
132  QString containerToString() const;
133 
137  QString toString() const override;
138 
139  AbstractType* clone() const override;
140  uint hash() const override;
141  bool equals(const AbstractType* rhs) const override;
142 
143  enum { Identity = 58 };
144 
145  using Data = ListTypeData;
146 
147 protected:
148  TYPE_DECLARE_DATA(ListType);
149 };
150 
151 class KDEVPLATFORMLANGUAGE_EXPORT MapTypeData
152  : public ListTypeData
153 {
154 public:
155  MapTypeData()
156  : ListTypeData()
157  , m_keyType() { }
158 
159  MapTypeData(const MapTypeData& rhs)
160  : ListTypeData(rhs)
161  , m_keyType(rhs.m_keyType) { }
162 
163  explicit MapTypeData(const ListTypeData& rhs)
164  : ListTypeData(rhs)
165  , m_keyType() { }
166 
167  ~MapTypeData() = default;
168 
169  MapTypeData& operator=(const ListTypeData& rhs) = delete;
170 
171  IndexedType m_keyType;
172 };
173 
180 class KDEVPLATFORMLANGUAGE_EXPORT MapType
181  : public ListType
182 {
183 public:
184  using Ptr = TypePtr<MapType>;
185 
186  MapType();
187  MapType(const MapType& rhs);
188  explicit MapType(ListTypeData& data);
189 
190  MapType& operator=(const MapType& rhs) = delete;
191 
196  template <typename LanguageUnsureType>
197  void addKeyType(const AbstractType::Ptr& typeToAdd)
198  {
199  auto newKeyType = TypeUtils::mergeTypes<LanguageUnsureType>(keyType().abstractType(), typeToAdd);
200  DUChainWriteLocker lock;
201  d_func_dynamic()->m_keyType = IndexedType(newKeyType);
202  }
203 
207  void replaceKeyType(const AbstractType::Ptr& newType);
208 
212  IndexedType keyType() const;
213 
217  QString toString() const override;
218 
219  AbstractType* clone() const override;
220  uint hash() const override;
221  bool equals(const AbstractType* rhs) const override;
222 
223  enum { Identity = 57 };
224 
225  using Data = MapTypeData;
226 
227 protected:
228  TYPE_DECLARE_DATA(MapType);
229 };
230 } // namespace KDevelop
231 
232 #endif // KDEVPLATFORM_CONTAINER_TYPES_H
KDevelop::ListType::addContentType
void addContentType(const AbstractType::Ptr &typeToAdd)
Adds typeToAdd to the content type of this list.
Definition: containertypes.h:113
KDevelop::DUChainWriteLocker
Customized write locker for the definition-use chain.
Definition: duchainlock.h:148
KDevelop::ListTypeData::ListTypeData
ListTypeData()
Definition: containertypes.h:34
KDevelop::MapType
Represents a hashmap-like object which can have a key and a content type.
Definition: containertypes.h:180
KDevelop::ListTypeData
Definition: containertypes.h:30
KDevelop::ListType
Represents a list-like object which can have a content type.
Definition: containertypes.h:83
TYPE_DECLARE_DATA
#define TYPE_DECLARE_DATA(Class)
This macro is used to declare type-specific data-access functions within subclasses of AbstractType.
Definition: abstracttype.h:38
KDevelop::MapTypeData::MapTypeData
MapTypeData(const ListTypeData &rhs)
Definition: containertypes.h:163
KDevelop::StructureTypeData
Private data structure for StructureType.
Definition: typesystemdata.h:198
KDevelop::MapTypeData::MapTypeData
MapTypeData(const MapTypeData &rhs)
Definition: containertypes.h:159
KDevelop::MapTypeData::m_keyType
IndexedType m_keyType
Definition: containertypes.h:171
KDevelop::TypePtr
QExplicitlySharedDataPointer wrapper with convenience functions attached.
Definition: typepointer.h:39
KDevelop::MapTypeData::MapTypeData
MapTypeData()
Definition: containertypes.h:155
KDevelop::MapType::addKeyType
void addKeyType(const AbstractType::Ptr &typeToAdd)
Add typeToAdd to this map's key type.
Definition: containertypes.h:197
typeutils.h
typesystemdata.h
QString
structuretype.h
KDevelop::MapTypeData
Definition: containertypes.h:151
KDevelop::ListTypeData::ListTypeData
ListTypeData(const ListTypeData &rhs)
Definition: containertypes.h:38
KDevelop::ListTypeData::m_contentType
IndexedType m_contentType
Definition: containertypes.h:50
KDevelop::ListTypeData::ListTypeData
ListTypeData(const KDevelop::StructureTypeData &rhs)
Definition: containertypes.h:42
KDevelop::IndexedType
Indexed type pointer.
Definition: indexedtype.h:36
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::StructureType
A type representing structure types.
Definition: structuretype.h:38
KDevelop::AbstractType
Base class for all types.
Definition: abstracttype.h:87
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:30:10 by doxygen 1.8.16 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kdevplatform/language/duchain

Skip menu "kdevplatform/language/duchain"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdevelop API Reference

Skip menu "kdevelop API Reference"
  • kdevplatform
  •   debugger
  •   documentation
  •   interfaces
  •   language
  •     assistant
  •     backgroundparser
  •     checks
  •     classmodel
  •     codecompletion
  •     codegen
  •     duchain
  •     editor
  •     highlighting
  •     interfaces
  •     util
  •   outputview
  •   project
  •   serialization
  •   shell
  •   sublime
  •   tests
  •   util
  •   vcs

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal