1 //===-- SBStream.h ----------------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SBStream_h_
10 #define LLDB_SBStream_h_
14 #include "lldb/API/SBDefines.h"
18 class LLDB_API SBStream {
22 SBStream(SBStream &&rhs);
26 explicit operator bool() const;
30 // If this stream is not redirected to a file, it will maintain a local cache
31 // for the stream data which can be accessed using this accessor.
32 const char *GetData();
34 // If this stream is not redirected to a file, it will maintain a local cache
35 // for the stream output whose length can be accessed using this accessor.
38 void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
40 void RedirectToFile(const char *path, bool append);
42 void RedirectToFile(lldb::SBFile file);
44 void RedirectToFile(lldb::FileSP file);
46 void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
48 void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);
50 // If the stream is redirected to a file, forget about the file and if
51 // ownership of the file was transferred to this object, close the file. If
52 // the stream is backed by a local cache, clear this cache.
56 friend class SBAddress;
58 friend class SBBreakpoint;
59 friend class SBBreakpointLocation;
60 friend class SBBreakpointName;
61 friend class SBCommandReturnObject;
62 friend class SBCompileUnit;
64 friend class SBDebugger;
65 friend class SBDeclaration;
67 friend class SBFileSpec;
68 friend class SBFileSpecList;
70 friend class SBFunction;
71 friend class SBInstruction;
72 friend class SBInstructionList;
73 friend class SBLineEntry;
74 friend class SBMemoryRegionInfo;
75 friend class SBModule;
76 friend class SBModuleSpec;
77 friend class SBModuleSpecList;
78 friend class SBProcess;
79 friend class SBSection;
80 friend class SBSourceManager;
81 friend class SBStructuredData;
82 friend class SBSymbol;
83 friend class SBSymbolContext;
84 friend class SBSymbolContextList;
85 friend class SBTarget;
86 friend class SBThread;
87 friend class SBThreadPlan;
89 friend class SBTypeEnumMember;
90 friend class SBTypeMemberFunction;
91 friend class SBTypeMember;
93 friend class SBWatchpoint;
95 lldb_private::Stream *operator->();
97 lldb_private::Stream *get();
99 lldb_private::Stream &ref();
102 DISALLOW_COPY_AND_ASSIGN(SBStream);
103 std::unique_ptr<lldb_private::Stream> m_opaque_up;
109 #endif // LLDB_SBStream_h_