14#ifndef OR_TOOLS_UTIL_PROTO_TOOLS_H_
15#define OR_TOOLS_UTIL_PROTO_TOOLS_H_
19#include "absl/status/status.h"
20#include "absl/status/statusor.h"
21#include "absl/strings/str_format.h"
22#include "google/protobuf/message.h"
35 const google::protobuf::Message*
proto);
41 const google::protobuf::Message&
message,
int indent_level);
48 const google::protobuf::Descriptor* expected_descriptor =
49 Proto::default_instance().GetDescriptor();
50 const google::protobuf::Descriptor* actual_descriptor =
51 proto->GetDescriptor();
52 if (actual_descriptor == expected_descriptor)
53 return reinterpret_cast<Proto*
>(
proto);
54 return absl::InvalidArgumentError(absl::StrFormat(
55 "Expected message type '%s', but got type '%s'",
56 expected_descriptor->full_name(), actual_descriptor->full_name()));
61 const google::protobuf::Message*
proto) {
62 const google::protobuf::Descriptor* expected_descriptor =
63 Proto::default_instance().GetDescriptor();
64 const google::protobuf::Descriptor* actual_descriptor =
65 proto->GetDescriptor();
66 if (actual_descriptor == expected_descriptor) {
67 return reinterpret_cast<const Proto*
>(
proto);
69 return absl::InvalidArgumentError(absl::StrFormat(
70 "Expected message type '%s', but got type '%s'",
71 expected_descriptor->full_name(), actual_descriptor->full_name()));
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
absl::StatusOr< Proto * > SafeProtoDownCast(google::protobuf::Message *proto)
absl::StatusOr< const Proto * > SafeProtoConstDownCast(const google::protobuf::Message *proto)
std::string FullProtocolMessageAsString(const google::protobuf::Message &message, int indent_level)