| 79 | #endif |
| 80 | |
| 81 | class StatusWithReason |
| 82 | { |
| 83 | public: |
| 84 | StatusWithReason() : m_code(0) |
| 85 | {} |
| 86 | StatusWithReason(bool ok) |
| 87 | { |
| 88 | if (ok) |
| 89 | m_code = 0; |
| 90 | else |
| 91 | m_code = -1; |
| 92 | } |
| 93 | StatusWithReason(int code) = delete; |
| 94 | StatusWithReason(int code, const std::string& what) : |
| 95 | m_code(code), m_what(what) |
| 96 | {} |
| 97 | |
| 98 | int code() const |
| 99 | { return m_code; } |
| 100 | |
| 101 | operator bool () const |
| 102 | { return (m_code == 0); } |
| 103 | |
| 104 | std::string what() const |
| 105 | { return m_what; } |
| 106 | |
| 107 | private: |
| 108 | int m_code; |
| 109 | std::string m_what; |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | /** |
no outgoing calls