blob: 3eca0dcaa1bc5b52119be39c4c187b9fc592bee0 [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
Enrico Granataedc41322012-10-04 23:54:09 +000071 // wrapping the variadic Printf() with a plain Print()
72 // because it is hard to support varargs in SWIG bridgings
73 %extend {
74 void Print (const char* str)
75 {
76 self->Printf(str);
77 }
78 }
79
Johnny Chen5cb6cab2011-07-19 22:41:47 +000080 void
81 RedirectToFile (const char *path, bool append);
82
83 void
84 RedirectToFileHandle (FILE *fh, bool transfer_fh_ownership);
85
86 void
87 RedirectToFileDescriptor (int fd, bool transfer_fh_ownership);
88
Johnny Chen1a73d4c2011-07-19 23:24:36 +000089 %feature("docstring", "
90 //--------------------------------------------------------------------------
91 /// If the stream is redirected to a file, forget about the file and if
92 /// ownership of the file was transfered to this object, close the file.
93 /// If the stream is backed by a local cache, clear this cache.
94 //--------------------------------------------------------------------------
95 ") Clear;
Johnny Chen5cb6cab2011-07-19 22:41:47 +000096 void
97 Clear ();
98};
99
100} // namespace lldb