SBData.h revision 9f074f0e030a74a3efd716a476b436f2d32bdf74
1//===-- SBData.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 LLDB_SBData_h_
11#define LLDB_SBData_h_
12
13#include "lldb/API/SBDefines.h"
14
15namespace lldb {
16
17class SBData
18{
19public:
20
21    SBData ();
22
23    SBData (const SBData &rhs);
24
25#ifndef SWIG
26    const SBData &
27    operator = (const SBData &rhs);
28#endif
29
30    ~SBData ();
31
32    uint8_t
33    GetAddressByteSize ();
34
35    void
36    Clear ();
37
38    bool
39    IsValid();
40
41    size_t
42    GetByteSize ();
43
44    lldb::ByteOrder
45    GetByteOrder();
46
47    float
48    GetFloat (lldb::SBError& error, uint32_t offset);
49
50    double
51    GetDouble (lldb::SBError& error, uint32_t offset);
52
53    long double
54    GetLongDouble (lldb::SBError& error, uint32_t offset);
55
56    lldb::addr_t
57    GetAddress (lldb::SBError& error, uint32_t offset);
58
59    uint8_t
60    GetUnsignedInt8 (lldb::SBError& error, uint32_t offset);
61
62    uint16_t
63    GetUnsignedInt16 (lldb::SBError& error, uint32_t offset);
64
65    uint32_t
66    GetUnsignedInt32 (lldb::SBError& error, uint32_t offset);
67
68    uint64_t
69    GetUnsignedInt64 (lldb::SBError& error, uint32_t offset);
70
71    int8_t
72    GetSignedInt8 (lldb::SBError& error, uint32_t offset);
73
74    int16_t
75    GetSignedInt16 (lldb::SBError& error, uint32_t offset);
76
77    int32_t
78    GetSignedInt32 (lldb::SBError& error, uint32_t offset);
79
80    int64_t
81    GetSignedInt64 (lldb::SBError& error, uint32_t offset);
82
83    const char*
84    GetString (lldb::SBError& error, uint32_t offset);
85
86    size_t
87    ReadRawData (lldb::SBError& error,
88                 uint32_t offset,
89                 void *buf,
90                 size_t size);
91
92    bool
93    GetDescription (lldb::SBStream &description, lldb::addr_t base_addr = LLDB_INVALID_ADDRESS);
94
95    // it would be nice to have SetData(SBError, const void*, size_t) when endianness and address size can be
96    // inferred from the existing DataExtractor, but having two SetData() signatures triggers a SWIG bug where
97    // the typemap isn't applied before resolving the overload, and thus the right function never gets called
98    void
99    SetData(lldb::SBError& error, const void *buf, size_t size, lldb::ByteOrder endian, uint8_t addr_size);
100
101    // see SetData() for why we don't have Append(const void* buf, size_t size)
102    bool
103    Append(const SBData& rhs);
104
105protected:
106
107#ifndef SWIG
108    // Mimic shared pointer...
109    lldb_private::DataExtractor *
110    get() const;
111
112    lldb_private::DataExtractor *
113    operator->() const;
114
115    lldb::DataExtractorSP &
116    operator*();
117
118    const lldb::DataExtractorSP &
119    operator*() const;
120#endif
121
122    SBData (const lldb::DataExtractorSP &data_sp);
123
124    void
125    SetOpaque (const lldb::DataExtractorSP &data_sp);
126
127private:
128    friend class SBInstruction;
129    friend class SBProcess;
130    friend class SBSection;
131    friend class SBValue;
132
133    lldb::DataExtractorSP  m_opaque_sp;
134};
135
136
137} // namespace lldb
138
139#endif // LLDB_SBData_h_
140