File indexing completed on 2026-05-10 08:42:56
0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef LLDB_UTILITY_BATON_H
0010 #define LLDB_UTILITY_BATON_H
0011
0012 #include "lldb/lldb-enumerations.h"
0013 #include "lldb/lldb-public.h"
0014
0015 #include "llvm/Support/raw_ostream.h"
0016
0017 #include <memory>
0018
0019 namespace lldb_private {
0020 class Stream;
0021 }
0022
0023 namespace lldb_private {
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 class Baton {
0036 public:
0037 Baton() = default;
0038 virtual ~Baton() = default;
0039
0040 virtual void *data() = 0;
0041
0042 virtual void GetDescription(llvm::raw_ostream &s,
0043 lldb::DescriptionLevel level,
0044 unsigned indentation) const = 0;
0045 };
0046
0047 class UntypedBaton : public Baton {
0048 public:
0049 UntypedBaton(void *Data) : m_data(Data) {}
0050 ~UntypedBaton() override {
0051
0052
0053 }
0054
0055 void *data() override { return m_data; }
0056 void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level,
0057 unsigned indentation) const override;
0058
0059 void *m_data;
0060 };
0061
0062 template <typename T> class TypedBaton : public Baton {
0063 public:
0064 explicit TypedBaton(std::unique_ptr<T> Item) : Item(std::move(Item)) {}
0065
0066 T *getItem() { return Item.get(); }
0067 const T *getItem() const { return Item.get(); }
0068
0069 void *data() override { return Item.get(); }
0070 void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level,
0071 unsigned indentation) const override {}
0072
0073 protected:
0074 std::unique_ptr<T> Item;
0075 };
0076
0077 }
0078
0079 #endif