1//===-- SBCommandReturnObject.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_SBCommandReturnObject_h_
11#define LLDB_SBCommandReturnObject_h_
12
13#include <stdio.h>
14
15#include "lldb/API/SBDefines.h"
16
17namespace lldb {
18
19class SBCommandReturnObject
20{
21public:
22
23    SBCommandReturnObject ();
24
25    SBCommandReturnObject (const lldb::SBCommandReturnObject &rhs);
26
27    const lldb::SBCommandReturnObject &
28    operator = (const lldb::SBCommandReturnObject &rhs);
29
30
31    SBCommandReturnObject (lldb_private::CommandReturnObject *ptr);
32
33    lldb_private::CommandReturnObject *
34    Release ();
35
36    ~SBCommandReturnObject ();
37
38    bool
39    IsValid() const;
40
41    const char *
42    GetOutput ();
43
44    const char *
45    GetError ();
46
47    size_t
48    PutOutput (FILE *fh);
49
50    size_t
51    GetOutputSize ();
52
53    size_t
54    GetErrorSize ();
55
56    size_t
57    PutError (FILE *fh);
58
59    void
60    Clear();
61
62    lldb::ReturnStatus
63    GetStatus();
64
65    void
66    SetStatus (lldb::ReturnStatus status);
67
68    bool
69    Succeeded ();
70
71    bool
72    HasResult ();
73
74    void
75    AppendMessage (const char *message);
76
77    void
78    AppendWarning (const char *message);
79
80    bool
81    GetDescription (lldb::SBStream &description);
82
83    void
84    SetImmediateOutputFile (FILE *fh);
85
86    void
87    SetImmediateErrorFile (FILE *fh);
88
89    void
90    PutCString(const char* string, int len = -1);
91
92    size_t
93    Printf(const char* format, ...)  __attribute__ ((format (printf, 2, 3)));
94
95    const char *
96    GetOutput (bool only_if_no_immediate);
97
98    const char *
99    GetError (bool only_if_no_immediate);
100
101    void
102    SetError (lldb::SBError &error,
103              const char *fallback_error_cstr = NULL);
104
105    void
106    SetError (const char* error_cstr);
107
108protected:
109    friend class SBCommandInterpreter;
110    friend class SBOptions;
111
112    lldb_private::CommandReturnObject *
113    operator->() const;
114
115    lldb_private::CommandReturnObject *
116    get() const;
117
118    lldb_private::CommandReturnObject &
119    operator*() const;
120
121    lldb_private::CommandReturnObject &
122    ref() const;
123
124    void
125    SetLLDBObjectPtr (lldb_private::CommandReturnObject *ptr);
126
127 private:
128    std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap;
129};
130
131} // namespace lldb
132
133#endif        // LLDB_SBCommandReturnObject_h_
134