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