7 #ifndef MEDIA_BASE_STATUS_H_
8 #define MEDIA_BASE_STATUS_H_
13 namespace edash_packager {
83 Status(error::Code error_code,
const std::string& error_message)
84 : error_code_(error_code) {
86 error_message_ = error_message;
94 static const Status UNKNOWN;
100 void SetError(error::Code error_code,
const std::string& error_message) {
101 if (error_code == error::OK) {
104 error_code_ = error_code;
105 error_message_ = error_message;
124 error_code_ = error::OK;
128 bool ok()
const {
return error_code_ == error::OK; }
129 error::Code error_code()
const {
return error_code_; }
130 const std::string& error_message()
const {
return error_message_; }
132 bool operator==(
const Status& x)
const {
133 return error_code_ == x.error_code() && error_message_ == x.error_message();
135 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
140 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
145 void Swap(
Status* other) {
146 error::Code error_code = error_code_;
147 error_code_ = other->error_code_;
148 other->error_code_ = error_code;
149 error_message_.swap(other->error_message_);
153 error::Code error_code_;
154 std::string error_message_;
160 std::ostream& operator<<(std::ostream& os,
const Status& x);
165 #endif // MEDIA_BASE_STATUS_H_