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 <memory> 16 17 #include "lldb/API/SBDefines.h" 18 19 namespace lldb { 20 21 class LLDB_API SBCommandReturnObject { 22 public: 23 SBCommandReturnObject(); 24 25 SBCommandReturnObject(const lldb::SBCommandReturnObject &rhs); 26 27 ~SBCommandReturnObject(); 28 29 const lldb::SBCommandReturnObject & 30 operator=(const lldb::SBCommandReturnObject &rhs); 31 32 SBCommandReturnObject(lldb_private::CommandReturnObject *ptr); 33 34 lldb_private::CommandReturnObject *Release(); 35 36 bool IsValid() const; 37 38 const char *GetOutput(); 39 40 const char *GetError(); 41 42 size_t PutOutput(FILE *fh); 43 44 size_t GetOutputSize(); 45 46 size_t GetErrorSize(); 47 48 size_t PutError(FILE *fh); 49 50 void Clear(); 51 52 lldb::ReturnStatus GetStatus(); 53 54 void SetStatus(lldb::ReturnStatus status); 55 56 bool Succeeded(); 57 58 bool HasResult(); 59 60 void AppendMessage(const char *message); 61 62 void AppendWarning(const char *message); 63 64 bool GetDescription(lldb::SBStream &description); 65 66 // deprecated, these two functions do not take ownership of file handle 67 void SetImmediateOutputFile(FILE *fh); 68 69 void SetImmediateErrorFile(FILE *fh); 70 71 void SetImmediateOutputFile(FILE *fh, bool transfer_ownership); 72 73 void SetImmediateErrorFile(FILE *fh, bool transfer_ownership); 74 75 void PutCString(const char *string, int len = -1); 76 77 size_t Printf(const char *format, ...) __attribute__((format(printf, 2, 3))); 78 79 const char *GetOutput(bool only_if_no_immediate); 80 81 const char *GetError(bool only_if_no_immediate); 82 83 void SetError(lldb::SBError &error, 84 const char *fallback_error_cstr = nullptr); 85 86 void SetError(const char *error_cstr); 87 88 protected: 89 friend class SBCommandInterpreter; 90 friend class SBOptions; 91 92 lldb_private::CommandReturnObject *operator->() const; 93 94 lldb_private::CommandReturnObject *get() const; 95 96 lldb_private::CommandReturnObject &operator*() const; 97 98 lldb_private::CommandReturnObject &ref() const; 99 100 void SetLLDBObjectPtr(lldb_private::CommandReturnObject *ptr); 101 102 private: 103 std::unique_ptr<lldb_private::CommandReturnObject> m_opaque_ap; 104 }; 105 106 } // namespace lldb 107 108 #endif // LLDB_SBCommandReturnObject_h_ 109