Skip to content

Commit bf2ea23

Browse files
committed
update
1 parent 9f9bdb6 commit bf2ea23

File tree

3 files changed

+9
-19
lines changed

3 files changed

+9
-19
lines changed

ortools/util/BUILD.bazel

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,6 @@ cc_library(
349349
srcs = ["file_util.cc"],
350350
hdrs = ["file_util.h"],
351351
deps = [
352-
"//ortools/base",
353352
"//ortools/base:file",
354353
"//ortools/base:gzipstring",
355354
"//ortools/base:recordio",
@@ -475,10 +474,10 @@ cc_library(
475474
deps = [
476475
"//ortools/base:intops",
477476
"//ortools/base:linked_hash_map",
478-
"//ortools/base:logging",
479477
"@abseil-cpp//absl/base:core_headers",
480478
"@abseil-cpp//absl/base:nullability",
481479
"@abseil-cpp//absl/functional:any_invocable",
480+
"@abseil-cpp//absl/log:check",
482481
"@abseil-cpp//absl/synchronization",
483482
],
484483
)

ortools/util/file_util.cc

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,11 @@
3131
#include "ortools/base/file.h"
3232
#include "ortools/base/gzipstring.h"
3333
#include "ortools/base/helpers.h"
34-
#include "ortools/base/logging.h"
3534
#include "ortools/base/options.h"
3635
#include "ortools/base/status_macros.h"
3736

3837
namespace operations_research {
3938

40-
using google::protobuf::util::JsonParseOptions;
41-
using google::protobuf::util::JsonStringToMessage;
42-
4339
absl::StatusOr<std::string> ReadFileToString(absl::string_view filename) {
4440
std::string contents;
4541
RETURN_IF_ERROR(file::GetContents(filename, &contents, file::Defaults()));
@@ -119,7 +115,7 @@ absl::Status StringToProto(absl::string_view data,
119115
}
120116
std::string json_error;
121117
absl::Status json_status =
122-
JsonStringToMessage(data, proto, JsonParseOptions());
118+
::google::protobuf::util::JsonStringToMessage(data, proto);
123119
if (json_status.ok()) {
124120
// NOTE(user): We protect against the JSON proto3 parser being very lenient
125121
// and easily accepting any JSON as a valid JSON for our proto: if the
@@ -164,34 +160,30 @@ absl::Status WriteProtoToFile(absl::string_view filename,
164160
}
165161
break;
166162
case ProtoWriteFormat::kJson: {
167-
google::protobuf::util::JsonPrintOptions options;
163+
google::protobuf::json::PrintOptions options;
168164
options.add_whitespace = true;
169-
#if PROTOBUF_VERSION >= 5026000 // Version 26.0.0
165+
options.unquote_int64_if_possible = true;
170166
options.always_print_fields_with_no_presence = true;
171-
#else
172-
options.always_print_primitive_fields = true;
173-
#endif
174167
options.preserve_proto_field_names = true;
175-
if (!google::protobuf::util::MessageToJsonString(proto, &output_string,
168+
if (!google::protobuf::json::MessageToJsonString(proto, &output_string,
176169
options)
177170
.ok()) {
178-
LOG(WARNING) << "Printing to stream failed.";
179-
return make_error("google::protobuf::util::MessageToJsonString()");
171+
return make_error("google::protobuf::json::MessageToJsonString()");
180172
}
181173
file_type_suffix = ".json";
182174
break;
183175
}
184-
case ProtoWriteFormat::kCanonicalJson:
176+
case ProtoWriteFormat::kCanonicalJson: {
185177
google::protobuf::util::JsonPrintOptions options;
186178
options.add_whitespace = true;
187179
if (!google::protobuf::util::MessageToJsonString(proto, &output_string,
188180
options)
189181
.ok()) {
190-
LOG(WARNING) << "Printing to stream failed.";
191182
return make_error("google::protobuf::util::MessageToJsonString()");
192183
}
193184
file_type_suffix = ".json";
194185
break;
186+
}
195187
}
196188
if (gzipped) {
197189
std::string gzip_string;

ortools/util/solve_interrupter.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@
1919

2020
#include "absl/base/nullability.h"
2121
#include "absl/functional/any_invocable.h"
22+
#include "absl/log/check.h"
2223
#include "absl/synchronization/mutex.h"
23-
#include "ortools/base/linked_hash_map.h"
24-
#include "ortools/base/logging.h"
2524

2625
namespace operations_research {
2726

0 commit comments

Comments
 (0)