LLDB API Documentation

SBStream.h
Go to the documentation of this file.
1 //===-- SBStream.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_SBStream_h_
11 #define LLDB_SBStream_h_
12 
13 #include <stdio.h>
14 
15 #include "lldb/API/SBDefines.h"
16 
17 namespace lldb {
18 
19 class LLDB_API SBStream {
20 public:
21  SBStream();
22 
23  SBStream(SBStream &&rhs);
24 
25  ~SBStream();
26 
27  bool IsValid() const;
28 
29  // If this stream is not redirected to a file, it will maintain a local
30  // cache for the stream data which can be accessed using this accessor.
31  const char *GetData();
32 
33  // If this stream is not redirected to a file, it will maintain a local
34  // cache for the stream output whose length can be accessed using this
35  // 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.
48  // If 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 SBCommandReturnObject;
57  friend class SBCompileUnit;
58  friend class SBData;
59  friend class SBDebugger;
60  friend class SBDeclaration;
61  friend class SBEvent;
62  friend class SBFileSpec;
63  friend class SBFileSpecList;
64  friend class SBFrame;
65  friend class SBFunction;
66  friend class SBInstruction;
67  friend class SBInstructionList;
68  friend class SBLineEntry;
69  friend class SBMemoryRegionInfo;
70  friend class SBModule;
71  friend class SBModuleSpec;
72  friend class SBModuleSpecList;
73  friend class SBProcess;
74  friend class SBSection;
75  friend class SBSourceManager;
76  friend class SBStructuredData;
77  friend class SBSymbol;
78  friend class SBSymbolContext;
79  friend class SBSymbolContextList;
80  friend class SBTarget;
81  friend class SBThread;
82  friend class SBThreadPlan;
83  friend class SBType;
84  friend class SBTypeEnumMember;
85  friend class SBTypeMemberFunction;
86  friend class SBTypeMember;
87  friend class SBValue;
88  friend class SBWatchpoint;
89 
90  lldb_private::Stream *operator->();
91 
92  lldb_private::Stream *get();
93 
94  lldb_private::Stream &ref();
95 
96 private:
97  DISALLOW_COPY_AND_ASSIGN(SBStream);
98  std::unique_ptr<lldb_private::Stream> m_opaque_ap;
99  bool m_is_file;
100 };
101 
102 } // namespace lldb
103 
104 #endif // LLDB_SBStream_h_
class LLDB_API SBStream
Definition: SBDefines.h:72