7 #ifndef MEDIA_BASE_STATUS_H_
8 #define MEDIA_BASE_STATUS_H_
93 Status(error::Code error_code,
const std::string& error_message)
94 : error_code_(error_code) {
96 error_message_ = error_message;
104 static const Status UNKNOWN;
110 void SetError(error::Code error_code,
const std::string& error_message) {
111 if (error_code == error::OK) {
114 error_code_ = error_code;
115 error_message_ = error_message;
134 error_code_ = error::OK;
138 bool ok()
const {
return error_code_ == error::OK; }
139 error::Code error_code()
const {
return error_code_; }
140 const std::string& error_message()
const {
return error_message_; }
142 bool operator==(
const Status& x)
const {
143 return error_code_ == x.error_code() && error_message_ == x.error_message();
145 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
150 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
155 void Swap(
Status* other) {
156 error::Code error_code = error_code_;
157 error_code_ = other->error_code_;
158 other->error_code_ = error_code;
159 error_message_.swap(other->error_message_);
163 error::Code error_code_;
164 std::string error_message_;
170 std::ostream& operator<<(std::ostream& os,
const Status& x);
175 #endif // MEDIA_BASE_STATUS_H_