• 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
typepointer.h
Go to the documentation of this file.
1 /*
2  * This file is part of the KDE libraries.
3  *
4  * Copyright 2005 Frerich Raabe <[email protected]>
5  * Copyright 2007-2008 David Nolden <[email protected]>
6  * Copyright 2014 Kevin Funk <[email protected]>
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the distribution.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 #ifndef KDEVPLATFORM_TYPEPOINTER_H
30 #define KDEVPLATFORM_TYPEPOINTER_H
31 
32 #include <QExplicitlySharedDataPointer>
33 
34 namespace KDevelop {
38 template <class T>
39 class TypePtr
40  : public QExplicitlySharedDataPointer<T>
41 {
42  using Base = QExplicitlySharedDataPointer<T>;
43 
44 public:
45  using Base::QExplicitlySharedDataPointer;
46  TypePtr<T>() = default;
47  TypePtr<T>(const TypePtr<T>&) = default;
48  TypePtr<T>(TypePtr<T>&&) = default;
49 
50  using Base::operator=;
51  TypePtr<T>& operator=(const TypePtr<T>&) = default;
52  TypePtr<T>& operator=(TypePtr<T>&&) = default;
53 
55  template <class U>
56  TypePtr<U> cast(U* /*dummy*/ = nullptr) const
57  {
58  return TypePtr<U>(dynamic_cast<U*>(Base::data()));
59  }
60 
71  template <class U>
72  static TypePtr<T> staticCast(const TypePtr<U>& o)
73  {
74  return TypePtr<T>(static_cast<T*>(o.data()));
75  }
87  template <class U>
88  static TypePtr<T> dynamicCast(const TypePtr<U>& o)
89  {
90  return TypePtr<T>(dynamic_cast<T*>(o.data()));
91  }
92 };
93 }
94 
95 #endif
KDevelop::TypePtr::operator=
TypePtr< T > & operator=(const TypePtr< T > &)=default
KDevelop::TypePtr::dynamicCast
static TypePtr< T > dynamicCast(const TypePtr< U > &o)
Convert TypePtr to TypePtr<T>, using a dynamic_cast.
Definition: typepointer.h:88
QExplicitlySharedDataPointer::data
T * data() const
KDevelop::TypePtr
QExplicitlySharedDataPointer wrapper with convenience functions attached.
Definition: typepointer.h:39
KDevelop::TypePtr::staticCast
static TypePtr< T > staticCast(const TypePtr< U > &o)
Convert TypePtr to TypePtr<T>, using a static_cast.
Definition: typepointer.h:72
QExplicitlySharedDataPointer
Definition: topducontext.h:28
QExplicitlySharedDataPointer::QExplicitlySharedDataPointer
QExplicitlySharedDataPointer()
KDevelop::TypePtr::cast
TypePtr< U > cast(U *=nullptr) const
Uses dynamic_cast to cast this pointer to the given type.
Definition: typepointer.h:56
KDevelop
Definition: abstractfunctiondeclaration.cpp:27
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Jan 23 2021 09:40:52 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