14#ifndef OR_TOOLS_UTIL_PROTO_TOOLS_H_
15#define OR_TOOLS_UTIL_PROTO_TOOLS_H_
19#include "absl/base/casts.h"
20#include "absl/status/status.h"
21#include "absl/status/statusor.h"
22#include "absl/strings/str_format.h"
23#include "google/protobuf/descriptor.h"
24#include "google/protobuf/message.h"
37 const google::protobuf::Message*
proto);
43 const google::protobuf::Message&
message,
int indent_level);
50 const google::protobuf::Descriptor* expected_descriptor =
51 Proto::default_instance().GetDescriptor();
52 const google::protobuf::Descriptor* actual_descriptor =
53 proto->GetDescriptor();
54 if (actual_descriptor == expected_descriptor)
55 return reinterpret_cast<Proto*
>(
proto);
56 return absl::InvalidArgumentError(absl::StrFormat(
57 "Expected message type '%s', but got type '%s'",
58 expected_descriptor->full_name(), actual_descriptor->full_name()));
63 const google::protobuf::Message*
proto) {
64 const google::protobuf::Descriptor* expected_descriptor =
65 Proto::default_instance().GetDescriptor();
66 const google::protobuf::Descriptor* actual_descriptor =
67 proto->GetDescriptor();
68 if (actual_descriptor == expected_descriptor) {
69 return reinterpret_cast<const Proto*
>(
proto);
71 return absl::InvalidArgumentError(absl::StrFormat(
72 "Expected message type '%s', but got type '%s'",
73 expected_descriptor->full_name(), actual_descriptor->full_name()));
CpModelProto proto
The output proto.
In SWIG mode, we don't want anything besides these top-level includes.
std::string FullProtocolMessageAsString(const google::protobuf::Message &message, int indent_level)
absl::StatusOr< Proto * > SafeProtoDownCast(google::protobuf::Message *proto)
Implementation of function templates.
absl::StatusOr< const Proto * > SafeProtoConstDownCast(const google::protobuf::Message *proto)