14 #ifndef OR_TOOLS_PORT_PROTO_UTILS_H_ 15 #define OR_TOOLS_PORT_PROTO_UTILS_H_ 19 #if !defined(__PORTABLE_PLATFORM__) 20 #include "google/protobuf/descriptor.h" 21 #include "google/protobuf/text_format.h" 22 #endif // !defined(__PORTABLE_PLATFORM__) 24 #include "absl/base/attributes.h" 25 #include "absl/strings/str_cat.h" 30 #if defined(__PORTABLE_PLATFORM__) 32 #else // defined(__PORTABLE_PLATFORM__) 34 #endif // !defined(__PORTABLE_PLATFORM__) 39 #if defined(__PORTABLE_PLATFORM__) 41 #else // defined(__PORTABLE_PLATFORM__) 42 return message.ShortDebugString();
43 #endif // !defined(__PORTABLE_PLATFORM__) 46 template <
typename ProtoEnumType>
48 #if defined(__PORTABLE_PLATFORM__) 49 return absl::StrCat(enum_value);
50 #else // defined(__PORTABLE_PLATFORM__) 51 auto enum_descriptor = google::protobuf::GetEnumDescriptor<ProtoEnumType>();
52 auto enum_value_descriptor = enum_descriptor->FindValueByNumber(enum_value);
53 if (enum_value_descriptor ==
nullptr) {
55 "Invalid enum value of: ", enum_value,
" for enum type: ",
56 google::protobuf::GetEnumDescriptor<ProtoEnumType>()->
name());
58 return enum_value_descriptor->name();
59 #endif // !defined(__PORTABLE_PLATFORM__) 62 template <
typename ProtoType>
65 #if defined(__PORTABLE_PLATFORM__) 67 #else // defined(__PORTABLE_PLATFORM__) 68 return google::protobuf::TextFormat::MergeFromString(proto_text_string,
70 #endif // !defined(__PORTABLE_PLATFORM__) 75 #endif // OR_TOOLS_PORT_PROTO_UTILS_H_
bool ProtobufTextFormatMergeFromString(const std::string &proto_text_string, ProtoType *proto)
std::string ProtobufDebugString(const P &message)
std::string ProtoEnumToString(ProtoEnumType enum_value)
std::string ProtobufShortDebugString(const P &message)
Collection of objects used to extend the Constraint Solver library.