Property.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //===-- Property.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. #ifndef LLDB_INTERPRETER_PROPERTY_H
  9. #define LLDB_INTERPRETER_PROPERTY_H
  10. #include "lldb/Interpreter/OptionValue.h"
  11. #include "lldb/Utility/ConstString.h"
  12. #include "lldb/Utility/Flags.h"
  13. #include "lldb/lldb-defines.h"
  14. #include "lldb/lldb-private-types.h"
  15. #include <string>
  16. namespace lldb_private {
  17. // A structure that can be used to create a global table for all properties.
  18. // Property class instances can be constructed using one of these.
  19. struct PropertyDefinition {
  20. const char *name;
  21. OptionValue::Type type;
  22. bool global; // false == this setting is a global setting by default
  23. uintptr_t default_uint_value;
  24. const char *default_cstr_value;
  25. OptionEnumValues enum_values;
  26. const char *description;
  27. };
  28. using PropertyDefinitions = llvm::ArrayRef<PropertyDefinition>;
  29. class Property {
  30. public:
  31. Property(const PropertyDefinition &definition);
  32. Property(ConstString name, ConstString desc, bool is_global,
  33. const lldb::OptionValueSP &value_sp);
  34. llvm::StringRef GetName() const { return m_name.GetStringRef(); }
  35. llvm::StringRef GetDescription() const {
  36. return m_description.GetStringRef();
  37. }
  38. const lldb::OptionValueSP &GetValue() const { return m_value_sp; }
  39. void SetOptionValue(const lldb::OptionValueSP &value_sp) {
  40. m_value_sp = value_sp;
  41. }
  42. bool IsValid() const { return (bool)m_value_sp; }
  43. bool IsGlobal() const { return m_is_global; }
  44. void Dump(const ExecutionContext *exe_ctx, Stream &strm,
  45. uint32_t dump_mask) const;
  46. bool DumpQualifiedName(Stream &strm) const;
  47. void DumpDescription(CommandInterpreter &interpreter, Stream &strm,
  48. uint32_t output_width,
  49. bool display_qualified_name) const;
  50. void SetValueChangedCallback(std::function<void()> callback);
  51. protected:
  52. ConstString m_name;
  53. ConstString m_description;
  54. lldb::OptionValueSP m_value_sp;
  55. bool m_is_global;
  56. };
  57. } // namespace lldb_private
  58. #endif // LLDB_INTERPRETER_PROPERTY_H