14#ifndef ORTOOLS_UTIL_PROTO_TOOLS_H_
15#define ORTOOLS_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/descriptor.h"
23#include "google/protobuf/message.h"
36 const google::protobuf::Message* proto);
42 const google::protobuf::Message& message,
int indent_level);
59 const google::protobuf::Message& message,
63 absl::flat_hash_map<std::string, int>* proto_path_counts);
70 const google::protobuf::Descriptor* expected_descriptor =
71 Proto::default_instance().GetDescriptor();
72 const google::protobuf::Descriptor* actual_descriptor =
73 proto->GetDescriptor();
74 if (actual_descriptor == expected_descriptor)
75 return reinterpret_cast<Proto*
>(proto);
76 return absl::InvalidArgumentError(absl::StrFormat(
77 "Expected message type '%s', but got type '%s'",
78 expected_descriptor->full_name(), actual_descriptor->full_name()));
83 const google::protobuf::Message* proto) {
84 const google::protobuf::Descriptor* expected_descriptor =
85 Proto::default_instance().GetDescriptor();
86 const google::protobuf::Descriptor* actual_descriptor =
87 proto->GetDescriptor();
88 if (actual_descriptor == expected_descriptor) {
89 return reinterpret_cast<const Proto*
>(proto);
91 return absl::InvalidArgumentError(absl::StrFormat(
92 "Expected message type '%s', but got type '%s'",
93 expected_descriptor->full_name(), actual_descriptor->full_name()));
std::string FullProtocolMessageAsString(const google::protobuf::Message &message, int indent_level)
absl::StatusOr< Proto * > SafeProtoDownCast(google::protobuf::Message *proto)
void ExploreAndCountAllProtoPathsInInstance(const google::protobuf::Message &message, absl::flat_hash_map< std::string, int > *proto_path_counts)
absl::StatusOr< const Proto * > SafeProtoConstDownCast(const google::protobuf::Message *proto)