LLDB mainline
SBStream.h
Go to the documentation of this file.
1//===-- SBStream.h ----------------------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLDB_API_SBSTREAM_H
10#define LLDB_API_SBSTREAM_H
11
12#include <cstdio>
13
14#include "lldb/API/SBDefines.h"
15
16namespace lldb {
17
19public:
20 SBStream();
21
22#ifndef SWIG
23 SBStream(SBStream &&rhs);
24#endif
25
27
28 explicit operator bool() const;
29
30 bool IsValid() const;
31
32 // If this stream is not redirected to a file, it will maintain a local cache
33 // for the stream data which can be accessed using this accessor.
34 const char *GetData();
35
36 // If this stream is not redirected to a file, it will maintain a local cache
37 // for the stream output whose length can be accessed using this accessor.
38 size_t GetSize();
39
40#ifndef SWIG
41 __attribute__((format(printf, 2, 3))) void Printf(const char *format, ...);
42#endif
43
44 void Print(const char *str);
45
46 void RedirectToFile(const char *path, bool append);
47
48 void RedirectToFile(lldb::SBFile file);
49
50 void RedirectToFile(lldb::FileSP file);
51
52#ifndef SWIG
53 void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
54#endif
55
56 void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);
57
58 // If the stream is redirected to a file, forget about the file and if
59 // ownership of the file was transferred to this object, close the file. If
60 // the stream is backed by a local cache, clear this cache.
61 void Clear();
62
63protected:
64 friend class SBAddress;
65 friend class SBBlock;
66 friend class SBBreakpoint;
68 friend class SBBreakpointName;
70 friend class SBCompileUnit;
71 friend class SBData;
72 friend class SBDebugger;
73 friend class SBDeclaration;
74 friend class SBEvent;
75 friend class SBFileSpec;
76 friend class SBFileSpecList;
77 friend class SBFrame;
78 friend class SBFunction;
79 friend class SBInstruction;
80 friend class SBInstructionList;
81 friend class SBLaunchInfo;
82 friend class SBLineEntry;
83 friend class SBMemoryRegionInfo;
84 friend class SBModule;
85 friend class SBModuleSpec;
86 friend class SBModuleSpecList;
87 friend class SBProcess;
88 friend class SBSection;
89 friend class SBSourceManager;
90 friend class SBStructuredData;
91 friend class SBSymbol;
92 friend class SBSymbolContext;
93 friend class SBSymbolContextList;
94 friend class SBTarget;
95 friend class SBThread;
96 friend class SBThreadPlan;
97 friend class SBType;
98 friend class SBTypeEnumMember;
100 friend class SBTypeMember;
101 friend class SBValue;
102 friend class SBWatchpoint;
103
104 lldb_private::Stream *operator->();
105
107
109
110private:
111 SBStream(const SBStream &) = delete;
112 const SBStream &operator=(const SBStream &) = delete;
113 std::unique_ptr<lldb_private::Stream> m_opaque_up;
114 bool m_is_file = false;
115};
116
117} // namespace lldb
118
119#endif // LLDB_API_SBSTREAM_H
#define LLDB_API
Definition: SBDefines.h:28
SBStream(const SBStream &)=delete
__attribute__((format(printf, 2, 3))) void Printf(const char *format
const SBStream & operator=(const SBStream &)=delete
std::unique_ptr< lldb_private::Stream > m_opaque_up
Definition: SBStream.h:113
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Definition: SBAddress.h:15
std::shared_ptr< lldb_private::File > FileSP
Definition: lldb-forward.h:345