1 // Copyright 2017 The Chromium OS Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef LIBBRILLO_BRILLO_PROTO_FILE_IO_H_ 6 #define LIBBRILLO_BRILLO_PROTO_FILE_IO_H_ 7 8 #include <base/files/file_path.h> 9 #include <brillo/brillo_export.h> 10 #include <google/protobuf/message.h> 11 12 namespace brillo { 13 14 // Simple utilities for serializing and deserializing protobufs in 15 // text format. For an example of the format, see the docs at 16 // https://developers.google.com/protocol-buffers/docs/overview#whynotxml 17 18 BRILLO_EXPORT bool ReadTextProtobuf(const base::FilePath& proto_file, 19 google::protobuf::Message* out_proto); 20 21 BRILLO_EXPORT bool ReadTextProtobuf(int fd, 22 google::protobuf::Message* out_proto); 23 24 BRILLO_EXPORT bool WriteTextProtobuf(int fd, 25 const google::protobuf::Message& proto); 26 27 } // namespace brillo 28 29 #endif // LIBBRILLO_BRILLO_PROTO_FILE_IO_H_ 30