7 #ifndef MEDIA_BASE_STATUS_H_
8 #define MEDIA_BASE_STATUS_H_
87 Status(error::Code error_code,
const std::string& error_message)
88 : error_code_(error_code) {
90 error_message_ = error_message;
98 static const Status UNKNOWN;
104 void SetError(error::Code error_code,
const std::string& error_message) {
105 if (error_code == error::OK) {
108 error_code_ = error_code;
109 error_message_ = error_message;
128 error_code_ = error::OK;
132 bool ok()
const {
return error_code_ == error::OK; }
133 error::Code error_code()
const {
return error_code_; }
134 const std::string& error_message()
const {
return error_message_; }
136 bool operator==(
const Status& x)
const {
137 return error_code_ == x.error_code() && error_message_ == x.error_message();
139 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
144 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
149 void Swap(
Status* other) {
150 error::Code error_code = error_code_;
151 error_code_ = other->error_code_;
152 other->error_code_ = error_code;
153 error_message_.swap(other->error_message_);
157 error::Code error_code_;
158 std::string error_message_;
164 std::ostream& operator<<(std::ostream& os,
const Status& x);
169 #endif // MEDIA_BASE_STATUS_H_