LLDB  mainline
OptionValueEnumeration.h
Go to the documentation of this file.
1 //===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef liblldb_OptionValueEnumeration_h_
10 #define liblldb_OptionValueEnumeration_h_
11 
15 #include "lldb/Utility/Status.h"
16 #include "lldb/Utility/Stream.h"
19 
20 namespace lldb_private {
21 
23 public:
24  typedef int64_t enum_type;
25  struct EnumeratorInfo {
26  enum_type value;
27  const char *description;
28  };
30  typedef EnumerationMap::Entry EnumerationMapEntry;
31 
32  OptionValueEnumeration(const OptionEnumValues &enumerators, enum_type value);
33 
34  ~OptionValueEnumeration() override;
35 
36  // Virtual subclass pure virtual overrides
37 
38  OptionValue::Type GetType() const override { return eTypeEnum; }
39 
40  void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
41  uint32_t dump_mask) override;
42 
43  Status
44  SetValueFromString(llvm::StringRef value,
46  Status
47  SetValueFromString(const char *,
49 
50  bool Clear() override {
52  m_value_was_set = false;
53  return true;
54  }
55 
56  lldb::OptionValueSP DeepCopy() const override;
57 
58  size_t AutoComplete(CommandInterpreter &interpreter,
59  CompletionRequest &request) override;
60 
61  // Subclass specific functions
62 
63  enum_type operator=(enum_type value) {
65  return m_current_value;
66  }
67 
68  enum_type GetCurrentValue() const { return m_current_value; }
69 
70  enum_type GetDefaultValue() const { return m_default_value; }
71 
72  void SetCurrentValue(enum_type value) { m_current_value = value; }
73 
74  void SetDefaultValue(enum_type value) { m_default_value = value; }
75 
76 protected:
77  void SetEnumerations(const OptionEnumValues &enumerators);
78 
79  enum_type m_current_value;
80  enum_type m_default_value;
81  EnumerationMap m_enumerations;
82 };
83 
84 } // namespace lldb_private
85 
86 #endif // liblldb_OptionValueEnumeration_h_
size_t AutoComplete(CommandInterpreter &interpreter, CompletionRequest &request) override
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
OptionValue::Type GetType() const override
void SetEnumerations(const OptionEnumValues &enumerators)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
OptionValueEnumeration(const OptionEnumValues &enumerators, enum_type value)
"lldb/Utility/ArgCompletionRequest.h"
VarSetOperationType
Settable state variable types.
void DumpValue(const ExecutionContext *exe_ctx, Stream &strm, uint32_t dump_mask) override
Status SetValueFromString(llvm::StringRef value, VarSetOperationType op=eVarSetOperationAssign) override
lldb::OptionValueSP DeepCopy() const override
UniqueCStringMap< EnumeratorInfo > EnumerationMap
An error handling class.
Definition: Status.h:44