7 #ifndef MEDIA_BASE_STATUS_H_
8 #define MEDIA_BASE_STATUS_H_
90 Status(error::Code error_code,
const std::string& error_message)
91 : error_code_(error_code) {
93 error_message_ = error_message;
101 static const Status UNKNOWN;
107 void SetError(error::Code error_code,
const std::string& error_message) {
108 if (error_code == error::OK) {
111 error_code_ = error_code;
112 error_message_ = error_message;
131 error_code_ = error::OK;
135 bool ok()
const {
return error_code_ == error::OK; }
136 error::Code error_code()
const {
return error_code_; }
137 const std::string& error_message()
const {
return error_message_; }
139 bool operator==(
const Status& x)
const {
140 return error_code_ == x.error_code() && error_message_ == x.error_message();
142 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
147 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
152 void Swap(
Status* other) {
153 error::Code error_code = error_code_;
154 error_code_ = other->error_code_;
155 other->error_code_ = error_code;
156 error_message_.swap(other->error_message_);
160 error::Code error_code_;
161 std::string error_message_;
167 std::ostream& operator<<(std::ostream& os,
const Status& x);
172 #endif // MEDIA_BASE_STATUS_H_