File: SBStream.h

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (127 lines) | stat: -rw-r--r-- 3,367 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//===-- SBStream.h ----------------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_API_SBSTREAM_H
#define LLDB_API_SBSTREAM_H

#include <cstdio>

#include "lldb/API/SBDefines.h"

namespace lldb_private {
class ScriptInterpreter;
} // namespace lldb_private

namespace lldb {

class LLDB_API SBStream {
public:
  SBStream();

#ifndef SWIG
  SBStream(SBStream &&rhs);
#endif

  ~SBStream();

  explicit operator bool() const;

  bool IsValid() const;

  // If this stream is not redirected to a file, it will maintain a local cache
  // for the stream data which can be accessed using this accessor.
  const char *GetData();

  // If this stream is not redirected to a file, it will maintain a local cache
  // for the stream output whose length can be accessed using this accessor.
  size_t GetSize();

#ifndef SWIG
  __attribute__((format(printf, 2, 3))) void Printf(const char *format, ...);
#endif

  void Print(const char *str);

  void RedirectToFile(const char *path, bool append);

  void RedirectToFile(lldb::SBFile file);

  void RedirectToFile(lldb::FileSP file);

#ifndef SWIG
  void RedirectToFileHandle(FILE *fh, bool transfer_fh_ownership);
#endif

  void RedirectToFileDescriptor(int fd, bool transfer_fh_ownership);

  // If the stream is redirected to a file, forget about the file and if
  // ownership of the file was transferred to this object, close the file. If
  // the stream is backed by a local cache, clear this cache.
  void Clear();

protected:
  friend class SBAddress;
  friend class SBAddressRange;
  friend class SBAddressRangeList;
  friend class SBBlock;
  friend class SBBreakpoint;
  friend class SBBreakpointLocation;
  friend class SBBreakpointName;
  friend class SBCommandReturnObject;
  friend class SBCompileUnit;
  friend class SBData;
  friend class SBDebugger;
  friend class SBDeclaration;
  friend class SBEvent;
  friend class SBFileSpec;
  friend class SBFileSpecList;
  friend class SBFrame;
  friend class SBFunction;
  friend class SBInstruction;
  friend class SBInstructionList;
  friend class SBLaunchInfo;
  friend class SBLineEntry;
  friend class SBMemoryRegionInfo;
  friend class SBModule;
  friend class SBModuleSpec;
  friend class SBModuleSpecList;
  friend class SBProcess;
  friend class SBSection;
  friend class SBSourceManager;
  friend class SBStructuredData;
  friend class SBSymbol;
  friend class SBSymbolContext;
  friend class SBSymbolContextList;
  friend class SBTarget;
  friend class SBThread;
  friend class SBThreadPlan;
  friend class SBType;
  friend class SBTypeEnumMember;
  friend class SBTypeMemberFunction;
  friend class SBTypeMember;
  friend class SBValue;
  friend class SBWatchpoint;

  friend class lldb_private::ScriptInterpreter;

  lldb_private::Stream *operator->();

  lldb_private::Stream *get();

  lldb_private::Stream &ref();

private:
  SBStream(const SBStream &) = delete;
  const SBStream &operator=(const SBStream &) = delete;
  std::unique_ptr<lldb_private::Stream> m_opaque_up;
  bool m_is_file = false;
};

} // namespace lldb

#endif // LLDB_API_SBSTREAM_H