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 cache 30 // 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 cache 34 // for the stream output whose length can be accessed using this accessor. 35 size_t GetSize(); 36 37 void Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); 38 39 void RedirectToFile(const char *path, bool append); 40 41 void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership); 42 43 void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership); 44 45 // If the stream is redirected to a file, forget about the file and if 46 // ownership of the file was transferred to this object, close the file. If 47 // the stream is backed by a local cache, clear this cache. 48 void Clear(); 49 50 protected: 51 friend class SBAddress; 52 friend class SBBlock; 53 friend class SBBreakpoint; 54 friend class SBBreakpointLocation; 55 friend class SBBreakpointName; 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_ 105