Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:42:50

0001 //===-- OptionValueEnumeration.h --------------------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H
0010 #define LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H
0011 
0012 #include "lldb/Core/UniqueCStringMap.h"
0013 #include "lldb/Interpreter/OptionValue.h"
0014 #include "lldb/Utility/ConstString.h"
0015 #include "lldb/Utility/Status.h"
0016 #include "lldb/Utility/Stream.h"
0017 #include "lldb/Utility/StreamString.h"
0018 #include "lldb/lldb-private-types.h"
0019 
0020 namespace lldb_private {
0021 
0022 class OptionValueEnumeration
0023     : public Cloneable<OptionValueEnumeration, OptionValue> {
0024 public:
0025   typedef int64_t enum_type;
0026   struct EnumeratorInfo {
0027     enum_type value;
0028     const char *description;
0029   };
0030   typedef UniqueCStringMap<EnumeratorInfo> EnumerationMap;
0031   typedef EnumerationMap::Entry EnumerationMapEntry;
0032 
0033   OptionValueEnumeration(const OptionEnumValues &enumerators, enum_type value);
0034 
0035   ~OptionValueEnumeration() override = default;
0036 
0037   // Virtual subclass pure virtual overrides
0038 
0039   OptionValue::Type GetType() const override { return eTypeEnum; }
0040 
0041   void DumpValue(const ExecutionContext *exe_ctx, Stream &strm,
0042                  uint32_t dump_mask) override;
0043 
0044   Status
0045   SetValueFromString(llvm::StringRef value,
0046                      VarSetOperationType op = eVarSetOperationAssign) override;
0047 
0048   void Clear() override {
0049     m_current_value = m_default_value;
0050     m_value_was_set = false;
0051   }
0052 
0053   void AutoComplete(CommandInterpreter &interpreter,
0054                     CompletionRequest &request) override;
0055 
0056   // Subclass specific functions
0057 
0058   enum_type operator=(enum_type value) {
0059     m_current_value = value;
0060     return m_current_value;
0061   }
0062 
0063   enum_type GetCurrentValue() const { return m_current_value; }
0064 
0065   enum_type GetDefaultValue() const { return m_default_value; }
0066 
0067   void SetCurrentValue(enum_type value) { m_current_value = value; }
0068 
0069   void SetDefaultValue(enum_type value) { m_default_value = value; }
0070 
0071 protected:
0072   void SetEnumerations(const OptionEnumValues &enumerators);
0073 
0074   enum_type m_current_value;
0075   enum_type m_default_value;
0076   EnumerationMap m_enumerations;
0077 };
0078 
0079 } // namespace lldb_private
0080 
0081 #endif // LLDB_INTERPRETER_OPTIONVALUEENUMERATION_H