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 SBStream
20 {
21 public:
22 
23  SBStream ();
24 
25  ~SBStream ();
26 
27  bool
28  IsValid() const;
29 
30  // If this stream is not redirected to a file, it will maintain a local
31  // cache for the stream data which can be accessed using this accessor.
32  const char *
33  GetData ();
34 
35  // If this stream is not redirected to a file, it will maintain a local
36  // cache for the stream output whose length can be accessed using this
37  // accessor.
38  size_t
39  GetSize();
40 
41  void
42  Printf (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
43 
44  void
45  RedirectToFile (const char *path, bool append);
46 
47  void
48  RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership);
49 
50  void
51  RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
52 
53  // If the stream is redirected to a file, forget about the file and if
54  // ownership of the file was transferred to this object, close the file.
55  // If the stream is backed by a local cache, clear this cache.
56  void
57  Clear ();
58 
59 protected:
60  friend class SBAddress;
61  friend class SBBlock;
62  friend class SBBreakpoint;
63  friend class SBBreakpointLocation;
64  friend class SBCommandReturnObject;
65  friend class SBCompileUnit;
66  friend class SBData;
67  friend class SBDebugger;
68  friend class SBDeclaration;
69  friend class SBEvent;
70  friend class SBFileSpec;
71  friend class SBFileSpecList;
72  friend class SBFrame;
73  friend class SBFunction;
74  friend class SBInstruction;
75  friend class SBInstructionList;
76  friend class SBLineEntry;
77  friend class SBModule;
78  friend class SBModuleSpec;
79  friend class SBModuleSpecList;
80  friend class SBProcess;
81  friend class SBSection;
82  friend class SBSourceManager;
83  friend class SBSymbol;
84  friend class SBSymbolContext;
85  friend class SBSymbolContextList;
86  friend class SBTarget;
87  friend class SBThread;
88  friend class SBType;
89  friend class SBTypeMember;
90  friend class SBValue;
91  friend class SBWatchpoint;
92 
93  lldb_private::Stream *
94  operator->();
95 
96  lldb_private::Stream *
97  get();
98 
99  lldb_private::Stream &
100  ref();
101 
102 private:
103 
104  DISALLOW_COPY_AND_ASSIGN (SBStream);
105  std::unique_ptr<lldb_private::Stream> m_opaque_ap;
106  bool m_is_file;
107 };
108 
109 } // namespace lldb
110 
111 #endif // LLDB_SBStream_h_