Language.h revision 49ce8969d3154e1560106cfe530444c09410f217
1//===-- Language.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_Language_h_
11#define liblldb_Language_h_
12
13#include "lldb/lldb-private.h"
14
15namespace lldb_private {
16
17//----------------------------------------------------------------------
18/// @class Language Language.h "lldb/Core/Language.h"
19/// @brief Encapsulates the programming language for an lldb object.
20///
21/// Languages are represented by an enumeration value.
22///
23/// The enumeration values used when describing the programming language
24/// are the same values as the latest DWARF specification.
25//----------------------------------------------------------------------
26class Language
27{
28public:
29    //------------------------------------------------------------------
30    /// Construct with optional language enumeration.
31    //------------------------------------------------------------------
32    Language(lldb::LanguageType language = lldb::eLanguageTypeUnknown);
33
34    //------------------------------------------------------------------
35    /// Destructor.
36    ///
37    /// The destructor is virtual in case this class is subclassed.
38    //------------------------------------------------------------------
39    virtual
40    ~Language();
41
42    //------------------------------------------------------------------
43    /// Get the language value as a NULL termianted C string.
44    ///
45    /// @return
46    ///     The C string representation of the language. The returned
47    ///     string does not need to be freed as it comes from constant
48    ///     strings. NULL can be returned when the language is set to
49    ///     a value that doesn't match of of the lldb::LanguageType
50    ///     enumerations.
51    //------------------------------------------------------------------
52    const char *
53    AsCString (lldb::DescriptionLevel level = lldb::eDescriptionLevelBrief) const;
54
55    void
56    Clear();
57
58    void
59    GetDescription (Stream *s, lldb::DescriptionLevel level) const;
60
61    //------------------------------------------------------------------
62    /// Dump the language value to the stream \a s.
63    ///
64    /// @param[in] s
65    ///     The stream to which to dump the language description.
66    //------------------------------------------------------------------
67    void
68    Dump(Stream *s) const;
69
70    //------------------------------------------------------------------
71    /// Get accessor for the language.
72    ///
73    /// @return
74    ///     The enumeration value that describes the programming
75    ///     language that an object is associated with.
76    //------------------------------------------------------------------
77    virtual lldb::LanguageType
78    GetLanguage() const;
79
80    //------------------------------------------------------------------
81    /// Set accessor for the language.
82    ///
83    /// @param[in] language
84    ///     The new enumeration value that describes the programming
85    ///     language that an object is associated with.
86    //------------------------------------------------------------------
87    void
88    SetLanguage(lldb::LanguageType language);
89
90    //------------------------------------------------------------------
91    /// Set accessor for the language.
92    ///
93    /// @param[in] language_cstr
94    ///     The language name as a C string.
95    //------------------------------------------------------------------
96    bool
97    SetLanguageFromCString(const char *language_cstr);
98
99
100protected:
101    //------------------------------------------------------------------
102    // Member variables
103    //------------------------------------------------------------------
104    lldb::LanguageType m_language; ///< The programming language enumeration value.
105                                   ///< The enumeration values are the same as the
106                                   ///< latest DWARF specification.
107};
108
109//--------------------------------------------------------------
110/// Stream the language enumeration as a string object to a
111/// Stream.
112//--------------------------------------------------------------
113Stream& operator << (Stream& s, const Language& language);
114
115} // namespace lldb_private
116
117#endif  // liblldb_Language_h_
118