7 #ifndef PACKAGER_STATUS_H_
8 #define PACKAGER_STATUS_H_
13 #if defined(SHARED_LIBRARY_BUILD)
16 #if defined(SHAKA_IMPLEMENTATION)
17 #define SHAKA_EXPORT __declspec(dllexport)
19 #define SHAKA_EXPORT __declspec(dllimport)
20 #endif // defined(SHAKA_IMPLEMENTATION)
22 #else // defined(OS_WIN)
24 #if defined(SHAKA_IMPLEMENTATION)
25 #define SHAKA_EXPORT __attribute__((visibility("default")))
30 #endif // defined(OS_WIN)
32 #else // defined(SHARED_LIBRARY_BUILD)
34 #endif // defined(SHARED_LIBRARY_BUILD)
118 Status(error::Code error_code,
const std::string& error_message)
119 : error_code_(error_code) {
121 error_message_ = error_message;
128 static const Status OK;
129 static const Status UNKNOWN;
135 void SetError(error::Code error_code,
const std::string& error_message) {
136 if (error_code == error::OK) {
139 error_code_ = error_code;
140 error_message_ = error_message;
159 error_code_ = error::OK;
163 bool ok()
const {
return error_code_ == error::OK; }
164 error::Code error_code()
const {
return error_code_; }
165 const std::string& error_message()
const {
return error_message_; }
167 bool operator==(
const Status& x)
const {
168 return error_code_ == x.error_code() && error_message_ == x.error_message();
170 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
175 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
178 std::string ToString()
const;
180 void Swap(
Status* other) {
181 error::Code error_code = error_code_;
182 error_code_ = other->error_code_;
183 other->error_code_ = error_code;
184 error_message_.swap(other->error_message_);
188 error::Code error_code_;
189 std::string error_message_;
195 SHAKA_EXPORT std::ostream& operator<<(std::ostream& os,
const Status& x);
199 #endif // PACKAGER_STATUS_H_
void Clear()
Clear this status object to contain the OK code and no error message.
bool Matches(const Status &x) const
void Update(const Status &new_status)
void SetError(error::Code error_code, const std::string &error_message)
Status()
Creates a "successful" status.
Status(error::Code error_code, const std::string &error_message)