Export media_cas_packager_sdk
This commit is contained in:
37
util/proto_status.h
Normal file
37
util/proto_status.h
Normal file
@@ -0,0 +1,37 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 2017 Google LLC.
|
||||
//
|
||||
// This software is licensed under the terms defined in the Widevine Master
|
||||
// License Agreement. For a copy of this agreement, please contact
|
||||
// widevine-licensing@google.com.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef UTIL_PROTO_STATUS_H_
|
||||
#define UTIL_PROTO_STATUS_H_
|
||||
|
||||
#include "google/protobuf/descriptor.h"
|
||||
#include "google/protobuf/generated_enum_reflection.h"
|
||||
#include "util/status.h"
|
||||
|
||||
namespace widevine {
|
||||
namespace util {
|
||||
|
||||
template <typename T>
|
||||
class ProtoEnumErrorSpace : public ErrorSpaceImpl<ProtoEnumErrorSpace<T>> {
|
||||
public:
|
||||
static std::string SpaceName() {
|
||||
return google::protobuf::GetEnumDescriptor<T>()->full_name();
|
||||
}
|
||||
|
||||
static std::string CodeToString(int code) {
|
||||
const google::protobuf::EnumValueDescriptor* v =
|
||||
google::protobuf::GetEnumDescriptor<T>()->FindValueByNumber(code);
|
||||
if (v) return v->name();
|
||||
return std::to_string(code);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace util
|
||||
} // namespace widevine
|
||||
|
||||
#endif // UTIL_PROTO_STATUS_H_
|
||||
Reference in New Issue
Block a user