• 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
indexedtopducontext.h
Go to the documentation of this file.
1 /* This file is part of KDevelop
2  Copyright 2007 David Nolden <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17  */
18 
19 #ifndef KDEVPLATFORM_INDEXEDTOPDUCONTEXT_H
20 #define KDEVPLATFORM_INDEXEDTOPDUCONTEXT_H
21 
22 #include <QMetaType>
23 #include <QPair>
24 
25 #include <language/languageexport.h>
26 
27 namespace KDevelop {
28 class IndexedString;
29 class IndexedTopDUContextEmbeddedTreeHandler;
30 class TopDUContext;
31 
35 class KDEVPLATFORMLANGUAGE_EXPORT IndexedTopDUContext
36 {
37 public:
38  inline IndexedTopDUContext(uint index) : m_index(index)
39  {
40  if (!index)
41  setIsDummy(true);
42  }
43  IndexedTopDUContext(TopDUContext* context = nullptr);
44 
45  enum {
46  DummyMask = 1u << 31u
47  };
48 
56  TopDUContext* data() const;
57 
63  bool isLoaded() const;
64 
65  inline bool operator==(const IndexedTopDUContext& rhs) const
66  {
67  return m_index == rhs.m_index;
68  }
69 
70  inline bool operator!=(const IndexedTopDUContext& rhs) const
71  {
72  return m_index != rhs.m_index;
73  }
74 
75  inline bool operator<(const IndexedTopDUContext& rhs) const
76  {
77  return m_index < rhs.m_index;
78  }
79 
80  inline bool isValid() const
81  {
82  return m_index && !isDummy();
83  }
84 
85  inline uint index() const
86  {
87  if (isDummy())
88  return 0;
89  else
90  return m_index;
91  }
92 
93  inline bool isDummy() const
94  {
95  return m_index & DummyMask;
96  }
97 
98  void setIsDummy(bool isDummy)
99  {
100  if (isDummy)
101  m_index |= DummyMask;
102  else
103  m_index &= ~(( uint )DummyMask);
104  }
105 
113  void setDummyData(ushort first, ushort second)
114  {
115  Q_ASSERT(isDummy());
116  m_index = (((( uint )first) << 16) + second) | DummyMask;
117  }
118 
122  QPair<ushort, ushort> dummyData() const
123  {
124  uint withoutMask = m_index & (~(( uint )DummyMask));
125  return qMakePair(( ushort )(withoutMask >> 16), ( ushort )withoutMask);
126  }
127 
128  IndexedString url() const;
129 
130 private:
131  uint m_index;
132  friend class IndexedTopDUContextEmbeddedTreeHandler;
133 };
134 
135 struct IndexedTopDUContextIndexConversion
136 {
137  inline static uint toIndex(const IndexedTopDUContext& top)
138  {
139  return top.index();
140  }
141 
142  inline static IndexedTopDUContext toItem(uint index)
143  {
144  return IndexedTopDUContext(index);
145  }
146 };
147 
148 inline uint qHash(const IndexedTopDUContext& ctx)
149 {
150  return ctx.index();
151 }
152 }
153 
154 Q_DECLARE_METATYPE(KDevelop::IndexedTopDUContext)
155 Q_DECLARE_TYPEINFO(KDevelop::IndexedTopDUContext, Q_MOVABLE_TYPE);
156 
157 #endif // KDEVPLATFORM_INDEXEDTOPDUCONTEXT_H
KDevelop::IndexedTopDUContext
Allows simple indirect access to top-contexts with on-demand loading.
Definition: indexedtopducontext.h:35
KDevelop::IndexedTopDUContext::operator==
bool operator==(const IndexedTopDUContext &rhs) const
Definition: indexedtopducontext.h:65
KDevelop::IndexedTopDUContext::operator<
bool operator<(const IndexedTopDUContext &rhs) const
Definition: indexedtopducontext.h:75
KDevelop::IndexedTopDUContext::isValid
bool isValid() const
Definition: indexedtopducontext.h:80
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(KDevelop::IndexedTopDUContext, Q_MOVABLE_TYPE)
KDevelop::IndexedTopDUContextIndexConversion::toIndex
static uint toIndex(const IndexedTopDUContext &top)
Definition: indexedtopducontext.h:137
KDevelop::IndexedTopDUContext::isDummy
bool isDummy() const
Definition: indexedtopducontext.h:93
KDevelop::IndexedTopDUContext::setDummyData
void setDummyData(ushort first, ushort second)
Allows giving this IndexedTopDUContext some data while logically keeping it invalid.
Definition: indexedtopducontext.h:113
KDevelop::IndexedTopDUContext::operator!=
bool operator!=(const IndexedTopDUContext &rhs) const
Definition: indexedtopducontext.h:70
KDevelop::IndexedTopDUContext::index
uint index() const
Definition: indexedtopducontext.h:85
KDevelop::TopDUContext
The top context in a definition-use chain for one source file.
Definition: topducontext.h:113
KDevelop::IndexedTopDUContext::IndexedTopDUContext
IndexedTopDUContext(uint index)
Definition: indexedtopducontext.h:38
KDevelop::IndexedTopDUContext::setIsDummy
void setIsDummy(bool isDummy)
Definition: indexedtopducontext.h:98
KDevelop::IndexedTopDUContext::dummyData
QPair< ushort, ushort > dummyData() const
The data previously set through setDummyData().
Definition: indexedtopducontext.h:122
KDevelop::qHash
uint qHash(const KDevelop::DeclarationId &id)
Definition: declarationid.h:205
KDevelop::IndexedTopDUContextIndexConversion
Definition: indexedtopducontext.h:135
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
KDevelop::IndexedTopDUContextIndexConversion::toItem
static IndexedTopDUContext toItem(uint index)
Definition: indexedtopducontext.h:142
QPair
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Thu Mar 4 2021 23:31:17 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