#ifndef FLUTTER_FML_STATUS_H_
#define FLUTTER_FML_STATUS_H_
#include <string_view>
namespace fml {
enum class StatusCode {
kOk,
kCancelled,
kUnknown,
kInvalidArgument,
kDeadlineExceeded,
kNotFound,
kAlreadyExists,
kPermissionDenied,
kResourceExhausted,
kFailedPrecondition,
kAborted,
kOutOfRange,
kUnimplemented,
kInternal,
kUnavailable,
kDataLoss,
kUnauthenticated
};
class Status final {
public:
Status();
Status(fml::StatusCode code, std::string_view message);
fml::StatusCode code() const;
void IgnoreError() const;
bool ok() const;
std::string_view message() const;
private:
fml::StatusCode code_;
std::string_view message_;
};
inline Status::Status() : code_(fml::StatusCode::kOk), message_() {}
inline Status::Status(fml::StatusCode code, std::string_view message)
: code_(code), message_(message) {}
inline fml::StatusCode Status::code() const {
return code_;
}
inline void Status::IgnoreError() const {
}
inline bool Status::ok() const {
return code_ == fml::StatusCode::kOk;
}
inline std::string_view Status::message() const {
return message_;
}
}
#endif