]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Interpreter/OptionValueEnumeration.h
Import DTS files from Linux 4.18
[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 #include "lldb/Core/UniqueCStringMap.h"
14 #include "lldb/Interpreter/OptionValue.h"
15 #include "lldb/Utility/ConstString.h"
16 #include "lldb/Utility/Status.h"
17 #include "lldb/Utility/Stream.h"
18 #include "lldb/Utility/StreamString.h"
19 #include "lldb/lldb-private-types.h"
20
21 namespace lldb_private {
22
23 class OptionValueEnumeration : public OptionValue {
24 public:
25   typedef int64_t enum_type;
26   struct EnumeratorInfo {
27     enum_type value;
28     const char *description;
29   };
30   typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
31   typedef EnumerationMap::Entry EnumerationMapEntry;
32
33   OptionValueEnumeration(const OptionEnumValueElement *enumerators,
34                          enum_type value);
35
36   ~OptionValueEnumeration() override;
37
38   //---------------------------------------------------------------------
39   // Virtual subclass pure virtual overrides
40   //---------------------------------------------------------------------
41
42   OptionValue::Type GetType() const override { return eTypeEnum; }
43
44   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
45                  uint32_t dump_mask) override;
46
47   Status
48   SetValueFromString(llvm::StringRef value,
49                      VarSetOperationType op = eVarSetOperationAssign) override;
50   Status
51   SetValueFromString(const char *,
52                      VarSetOperationType = eVarSetOperationAssign) = delete;
53
54   bool Clear() override {
55     m_current_value = m_default_value;
56     m_value_was_set = false;
57     return true;
58   }
59
60   lldb::OptionValueSP DeepCopy() const override;
61
62   size_t AutoComplete(CommandInterpreter &interpreter, llvm::StringRef s,
63                       int match_start_point, int max_return_elements,
64                       bool &word_complete, StringList &matches) override;
65
66   //---------------------------------------------------------------------
67   // Subclass specific functions
68   //---------------------------------------------------------------------
69
70   enum_type operator=(enum_type value) {
71     m_current_value = value;
72     return m_current_value;
73   }
74
75   enum_type GetCurrentValue() const { return m_current_value; }
76
77   enum_type GetDefaultValue() const { return m_default_value; }
78
79   void SetCurrentValue(enum_type value) { m_current_value = value; }
80
81   void SetDefaultValue(enum_type value) { m_default_value = value; }
82
83 protected:
84   void SetEnumerations(const OptionEnumValueElement *enumerators);
85
86   enum_type m_current_value;
87   enum_type m_default_value;
88   EnumerationMap m_enumerations;
89 };
90
91 } // namespace lldb_private
92
93 #endif // liblldb_OptionValueEnumeration_h_