sync with internal cleanup code

This commit is contained in:
Laurent Perron
2022-06-06 11:49:26 +02:00
parent 2d4de65a79
commit 9f375b13b2
3 changed files with 13 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ namespace {
#if defined(PROTOBUF_INTERNAL_IMPL)
using google::protobuf::Message;
#define LegacyUnredactedShortDebugString(x) x.ShortDebugString()
#else
using google::protobuf::Message;
#endif
@@ -387,7 +388,7 @@ std::string EncodeSatParametersAsString(const sat::SatParameters& parameters) {
return bytes;
}
return parameters.ShortDebugString();
return LegacyUnredactedShortDebugString(parameters);
}
} // namespace operations_research

View File

@@ -24,13 +24,16 @@
#include "absl/base/attributes.h"
#include "absl/strings/str_cat.h"
#define LegacyUnredactedDebugString(x) x.DebugString()
#define LegacyUnredactedShortDebugString(x) x.ShortDebugString()
namespace operations_research {
template <class P>
std::string ProtobufDebugString(const P& message) {
#if defined(__PORTABLE_PLATFORM__)
return message.GetTypeName();
#else // defined(__PORTABLE_PLATFORM__)
return message.DebugString();
return LegacyUnredactedDebugString(message);
#endif // !defined(__PORTABLE_PLATFORM__)
}
@@ -39,7 +42,7 @@ std::string ProtobufShortDebugString(const P& message) {
#if defined(__PORTABLE_PLATFORM__)
return message.GetTypeName();
#else // defined(__PORTABLE_PLATFORM__)
return message.ShortDebugString();
return LegacyUnredactedShortDebugString(message);
#endif // !defined(__PORTABLE_PLATFORM__)
}

View File

@@ -39,6 +39,9 @@ namespace operations_research {
namespace sat {
namespace {
#define LegacyUnredactedDebugString(x) x.DebugString()
#define LegacyUnredactedShortDebugString(x) x.ShortDebugString()
// =============================================================================
// CpModelProto validation.
// =============================================================================
@@ -637,18 +640,18 @@ std::string ValidateCumulativeConstraint(const CpModelProto& model,
for (const LinearExpressionProto& demand_expr : ct.cumulative().demands()) {
if (MinOfExpression(model, demand_expr) < 0) {
return absl::StrCat(
"Demand ", demand_expr.DebugString(),
"Demand ", LegacyUnredactedDebugString(demand_expr),
" must be positive in constraint: ", ProtobufDebugString(ct));
}
if (demand_expr.vars_size() > 1) {
return absl::StrCat("Demand ", demand_expr.DebugString(),
return absl::StrCat("Demand ", LegacyUnredactedDebugString(demand_expr),
" must be affine or constant in constraint: ",
ProtobufDebugString(ct));
}
}
if (ct.cumulative().capacity().vars_size() > 1) {
return absl::StrCat(
"capacity ", ct.cumulative().capacity().DebugString(),
"capacity ", LegacyUnredactedDebugString(ct.cumulative().capacity()),
" must be affine or constant in constraint: ", ProtobufDebugString(ct));
}