| 180 | //--------------------------------------------------------------------------- |
| 181 | |
| 182 | void protobuf_util::SerializeMessage(int fd, const google::protobuf::Message& message) |
| 183 | { |
| 184 | const string data = message.SerializeAsString(); |
| 185 | |
| 186 | // Write the size of the protobuf data as a header |
| 187 | const auto size = static_cast<int32_t>(data.length()); |
| 188 | if (write(fd, &size, sizeof(size)) != sizeof(size)) { |
| 189 | throw io_exception("Can't write protobuf message size"); |
| 190 | } |
| 191 | |
| 192 | // Write the actual protobuf data |
| 193 | if (write(fd, data.data(), size) != size) { |
| 194 | throw io_exception("Can't write protobuf message data"); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | void protobuf_util::DeserializeMessage(int fd, google::protobuf::Message& message) |
| 199 | { |
nothing calls this directly
no test coverage detected