blob: 8a6a8e57d695df7a74e630d7c1a479ec66c02cd8 [file] [log] [blame]
Johnny Chen5cb6cab2011-07-19 22:41:47 +00001//===-- SWIG Interface for SBStream -----------------------------*- 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#include <stdio.h>
11
12namespace lldb {
13
Johnny Chen1a73d4c2011-07-19 23:24:36 +000014%feature("docstring",
15"Represents a destination for streaming data output to. By default, a string
16stream is created.
17
18For example (from test/source-manager/TestSourceManager.py),
19
20 # Create the filespec for 'main.c'.
21 filespec = lldb.SBFileSpec('main.c', False)
22 source_mgr = self.dbg.GetSourceManager()
23 # Use a string stream as the destination.
24 stream = lldb.SBStream()
25 source_mgr.DisplaySourceLinesWithLineNumbers(filespec,
26 self.line,
27 2, # context before
28 2, # context after
29 '=>', # prefix for current line
30 stream)
31
32 # 2
33 # 3 int main(int argc, char const *argv[]) {
34 # => 4 printf('Hello world.\\n'); // Set break point at this line.
35 # 5 return 0;
36 # 6 }
37 self.expect(stream.GetData(), 'Source code displayed correctly',
38 exe=False,
39 patterns = ['=> %d.*Hello world' % self.line])
40") SBStream;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000041class SBStream
42{
43public:
44
45 SBStream ();
46
47 ~SBStream ();
48
49 bool
50 IsValid() const;
51
Johnny Chen1a73d4c2011-07-19 23:24:36 +000052 %feature("docstring", "
53 //--------------------------------------------------------------------------
54 /// If this stream is not redirected to a file, it will maintain a local
55 /// cache for the stream data which can be accessed using this accessor.
56 //--------------------------------------------------------------------------
57 ") GetData;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000058 const char *
59 GetData ();
60
Johnny Chen1a73d4c2011-07-19 23:24:36 +000061 %feature("docstring", "
62 //--------------------------------------------------------------------------
63 /// If this stream is not redirected to a file, it will maintain a local
64 /// cache for the stream output whose length can be accessed using this
65 /// accessor.
66 //--------------------------------------------------------------------------
67 ") GetSize;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000068 size_t
69 GetSize();
70
71 void
72 Printf (const char *format, ...);
73
74 void
75 RedirectToFile (const char *path, bool append);
76
77 void
78 RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership);
79
80 void
81 RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
82
Johnny Chen1a73d4c2011-07-19 23:24:36 +000083 %feature("docstring", "
84 //--------------------------------------------------------------------------
85 /// If the stream is redirected to a file, forget about the file and if
86 /// ownership of the file was transfered to this object, close the file.
87 /// If the stream is backed by a local cache, clear this cache.
88 //--------------------------------------------------------------------------
89 ") Clear;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000090 void
91 Clear ();
92};
93
94} // namespace lldb