14#ifndef OR_TOOLS_PORT_PROTO_UTILS_H_
15#define OR_TOOLS_PORT_PROTO_UTILS_H_
19#ifndef __PORTABLE_PLATFORM__
20#include "google/protobuf/descriptor.h"
21#include "google/protobuf/text_format.h"
24#include "absl/strings/str_cat.h"
27#if defined(__PORTABLE_PLATFORM__)
38template <
typename ProtoEnumType>
40 return absl::StrCat(enum_value);
43template <
typename ProtoType>
45 ABSL_ATTRIBUTE_UNUSED,
46 ProtoType*
proto ABSL_ATTRIBUTE_UNUSED) {
59 return message.ShortDebugString();
62template <
typename ProtoEnumType>
64 auto enum_descriptor = google::protobuf::GetEnumDescriptor<ProtoEnumType>();
65 auto enum_value_descriptor = enum_descriptor->FindValueByNumber(enum_value);
66 if (enum_value_descriptor ==
nullptr) {
68 "Invalid enum value of: ", enum_value,
" for enum type: ",
69 google::protobuf::GetEnumDescriptor<ProtoEnumType>()->
name());
71 return enum_value_descriptor->name();
74template <
typename ProtoType>
77 return google::protobuf::TextFormat::MergeFromString(proto_text_string,
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
bool ProtobufTextFormatMergeFromString(const std::string &proto_text_string, ProtoType *proto)
std::string ProtoEnumToString(ProtoEnumType enum_value)
std::string ProtobufDebugString(const P &message)
std::string ProtobufShortDebugString(const P &message)