7 #ifndef MEDIA_BASE_STATUS_H_
8 #define MEDIA_BASE_STATUS_H_
12 #include "packager/base/logging.h"
14 namespace edash_packager {
84 Status(error::Code error_code,
const std::string& error_message)
85 : error_code_(error_code) {
87 error_message_ = error_message;
95 static const Status& UNKNOWN;
101 void SetError(error::Code error_code,
const std::string& error_message) {
102 if (error_code == error::OK) {
105 error_code_ = error_code;
106 error_message_ = error_message;
125 error_code_ = error::OK;
129 bool ok()
const {
return error_code_ == error::OK; }
130 error::Code error_code()
const {
return error_code_; }
131 const std::string& error_message()
const {
return error_message_; }
133 bool operator==(
const Status& x)
const {
134 return error_code_ == x.error_code() && error_message_ == x.error_message();
136 bool operator!=(
const Status& x)
const {
return !(*
this == x); }
141 bool Matches(
const Status& x)
const {
return error_code_ == x.error_code(); }
146 void Swap(
Status* other) {
147 error::Code error_code = error_code_;
148 error_code_ = other->error_code_;
149 other->error_code_ = error_code;
150 error_message_.swap(other->error_message_);
154 error::Code error_code_;
155 std::string error_message_;
161 extern std::ostream& operator<<(std::ostream& os,
const Status& x);
166 #endif // MEDIA_BASE_STATUS_H_