aboutsummaryrefslogtreecommitdiff
path: root/include/lldb/Core/DataBuffer.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/lldb/Core/DataBuffer.h')
-rw-r--r--include/lldb/Core/DataBuffer.h89
1 files changed, 46 insertions, 43 deletions
diff --git a/include/lldb/Core/DataBuffer.h b/include/lldb/Core/DataBuffer.h
index da4934457233..ffa71c06be80 100644
--- a/include/lldb/Core/DataBuffer.h
+++ b/include/lldb/Core/DataBuffer.h
@@ -16,6 +16,8 @@
#include "lldb/lldb-types.h"
+#include "llvm/ADT/ArrayRef.h"
+
namespace lldb_private {
//----------------------------------------------------------------------
@@ -43,54 +45,55 @@ namespace lldb_private {
/// data on demand with some extra function calls to load the data
/// before it gets accessed.
//----------------------------------------------------------------------
-class DataBuffer
-{
+class DataBuffer {
public:
- //------------------------------------------------------------------
- /// Destructor
- ///
- /// The destructor is virtual as other classes will inherit from
- /// this class and be downcast to the DataBuffer pure virtual
- /// interface. The virtual destructor ensures that destructing the
- /// base class will destruct the class that inherited from it
- /// correctly.
- //------------------------------------------------------------------
- virtual
- ~DataBuffer()
- {
- }
+ //------------------------------------------------------------------
+ /// Destructor
+ ///
+ /// The destructor is virtual as other classes will inherit from
+ /// this class and be downcast to the DataBuffer pure virtual
+ /// interface. The virtual destructor ensures that destructing the
+ /// base class will destruct the class that inherited from it
+ /// correctly.
+ //------------------------------------------------------------------
+ virtual ~DataBuffer() {}
+
+ //------------------------------------------------------------------
+ /// Get a pointer to the data.
+ ///
+ /// @return
+ /// A pointer to the bytes owned by this object, or NULL if the
+ /// object contains no bytes.
+ //------------------------------------------------------------------
+ virtual uint8_t *GetBytes() = 0;
+
+ //------------------------------------------------------------------
+ /// Get a const pointer to the data.
+ ///
+ /// @return
+ /// A const pointer to the bytes owned by this object, or NULL
+ /// if the object contains no bytes.
+ //------------------------------------------------------------------
+ virtual const uint8_t *GetBytes() const = 0;
- //------------------------------------------------------------------
- /// Get a pointer to the data.
- ///
- /// @return
- /// A pointer to the bytes owned by this object, or NULL if the
- /// object contains no bytes.
- //------------------------------------------------------------------
- virtual uint8_t *
- GetBytes () = 0;
+ //------------------------------------------------------------------
+ /// Get the number of bytes in the data buffer.
+ ///
+ /// @return
+ /// The number of bytes this object currently contains.
+ //------------------------------------------------------------------
+ virtual lldb::offset_t GetByteSize() const = 0;
- //------------------------------------------------------------------
- /// Get a const pointer to the data.
- ///
- /// @return
- /// A const pointer to the bytes owned by this object, or NULL
- /// if the object contains no bytes.
- //------------------------------------------------------------------
- virtual const uint8_t *
- GetBytes () const = 0;
+ llvm::ArrayRef<uint8_t> GetData() const {
+ return llvm::ArrayRef<uint8_t>(GetBytes(), GetByteSize());
+ }
- //------------------------------------------------------------------
- /// Get the number of bytes in the data buffer.
- ///
- /// @return
- /// The number of bytes this object currently contains.
- //------------------------------------------------------------------
- virtual lldb::offset_t
- GetByteSize() const = 0;
+ llvm::MutableArrayRef<uint8_t> GetData() {
+ return llvm::MutableArrayRef<uint8_t>(GetBytes(), GetByteSize());
+ }
};
} // namespace lldb_private
-#endif /// #if defined(__cplusplus)
-#endif /// lldb_DataBuffer_h_
+#endif /// #if defined(__cplusplus)
+#endif /// lldb_DataBuffer_h_