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_SBStream_h_
10 #define LLDB_SBStream_h_
11 
12 #include <stdio.h>
13 
14 #include "lldb/API/SBDefines.h"
15 
16 namespace lldb {
17 
19 public:
20  SBStream();
21 
22  SBStream(SBStream &&rhs);
23 
24  ~SBStream();
25 
26  explicit operator bool() const;
27 
28  bool IsValid() const;
29 
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();
33 
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.
36  size_t GetSize();
37 
38  void Printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
39 
40  void RedirectToFile(const char *path, bool append);
41 
42  void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
43 
44  void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);
45 
46  // If the stream is redirected to a file, forget about the file and if
47  // ownership of the file was transferred to this object, close the file. If
48  // the stream is backed by a local cache, clear this cache.
49  void Clear();
50 
51 protected:
52  friend class SBAddress;
53  friend class SBBlock;
54  friend class SBBreakpoint;
55  friend class SBBreakpointLocation;
56  friend class SBBreakpointName;
57  friend class SBCommandReturnObject;
58  friend class SBCompileUnit;
59  friend class SBData;
60  friend class SBDebugger;
61  friend class SBDeclaration;
62  friend class SBEvent;
63  friend class SBFileSpec;
64  friend class SBFileSpecList;
65  friend class SBFrame;
66  friend class SBFunction;
67  friend class SBInstruction;
68  friend class SBInstructionList;
69  friend class SBLineEntry;
70  friend class SBMemoryRegionInfo;
71  friend class SBModule;
72  friend class SBModuleSpec;
73  friend class SBModuleSpecList;
74  friend class SBProcess;
75  friend class SBSection;
76  friend class SBSourceManager;
77  friend class SBStructuredData;
78  friend class SBSymbol;
79  friend class SBSymbolContext;
80  friend class SBSymbolContextList;
81  friend class SBTarget;
82  friend class SBThread;
83  friend class SBThreadPlan;
84  friend class SBType;
85  friend class SBTypeEnumMember;
86  friend class SBTypeMemberFunction;
87  friend class SBTypeMember;
88  friend class SBValue;
89  friend class SBWatchpoint;
90 
91  lldb_private::Stream *operator->();
92 
93  lldb_private::Stream *get();
94 
95  lldb_private::Stream &ref();
96 
97 private:
98  DISALLOW_COPY_AND_ASSIGN(SBStream);
99  std::unique_ptr<lldb_private::Stream> m_opaque_up;
100  bool m_is_file;
101 };
102 
103 } // namespace lldb
104 
105 #endif // LLDB_SBStream_h_
class LLDB_API SBStream
Definition: SBDefines.h:66
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
#define LLDB_API
Definition: lldb-defines.h:23
Definition: SBAddress.h:15