Updated formatting in iOS parse proto utils
This commit is contained in:
parent
f51dd05e89
commit
377d632508
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2022 The MediaPipe Authors.
|
/* Copyright 2023 The MediaPipe Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -21,20 +21,22 @@ limitations under the License.
|
||||||
namespace mediapipe::tasks::ios::test::vision::utils {
|
namespace mediapipe::tasks::ios::test::vision::utils {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
using ::google::protobuf::TextFormat;
|
using ::google::protobuf::TextFormat;
|
||||||
}
|
} // anonymous namespace
|
||||||
|
|
||||||
absl::Status get_proto_from_pbtxt(const std::string file_path, google::protobuf::Message& proto) {
|
absl::Status get_proto_from_pbtxt(const std::string file_path,
|
||||||
|
google::protobuf::Message& proto) {
|
||||||
|
std::ifstream file_input_stream(file_path);
|
||||||
|
if (!file_input_stream.is_open())
|
||||||
|
return absl::InvalidArgumentError("Cannot read input file.");
|
||||||
|
|
||||||
std::ifstream file_input_stream(file_path);
|
std::stringstream strings_stream;
|
||||||
if(!file_input_stream.is_open()) return absl::InvalidArgumentError(
|
strings_stream << file_input_stream.rdbuf();
|
||||||
"Cannot read input file.");
|
|
||||||
|
|
||||||
std::stringstream strings_stream ;
|
return TextFormat::ParseFromString(strings_stream.str(), &proto)
|
||||||
strings_stream << file_input_stream.rdbuf();
|
? absl::OkStatus()
|
||||||
|
: absl::InvalidArgumentError(
|
||||||
return TextFormat::ParseFromString(strings_stream.str(), &proto) ? absl::OkStatus() : absl::InvalidArgumentError(
|
"Cannot read a valid proto from the input file.");
|
||||||
"Cannot read a valid proto from the input file.");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace mediapipe::tasks::ios::test::vision::utils
|
} // namespace mediapipe::tasks::ios::test::vision::utils
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright 2022 The MediaPipe Authors.
|
/* Copyright 2023 The MediaPipe Authors.
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -22,7 +22,8 @@ limitations under the License.
|
||||||
#include "google/protobuf/text_format.h"
|
#include "google/protobuf/text_format.h"
|
||||||
|
|
||||||
namespace mediapipe::tasks::ios::test::vision::utils {
|
namespace mediapipe::tasks::ios::test::vision::utils {
|
||||||
absl::Status get_proto_from_pbtxt(const std::string file_path, google::protobuf::Message& proto);
|
absl::Status get_proto_from_pbtxt(const std::string file_path,
|
||||||
|
google::protobuf::Message& proto);
|
||||||
} // namespace mediapipe::tasks::ios::test::vision::utils
|
} // namespace mediapipe::tasks::ios::test::vision::utils
|
||||||
|
|
||||||
#endif // MEDIAPIPE_TASKS_IOS_TEST_VISION_UTILS_H_
|
#endif // MEDIAPIPE_TASKS_IOS_TEST_VISION_UTILS_H_
|
||||||
|
|
Loading…
Reference in New Issue
Block a user