1 //===-- DataBuffer.h --------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_DataBuffer_h_
11 #define liblldb_DataBuffer_h_
12 #if defined(__cplusplus)
17 #include "lldb/lldb-types.h"
19 namespace lldb_private {
21 //----------------------------------------------------------------------
22 /// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h"
23 /// @brief A pure virtual protocol class for abstracted data buffers.
25 /// DataBuffer is an abstract class that gets packaged into a shared pointer
26 /// that can use to implement various ways to store data (on the heap,
27 /// memory mapped, cached inferior memory). It gets used by DataExtractor
28 /// so many DataExtractor objects can share the same data and sub-ranges
29 /// of that shared data, and the last object that contains a reference
30 /// to the shared data will free it.
32 /// Subclasses can implement as many different constructors or member
33 /// functions that allow data to be stored in the object's buffer prior
34 /// to handing the shared data to clients that use these buffers.
36 /// All subclasses must override all of the pure virtual functions as
37 /// they are used by clients to access the data. Having a common
38 /// interface allows different ways of storing data, yet using it in
41 /// This class currently expects all data to be available without any
42 /// extra calls being made, but we can modify it to optionally get
43 /// data on demand with some extra function calls to load the data
44 /// before it gets accessed.
45 //----------------------------------------------------------------------
49 //------------------------------------------------------------------
52 /// The destructor is virtual as other classes will inherit from
53 /// this class and be downcast to the DataBuffer pure virtual
54 /// interface. The virtual destructor ensures that destructing the
55 /// base class will destruct the class that inherited from it
57 //------------------------------------------------------------------
63 //------------------------------------------------------------------
64 /// Get a pointer to the data.
67 /// A pointer to the bytes owned by this object, or NULL if the
68 /// object contains no bytes.
69 //------------------------------------------------------------------
73 //------------------------------------------------------------------
74 /// Get a const pointer to the data.
77 /// A const pointer to the bytes owned by this object, or NULL
78 /// if the object contains no bytes.
79 //------------------------------------------------------------------
80 virtual const uint8_t *
81 GetBytes () const = 0;
83 //------------------------------------------------------------------
84 /// Get the number of bytes in the data buffer.
87 /// The number of bytes this object currently contains.
88 //------------------------------------------------------------------
89 virtual lldb::offset_t
90 GetByteSize() const = 0;
93 } // namespace lldb_private
95 #endif /// #if defined(__cplusplus)
96 #endif /// lldb_DataBuffer_h_