1 //===--- DataBufferLLVM.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 LLDB_UTILITY_DATABUFFERLLVM_H
10 #define LLDB_UTILITY_DATABUFFERLLVM_H
11 
12 #include "lldb/Utility/DataBuffer.h"
13 #include "lldb/lldb-types.h"
14 
15 #include <memory>
16 #include <stdint.h>
17 
18 namespace llvm {
19 class WritableMemoryBuffer;
20 class Twine;
21 }
22 
23 namespace lldb_private {
24 
25 class FileSystem;
26 class DataBufferLLVM : public DataBuffer {
27 public:
28   ~DataBufferLLVM() override;
29 
30   uint8_t *GetBytes() override;
31   const uint8_t *GetBytes() const override;
32   lldb::offset_t GetByteSize() const override;
33 
34   char *GetChars() { return reinterpret_cast<char *>(GetBytes()); }
35 
36 private:
37   friend FileSystem;
38   /// Construct a DataBufferLLVM from \p Buffer.  \p Buffer must be a valid
39   /// pointer.
40   explicit DataBufferLLVM(std::unique_ptr<llvm::WritableMemoryBuffer> Buffer);
41 
42   std::unique_ptr<llvm::WritableMemoryBuffer> Buffer;
43 };
44 }
45 
46 #endif
47