| 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_HELIUM_CODED_VALUE_SERIALIZER_H_ |
| 6 #define BLIMP_HELIUM_CODED_VALUE_SERIALIZER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "blimp/helium/blimp_helium_export.h" |
| 11 |
| 12 namespace google { |
| 13 namespace protobuf { |
| 14 namespace io { |
| 15 class CodedInputStream; |
| 16 class CodedOutputStream; |
| 17 } // namespace io |
| 18 } // namespace protobuf |
| 19 } // namespace google |
| 20 |
| 21 namespace blimp { |
| 22 namespace helium { |
| 23 |
| 24 class VersionVector; |
| 25 |
| 26 // Syncable CRDTs need to serialize their data into CodedOutputStreams. This |
| 27 // helper class centralizes that logic into two overloaded functions, one for |
| 28 // serialization and one for deserialization that can be called for any |
| 29 // supported primitive type. |
| 30 class BLIMP_HELIUM_EXPORT CodedValueSerializer { |
| 31 public: |
| 32 static void Serialize(const int32_t& value, |
| 33 google::protobuf::io::CodedOutputStream* output_stream); |
| 34 static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| 35 int32_t* value); |
| 36 |
| 37 static void Serialize(const std::string& value, |
| 38 google::protobuf::io::CodedOutputStream* output_stream); |
| 39 static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| 40 std::string* value); |
| 41 |
| 42 static void Serialize(const VersionVector& value, |
| 43 google::protobuf::io::CodedOutputStream* output_stream); |
| 44 static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| 45 VersionVector* value); |
| 46 }; |
| 47 |
| 48 } // namespace helium |
| 49 } // namespace blimp |
| 50 |
| 51 #endif // BLIMP_HELIUM_CODED_VALUE_SERIALIZER_H_ |
| OLD | NEW |