| Index: blimp/net/helium/syncable_primitive_serializer.h
|
| diff --git a/blimp/net/helium/syncable_primitive_serializer.h b/blimp/net/helium/syncable_primitive_serializer.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..99966653684e9d87f09a811d640e21a9dad4dd31
|
| --- /dev/null
|
| +++ b/blimp/net/helium/syncable_primitive_serializer.h
|
| @@ -0,0 +1,40 @@
|
| +// 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_NET_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_
|
| +#define BLIMP_NET_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_
|
| +
|
| +#include <string>
|
| +
|
| +namespace google {
|
| +namespace protobuf {
|
| +namespace io {
|
| +class CodedInputStream;
|
| +class CodedOutputStream;
|
| +} // namespace io
|
| +} // namespace protobuf
|
| +} // namespace google
|
| +
|
| +namespace blimp {
|
| +
|
| +// 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
|
| +// primitive type.
|
| +class 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 blimp
|
| +
|
| +#endif // BLIMP_NET_HELIUM_SYNCABLE_PRIMITIVE_SERIALIZER_H_
|
|
|