Updated formatting in iOS parse proto utils

This commit is contained in:
Prianka Liz Kariat 2023-05-25 19:15:43 +05:30
parent f51dd05e89
commit 377d632508
2 changed files with 19 additions and 16 deletions

View File

@ -1,4 +1,4 @@
/* Copyright 2022 The MediaPipe Authors.
/* Copyright 2023 The MediaPipe Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
@ -22,18 +22,20 @@ namespace mediapipe::tasks::ios::test::vision::utils {
namespace {
using ::google::protobuf::TextFormat;
}
absl::Status get_proto_from_pbtxt(const std::string file_path, google::protobuf::Message& proto) {
} // anonymous namespace
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.");
if (!file_input_stream.is_open())
return absl::InvalidArgumentError("Cannot read input file.");
std::stringstream strings_stream;
strings_stream << file_input_stream.rdbuf();
return TextFormat::ParseFromString(strings_stream.str(), &proto) ? absl::OkStatus() : absl::InvalidArgumentError(
return TextFormat::ParseFromString(strings_stream.str(), &proto)
? absl::OkStatus()
: absl::InvalidArgumentError(
"Cannot read a valid proto from the input file.");
}

View File

@ -1,4 +1,4 @@
/* Copyright 2022 The MediaPipe Authors.
/* Copyright 2023 The MediaPipe Authors.
Licensed under the Apache License, Version 2.0 (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"
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
#endif // MEDIAPIPE_TASKS_IOS_TEST_VISION_UTILS_H_