| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium 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 BLIMP_NET_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_ |
| 6 #define BLIMP_NET_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 namespace google { |
| 11 namespace protobuf { |
| 12 namespace io { |
| 13 class CodedInputStream; |
| 14 class CodedOutputStream; |
| 15 } // namespace io |
| 16 } // namespace protobuf |
| 17 } // namespace google |
| 18 |
| 19 namespace blimp { |
| 20 |
| 21 // Syncable CRDTs need to serialize their data into CodedOutputStreams. This |
| 22 // helper class centralizes that logic into two overloaded functions, one for |
| 23 // serialization and one for deserialization that can be called for any |
| 24 // primitive type. |
| 25 class SyncablePrimitiveSerializer { |
| 26 public: |
| 27 static void Serialize(const int32_t& value, |
| 28 google::protobuf::io::CodedOutputStream* output_stream); |
| 29 static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| 30 int32_t* value); |
| 31 |
| 32 static void Serialize(const std::string& value, |
| 33 google::protobuf::io::CodedOutputStream* output_stream); |
| 34 static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| 35 std::string* value); |
| 36 }; |
| 37 |
| 38 } // namespace blimp |
| 39 |
| 40 #endif // BLIMP_NET_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_ |
| OLD | NEW |