1 // Copyright (c) 2012-2014 Konstantin Isakov <ikm@zbackup.org> and ZBackup contributors, see CONTRIBUTORS
2 // Part of ZBackup. Licensed under GNU GPLv2 or later + OpenSSL, see LICENSE
3 
4 #ifndef MESSAGE_HH_INCLUDED__
5 #define MESSAGE_HH_INCLUDED__
6 
7 #include <google/protobuf/io/coded_stream.h>
8 #include <google/protobuf/io/zero_copy_stream.h>
9 #include <google/protobuf/message_lite.h>
10 #include <exception>
11 
12 #include "ex.hh"
13 
14 /// Some utilities for protobuffer messages
15 namespace Message {
16 
17 DEF_EX( Ex, "Message exception", std::exception )
18 DEF_EX_STR( exCantParse, "Can't parse message", Ex )
19 DEF_EX_STR( exCantSerialize, "Can't serialize message", Ex )
20 
21 using google::protobuf::io::ZeroCopyOutputStream;
22 using google::protobuf::io::ZeroCopyInputStream;
23 using google::protobuf::io::CodedInputStream;
24 using google::protobuf::io::CodedOutputStream;
25 using google::protobuf::MessageLite;
26 
27 /// Serializes the given message to the given zero-copy stream
28 void serialize( MessageLite const &, ZeroCopyOutputStream & );
29 
30 /// Serializes the given message to the given coded stream
31 void serialize( MessageLite const &, CodedOutputStream & );
32 
33 /// Reads and parses the given message from the given zero-copy stream
34 void parse( MessageLite &, ZeroCopyInputStream & );
35 
36 /// Reads and parses the given message from the given coded stream
37 void parse( MessageLite &, CodedInputStream & );
38 }
39 
40 #endif
41