SBStructuredData.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //===-- SBStructuredData.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_API_SBSTRUCTUREDDATA_H
  9. #define LLDB_API_SBSTRUCTUREDDATA_H
  10. #include "lldb/API/SBDefines.h"
  11. #include "lldb/API/SBModule.h"
  12. namespace lldb {
  13. class SBStructuredData {
  14. public:
  15. SBStructuredData();
  16. SBStructuredData(const lldb::SBStructuredData &rhs);
  17. SBStructuredData(const lldb::EventSP &event_sp);
  18. SBStructuredData(lldb_private::StructuredDataImpl *impl);
  19. ~SBStructuredData();
  20. lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);
  21. explicit operator bool() const;
  22. bool IsValid() const;
  23. lldb::SBError SetFromJSON(lldb::SBStream &stream);
  24. void Clear();
  25. lldb::SBError GetAsJSON(lldb::SBStream &stream) const;
  26. lldb::SBError GetDescription(lldb::SBStream &stream) const;
  27. /// Return the type of data in this data structure
  28. lldb::StructuredDataType GetType() const;
  29. /// Return the size (i.e. number of elements) in this data structure
  30. /// if it is an array or dictionary type. For other types, 0 will be
  31. // returned.
  32. size_t GetSize() const;
  33. /// Fill keys with the keys in this object and return true if this data
  34. /// structure is a dictionary. Returns false otherwise.
  35. bool GetKeys(lldb::SBStringList &keys) const;
  36. /// Return the value corresponding to a key if this data structure
  37. /// is a dictionary type.
  38. lldb::SBStructuredData GetValueForKey(const char *key) const;
  39. /// Return the value corresponding to an index if this data structure
  40. /// is array.
  41. lldb::SBStructuredData GetItemAtIndex(size_t idx) const;
  42. /// Return the integer value if this data structure is an integer type.
  43. uint64_t GetIntegerValue(uint64_t fail_value = 0) const;
  44. /// Return the floating point value if this data structure is a floating
  45. /// type.
  46. double GetFloatValue(double fail_value = 0.0) const;
  47. /// Return the boolean value if this data structure is a boolean type.
  48. bool GetBooleanValue(bool fail_value = false) const;
  49. /// Provides the string value if this data structure is a string type.
  50. ///
  51. /// \param[out] dst
  52. /// pointer where the string value will be written. In case it is null,
  53. /// nothing will be written at \a dst.
  54. ///
  55. /// \param[in] dst_len
  56. /// max number of characters that can be written at \a dst. In case it is
  57. /// zero, nothing will be written at \a dst. If this length is not enough
  58. /// to write the complete string value, (\a dst_len - 1) bytes of the
  59. /// string value will be written at \a dst followed by a null character.
  60. ///
  61. /// \return
  62. /// Returns the byte size needed to completely write the string value at
  63. /// \a dst in all cases.
  64. size_t GetStringValue(char *dst, size_t dst_len) const;
  65. protected:
  66. friend class SBLaunchInfo;
  67. friend class SBTraceOptions;
  68. friend class SBDebugger;
  69. friend class SBTarget;
  70. friend class SBProcess;
  71. friend class SBThread;
  72. friend class SBThreadPlan;
  73. friend class SBBreakpoint;
  74. friend class SBBreakpointLocation;
  75. friend class SBBreakpointName;
  76. StructuredDataImplUP m_impl_up;
  77. };
  78. } // namespace lldb
  79. #endif // LLDB_API_SBSTRUCTUREDDATA_H