0dce4e7e83e136ef44ad7df8aab4143cc0485d77
[platform/upstream/caffeonacl.git] / src / caffe / util / io.hpp
1 // Copyright Yangqing Jia 2013
2
3 #ifndef CAFFE_UTIL_IO_H_
4 #define CAFFE_UTIL_IO_H_
5
6 #include <google/protobuf/message.h>
7
8 #include <string>
9
10 #include "caffe/blob.hpp"
11 #include "caffe/proto/caffe.pb.h"
12
13 using std::string;
14 using ::google::protobuf::Message;
15
16 namespace caffe {
17
18 void ReadProtoFromTextFile(const char* filename,
19     Message* proto);
20 inline void ReadProtoFromTextFile(const string& filename,
21     Message* proto) {
22   ReadProtoFromTextFile(filename.c_str(), proto);
23 }
24
25 void WriteProtoToTextFile(const Message& proto, const char* filename);
26 inline void WriteProtoToTextFile(const Message& proto, const string& filename) {
27   WriteProtoToTextFile(proto, filename.c_str());
28 }
29
30 void ReadProtoFromBinaryFile(const char* filename,
31     Message* proto);
32 inline void ReadProtoFromBinaryFile(const string& filename,
33     Message* proto) {
34   ReadProtoFromBinaryFile(filename.c_str(), proto);
35 }
36
37 void WriteProtoToBinaryFile(const Message& proto, const char* filename);
38 inline void WriteProtoToBinaryFile(
39     const Message& proto, const string& filename) {
40   WriteProtoToBinaryFile(proto, filename.c_str());
41 }
42
43
44 }  // namespace caffe
45
46 #endif   // CAFFE_UTIL_IO_H_