SBError.h revision 1fa6b3d6c83955fe06c63d3a4025f2c0ec431d68
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
15namespace lldb {
16
17class SBError {
18public:
19    SBError ();
20
21    SBError (const lldb::SBError &rhs);
22
23    ~SBError();
24
25#ifndef SWIG
26
27    const SBError &
28    operator =(const lldb::SBError &rhs);
29
30#endif
31
32    const char *
33    GetCString () const;
34
35    void
36    Clear ();
37
38    bool
39    Fail () const;
40
41    bool
42    Success () const;
43
44    uint32_t
45    GetError () const;
46
47    lldb::ErrorType
48    GetType () const;
49
50    void
51    SetError (uint32_t err, lldb::ErrorType type);
52
53    void
54    SetErrorToErrno ();
55
56    void
57    SetErrorToGenericError ();
58
59    void
60    SetErrorString (const char *err_str);
61
62    int
63    SetErrorStringWithFormat (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
64
65    bool
66    IsValid () const;
67
68    bool
69    GetDescription (lldb::SBStream &description);
70
71protected:
72
73#ifndef SWIG
74    friend class SBArguments;
75    friend class SBData;
76    friend class SBDebugger;
77    friend class SBCommunication;
78    friend class SBHostOS;
79    friend class SBInputReader;
80    friend class SBProcess;
81    friend class SBThread;
82    friend class SBTarget;
83    friend class SBValue;
84    friend class SBWatchpoint;
85
86    lldb_private::Error *
87    get();
88
89    lldb_private::Error *
90    operator->();
91
92    const lldb_private::Error &
93    operator*() const;
94
95    lldb_private::Error &
96    ref();
97
98#endif
99
100
101    void
102    SetError (const lldb_private::Error &lldb_error);
103
104private:
105    std::auto_ptr<lldb_private::Error> m_opaque_ap;
106
107    void
108    CreateIfNeeded ();
109};
110
111
112} // namespace lldb
113
114#endif // LLDB_SBError_h_
115