]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
Merge ^/head r293036 through r293174.
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Interpreter / OptionValueEnumeration.h
1 //===-- OptionValueEnumeration.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_OptionValueEnumeration_h_
11 #define liblldb_OptionValueEnumeration_h_
12
13 // C Includes
14 // C++ Includes
15 // Other libraries and framework includes
16 // Project includes
17 #include "lldb/Core/ConstString.h"
18 #include "lldb/Core/Error.h"
19 #include "lldb/Core/Stream.h"
20 #include "lldb/Core/StreamString.h"
21 #include "lldb/Core/UniqueCStringMap.h"
22 #include "lldb/Interpreter/OptionValue.h"
23
24 namespace lldb_private {
25
26 class OptionValueEnumeration : public OptionValue
27 {
28 public:
29     typedef int64_t enum_type;
30     struct EnumeratorInfo
31     {
32         enum_type value;
33         const char *description;
34     };
35     typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
36     typedef EnumerationMap::Entry EnumerationMapEntry;
37
38     OptionValueEnumeration (const OptionEnumValueElement *enumerators, enum_type value);
39     
40     ~OptionValueEnumeration() override;
41     
42     //---------------------------------------------------------------------
43     // Virtual subclass pure virtual overrides
44     //---------------------------------------------------------------------
45     
46     OptionValue::Type
47     GetType() const override
48     {
49         return eTypeEnum;
50     }
51     
52     void
53     DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override;
54     
55     Error
56     SetValueFromString(llvm::StringRef value,
57                        VarSetOperationType op = eVarSetOperationAssign) override;
58     
59     bool
60     Clear() override
61     {
62         m_current_value = m_default_value;
63         m_value_was_set = false;
64         return true;
65     }
66     
67     lldb::OptionValueSP
68     DeepCopy() const override;
69     
70     size_t
71     AutoComplete(CommandInterpreter &interpreter,
72                  const char *s,
73                  int match_start_point,
74                  int max_return_elements,
75                  bool &word_complete,
76                  StringList &matches) override;
77
78     //---------------------------------------------------------------------
79     // Subclass specific functions
80     //---------------------------------------------------------------------
81     
82     enum_type
83     operator = (enum_type value)
84     {
85         m_current_value = value;
86         return m_current_value;
87     }
88     
89     enum_type
90     GetCurrentValue() const
91     {
92         return m_current_value;
93     }
94     
95     enum_type
96     GetDefaultValue() const
97     {
98         return m_default_value;
99     }
100     
101     void
102     SetCurrentValue (enum_type value)
103     {
104         m_current_value = value;
105     }
106     
107     void
108     SetDefaultValue (enum_type value)
109     {
110         m_default_value = value;
111     }
112     
113 protected:
114     void
115     SetEnumerations (const OptionEnumValueElement *enumerators);
116
117     enum_type m_current_value;
118     enum_type m_default_value;
119     EnumerationMap m_enumerations;
120 };
121
122 } // namespace lldb_private
123
124 #endif // liblldb_OptionValueEnumeration_h_