]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/include/lldb/Core/DataBuffer.h
Update LLDB snapshot to upstream r225923 (git 2b588ecd)
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / include / lldb / Core / DataBuffer.h
1 //===-- DataBuffer.h --------------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #ifndef liblldb_DataBuffer_h_
11 #define liblldb_DataBuffer_h_
12 #if defined(__cplusplus)
13
14 #include <stdint.h>
15 #include <string.h>
16
17 #include "lldb/lldb-types.h"
18
19 namespace lldb_private {
20
21 //----------------------------------------------------------------------
22 /// @class DataBuffer DataBuffer.h "lldb/Core/DataBuffer.h"
23 /// @brief A pure virtual protocol class for abstracted data buffers.
24 ///
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.
31 ///
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.
35 ///
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
39 /// one common way.
40 ///
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 //----------------------------------------------------------------------
46 class DataBuffer
47 {
48 public:
49     //------------------------------------------------------------------
50     /// Destructor
51     ///
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
56     /// correctly.
57     //------------------------------------------------------------------
58     virtual
59     ~DataBuffer()
60     {
61     }
62
63     //------------------------------------------------------------------
64     /// Get a pointer to the data.
65     ///
66     /// @return
67     ///     A pointer to the bytes owned by this object, or NULL if the
68     ///     object contains no bytes.
69     //------------------------------------------------------------------
70     virtual uint8_t *
71     GetBytes () = 0;
72
73     //------------------------------------------------------------------
74     /// Get a const pointer to the data.
75     ///
76     /// @return
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;
82
83     //------------------------------------------------------------------
84     /// Get the number of bytes in the data buffer.
85     ///
86     /// @return
87     ///     The number of bytes this object currently contains.
88     //------------------------------------------------------------------
89     virtual lldb::offset_t
90     GetByteSize() const = 0;
91 };
92
93 } // namespace lldb_private
94
95 #endif  /// #if defined(__cplusplus)
96 #endif  /// lldb_DataBuffer_h_