1 //===-- SBError.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_SBError_h_
11 #define LLDB_SBError_h_
12 
13 #include "lldb/API/SBDefines.h"
14 
15 namespace lldb {
16 
17 class LLDB_API SBError {
18 public:
19   SBError();
20 
21   SBError(const lldb::SBError &rhs);
22 
23   ~SBError();
24 
25   const SBError &operator=(const lldb::SBError &rhs);
26 
27   const char *GetCString() const;
28 
29   void Clear();
30 
31   bool Fail() const;
32 
33   bool Success() const;
34 
35   uint32_t GetError() const;
36 
37   lldb::ErrorType GetType() const;
38 
39   void SetError(uint32_t err, lldb::ErrorType type);
40 
41   void SetErrorToErrno();
42 
43   void SetErrorToGenericError();
44 
45   void SetErrorString(const char *err_str);
46 
47   int SetErrorStringWithFormat(const char *format, ...)
48       __attribute__((format(printf, 2, 3)));
49 
50   bool IsValid() const;
51 
52   bool GetDescription(lldb::SBStream &description);
53 
54 protected:
55   friend class SBCommandReturnObject;
56   friend class SBData;
57   friend class SBDebugger;
58   friend class SBCommunication;
59   friend class SBHostOS;
60   friend class SBPlatform;
61   friend class SBProcess;
62   friend class SBStructuredData;
63   friend class SBThread;
64   friend class SBTrace;
65   friend class SBTarget;
66   friend class SBValue;
67   friend class SBWatchpoint;
68   friend class SBBreakpoint;
69   friend class SBBreakpointLocation;
70   friend class SBBreakpointName;
71 
72   lldb_private::Status *get();
73 
74   lldb_private::Status *operator->();
75 
76   const lldb_private::Status &operator*() const;
77 
78   lldb_private::Status &ref();
79 
80   void SetError(const lldb_private::Status &lldb_error);
81 
82 private:
83   std::unique_ptr<lldb_private::Status> m_opaque_ap;
84 
85   void CreateIfNeeded();
86 };
87 
88 } // namespace lldb
89 
90 #endif // LLDB_SBError_h_
91