1 | //===-- SBCommandReturnObject.h ---------------------------------*- C++ -*-===// |
2 | // |
3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | // See https://llvm.org/LICENSE.txt for license information. |
5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLDB_API_SBCOMMANDRETURNOBJECT_H |
10 | #define LLDB_API_SBCOMMANDRETURNOBJECT_H |
11 | |
12 | #include <cstdio> |
13 | |
14 | #include <memory> |
15 | |
16 | #include "lldb/API/SBDefines.h" |
17 | |
18 | namespace lldb_private { |
19 | class CommandPluginInterfaceImplementation; |
20 | class SBCommandReturnObjectImpl; |
21 | namespace python { |
22 | class SWIGBridge; |
23 | } |
24 | } // namespace lldb_private |
25 | |
26 | namespace lldb { |
27 | |
28 | class LLDB_API SBCommandReturnObject { |
29 | public: |
30 | SBCommandReturnObject(); |
31 | |
32 | // rvalue ctor+assignment are incompatible with Reproducers. |
33 | |
34 | SBCommandReturnObject(const lldb::SBCommandReturnObject &rhs); |
35 | |
36 | ~SBCommandReturnObject(); |
37 | |
38 | lldb::SBCommandReturnObject & |
39 | operator=(const lldb::SBCommandReturnObject &rhs); |
40 | |
41 | explicit operator bool() const; |
42 | |
43 | bool IsValid() const; |
44 | |
45 | const char *GetOutput(); |
46 | |
47 | const char *GetError(); |
48 | |
49 | #ifndef SWIG |
50 | LLDB_DEPRECATED_FIXME("Use PutOutput(SBFile) or PutOutput(FileSP)" , |
51 | "PutOutput(SBFile)" ) |
52 | size_t PutOutput(FILE *fh); |
53 | #endif |
54 | |
55 | size_t PutOutput(SBFile file); |
56 | |
57 | size_t PutOutput(FileSP BORROWED); |
58 | |
59 | size_t GetOutputSize(); |
60 | |
61 | size_t GetErrorSize(); |
62 | |
63 | #ifndef SWIG |
64 | LLDB_DEPRECATED_FIXME("Use PutError(SBFile) or PutError(FileSP)" , |
65 | "PutError(SBFile)" ) |
66 | size_t PutError(FILE *fh); |
67 | #endif |
68 | |
69 | size_t PutError(SBFile file); |
70 | |
71 | size_t PutError(FileSP BORROWED); |
72 | |
73 | void Clear(); |
74 | |
75 | lldb::ReturnStatus GetStatus(); |
76 | |
77 | void SetStatus(lldb::ReturnStatus status); |
78 | |
79 | bool Succeeded(); |
80 | |
81 | bool HasResult(); |
82 | |
83 | void AppendMessage(const char *message); |
84 | |
85 | void AppendWarning(const char *message); |
86 | |
87 | bool GetDescription(lldb::SBStream &description); |
88 | |
89 | #ifndef SWIG |
90 | LLDB_DEPRECATED_FIXME( |
91 | "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)" , |
92 | "SetImmediateOutputFile(SBFile)" ) |
93 | void SetImmediateOutputFile(FILE *fh); |
94 | |
95 | LLDB_DEPRECATED_FIXME( |
96 | "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)" , |
97 | "SetImmediateErrorFile(SBFile)" ) |
98 | void SetImmediateErrorFile(FILE *fh); |
99 | |
100 | LLDB_DEPRECATED_FIXME( |
101 | "Use SetImmediateOutputFile(SBFile) or SetImmediateOutputFile(FileSP)" , |
102 | "SetImmediateOutputFile(SBFile)" ) |
103 | void SetImmediateOutputFile(FILE *fh, bool transfer_ownership); |
104 | |
105 | LLDB_DEPRECATED_FIXME( |
106 | "Use SetImmediateErrorFile(SBFile) or SetImmediateErrorFile(FileSP)" , |
107 | "SetImmediateErrorFile(SBFile)" ) |
108 | void SetImmediateErrorFile(FILE *fh, bool transfer_ownership); |
109 | #endif |
110 | |
111 | void SetImmediateOutputFile(SBFile file); |
112 | |
113 | void SetImmediateErrorFile(SBFile file); |
114 | |
115 | void SetImmediateOutputFile(FileSP BORROWED); |
116 | |
117 | void SetImmediateErrorFile(FileSP BORROWED); |
118 | |
119 | void PutCString(const char *string, int len = -1); |
120 | |
121 | #ifndef SWIG |
122 | __attribute__((format(printf, 2, 3))) size_t Printf(const char *format, ...); |
123 | #endif |
124 | |
125 | const char *GetOutput(bool only_if_no_immediate); |
126 | |
127 | const char *GetError(bool only_if_no_immediate); |
128 | |
129 | void SetError(lldb::SBError &error, |
130 | const char *fallback_error_cstr = nullptr); |
131 | |
132 | void SetError(const char *error_cstr); |
133 | |
134 | protected: |
135 | friend class SBCommandInterpreter; |
136 | friend class SBOptions; |
137 | |
138 | friend class lldb_private::CommandPluginInterfaceImplementation; |
139 | friend class lldb_private::python::SWIGBridge; |
140 | |
141 | SBCommandReturnObject(lldb_private::CommandReturnObject &ref); |
142 | |
143 | lldb_private::CommandReturnObject *operator->() const; |
144 | |
145 | lldb_private::CommandReturnObject *get() const; |
146 | |
147 | lldb_private::CommandReturnObject &operator*() const; |
148 | |
149 | private: |
150 | lldb_private::CommandReturnObject &ref() const; |
151 | |
152 | std::unique_ptr<lldb_private::SBCommandReturnObjectImpl> m_opaque_up; |
153 | }; |
154 | |
155 | } // namespace lldb |
156 | |
157 | #endif // LLDB_API_SBCOMMANDRETURNOBJECT_H |
158 | |