SBStream.h revision 7dd5c51fbab8384b18f20ecc125f9a1bb3c9bcb2
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
17namespace lldb {
18
19class SBStream
20{
21public:
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 transfered to this object, close the file.
55    // If the stream is backed by a local cache, clear this cache.
56    void
57    Clear ();
58
59protected:
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 SBEvent;
69    friend class SBFileSpec;
70    friend class SBFileSpecList;
71    friend class SBFrame;
72    friend class SBFunction;
73    friend class SBInstruction;
74    friend class SBInstructionList;
75    friend class SBLineEntry;
76    friend class SBModule;
77    friend class SBProcess;
78    friend class SBSection;
79    friend class SBSourceManager;
80    friend class SBSymbol;
81    friend class SBSymbolContext;
82    friend class SBSymbolContextList;
83    friend class SBTarget;
84    friend class SBThread;
85    friend class SBType;
86    friend class SBTypeMember;
87    friend class SBValue;
88    friend class SBWatchpoint;
89
90    lldb_private::Stream *
91    operator->();
92
93    lldb_private::Stream *
94    get();
95
96    lldb_private::Stream &
97    ref();
98
99private:
100
101    DISALLOW_COPY_AND_ASSIGN (SBStream);
102    std::auto_ptr<lldb_private::Stream> m_opaque_ap;
103    bool m_is_file;
104};
105
106} // namespace lldb
107
108#endif // LLDB_SBStream_h_
109