Chromium Code Reviews| Index: blimp/helium/syncable_primitive_serializer.h |
| diff --git a/blimp/helium/syncable_primitive_serializer.h b/blimp/helium/syncable_primitive_serializer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8f22a3b97e95b9aa36bf49e562470323c1097256 |
| --- /dev/null |
| +++ b/blimp/helium/syncable_primitive_serializer.h |
| @@ -0,0 +1,44 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BLIMP_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_ |
| +#define BLIMP_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_ |
| + |
| +#include <string> |
| + |
| +#include "blimp/helium/blimp_helium_export.h" |
| + |
| +namespace google { |
| +namespace protobuf { |
| +namespace io { |
| +class CodedInputStream; |
| +class CodedOutputStream; |
| +} // namespace io |
| +} // namespace protobuf |
| +} // namespace google |
| + |
| +namespace blimp { |
| +namespace helium { |
| + |
| +// Syncable CRDTs need to serialize their data into CodedOutputStreams. This |
| +// helper class centralizes that logic into two overloaded functions, one for |
| +// serialization and one for deserialization that can be called for any |
|
Kevin M
2016/10/19 00:27:08
"Any" doesn't seem accurate here, as we only suppo
steimel
2016/10/19 16:40:50
Done.
|
| +// primitive type. |
| +class BLIMP_HELIUM_EXPORT SyncablePrimitiveSerializer { |
| + public: |
| + static void Serialize(const int32_t& value, |
| + google::protobuf::io::CodedOutputStream* output_stream); |
| + static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| + int32_t* value); |
| + |
| + static void Serialize(const std::string& value, |
| + google::protobuf::io::CodedOutputStream* output_stream); |
| + static bool Deserialize(google::protobuf::io::CodedInputStream* input_stream, |
| + std::string* value); |
| +}; |
| + |
| +} // namespace helium |
| +} // namespace blimp |
| + |
| +#endif // BLIMP_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_ |