1 //===-- ClangNamespaceDecl.h ------------------------------------*- C++ -*-===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 #ifndef liblldb_ClangNamespaceDecl_h_ 11 #define liblldb_ClangNamespaceDecl_h_ 12 13 #include <string> 14 15 #include "lldb/lldb-public.h" 16 #include "lldb/Core/ClangForward.h" 17 18 namespace lldb_private { 19 20 class ClangNamespaceDecl 21 { 22 public: ClangNamespaceDecl()23 ClangNamespaceDecl () : 24 m_ast (NULL), 25 m_namespace_decl (NULL) 26 { 27 } 28 ClangNamespaceDecl(clang::ASTContext * ast,clang::NamespaceDecl * namespace_decl)29 ClangNamespaceDecl (clang::ASTContext *ast, clang::NamespaceDecl *namespace_decl) : 30 m_ast (ast), 31 m_namespace_decl (namespace_decl) 32 { 33 } 34 ClangNamespaceDecl(const ClangNamespaceDecl & rhs)35 ClangNamespaceDecl (const ClangNamespaceDecl &rhs) : 36 m_ast (rhs.m_ast), 37 m_namespace_decl (rhs.m_namespace_decl) 38 { 39 } 40 41 const ClangNamespaceDecl & 42 operator = (const ClangNamespaceDecl &rhs) 43 { 44 m_ast = rhs.m_ast; 45 m_namespace_decl = rhs.m_namespace_decl; 46 return *this; 47 } 48 49 //------------------------------------------------------------------ 50 /// Convert to bool operator. 51 /// 52 /// This allows code to check a ClangNamespaceDecl object to see if 53 /// it contains a valid namespace decl using code such as: 54 /// 55 /// @code 56 /// ClangNamespaceDecl ns_decl(...); 57 /// if (ns_decl) 58 /// { ... 59 /// @endcode 60 /// 61 /// @return 62 /// /b True this object contains a valid namespace decl, \b 63 /// false otherwise. 64 //------------------------------------------------------------------ 65 explicit operator bool() const 66 { 67 return m_ast != NULL && m_namespace_decl != NULL; 68 } 69 70 clang::ASTContext * GetASTContext()71 GetASTContext() const 72 { 73 return m_ast; 74 } 75 76 void SetASTContext(clang::ASTContext * ast)77 SetASTContext (clang::ASTContext *ast) 78 { 79 m_ast = ast; 80 } 81 82 clang::NamespaceDecl * GetNamespaceDecl()83 GetNamespaceDecl () const 84 { 85 return m_namespace_decl; 86 } 87 88 void SetNamespaceDecl(clang::NamespaceDecl * namespace_decl)89 SetNamespaceDecl (clang::NamespaceDecl *namespace_decl) 90 { 91 m_namespace_decl = namespace_decl; 92 } 93 94 std::string 95 GetQualifiedName () const; 96 97 protected: 98 clang::ASTContext *m_ast; 99 clang::NamespaceDecl *m_namespace_decl; 100 }; 101 102 103 } // namespace lldb_private 104 105 #endif // #ifndef liblldb_ClangNamespaceDecl_h_ 106