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