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 namespace lldb_private {
19 //----------------------------------------------------------------------
20 /// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h"
21 /// @brief A pure virtual protocol class for abstracted data buffers.
23 /// DataBuffer is an abtract class that gets packaged into a shared pointer
24 /// that can use to implement various ways to store data (on the heap,
25 /// memory mapped, cached inferior memory). It gets used by DataExtractor
26 /// so many DataExtractor objects can share the same data and sub-ranges
27 /// of that shared data, and the last object that contains a reference
28 /// to the shared data will free it.
30 /// Subclasses can implement as many different constructors or member
31 /// functions that allow data to be stored in the object's buffer prior
32 /// to handing the shared data to clients that use these buffers.
34 /// All subclasses must override all of the pure virtual functions as
35 /// they are used by clients to access the data. Having a common
36 /// interface allows different ways of storing data, yet using it in
39 /// This class currently expects all data to be available without any
40 /// extra calls being made, but we can modify it to optionally get
41 /// data on demand with some extra function calls to load the data
42 /// before it gets accessed.
43 //----------------------------------------------------------------------
47 //------------------------------------------------------------------
50 /// The destructor is virtual as other classes will inherit from
51 /// this class and be downcast to the DataBuffer pure virtual
52 /// interface. The virtual destructor ensures that destructing the
53 /// base class will destruct the class that inherited from it
55 //------------------------------------------------------------------
61 //------------------------------------------------------------------
62 /// Get a pointer to the data.
65 /// A pointer to the bytes owned by this object, or NULL if the
66 /// object contains no bytes.
67 //------------------------------------------------------------------
71 //------------------------------------------------------------------
72 /// Get a const pointer to the data.
75 /// A const pointer to the bytes owned by this object, or NULL
76 /// if the object contains no bytes.
77 //------------------------------------------------------------------
78 virtual const uint8_t *
79 GetBytes () const = 0;
81 //------------------------------------------------------------------
82 /// Get the number of bytes in the data buffer.
85 /// The number of bytes this object currently contains.
86 //------------------------------------------------------------------
87 virtual lldb::offset_t
88 GetByteSize() const = 0;
91 } // namespace lldb_private
93 #endif /// #if defined(__cplusplus)
94 #endif /// lldb_DataBuffer_h_