7 #ifndef MEDIA_BASE_STATUS_H_
8 #define MEDIA_BASE_STATUS_H_
96 Status(error::Code error_code,
const std::string& error_message)
97 : error_code_(error_code) {
99 error_message_ = error_message;
107 static const Status UNKNOWN;
113 void SetError(error::Code error_code,
const std::string& error_message) {
114 if (error_code == error::OK) {
117 error_code_ = error_code;
118 error_message_ = error_message;
137 error_code_ = error::OK;
141 bool ok()
const {
return error_code_ == error::OK; }
142 error::Code error_code()
const {
return error_code_; }
143 const std::string& error_message()
const {
return error_message_; }
145 bool operator==(
const Status& x)
const {
146 return error_code_ == x.error_code() && error_message_ == x.error_message();
148 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
153 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
158 void Swap(
Status* other) {
159 error::Code error_code = error_code_;
160 error_code_ = other->error_code_;
161 other->error_code_ = error_code;
162 error_message_.swap(other->error_message_);
166 error::Code error_code_;
167 std::string error_message_;
173 std::ostream& operator<<(std::ostream& os,
const Status& x);
178 #endif // MEDIA_BASE_STATUS_H_