| Index: third_party/protobuf/src/google/protobuf/proto_cast.h
|
| diff --git a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h b/third_party/protobuf/src/google/protobuf/proto_cast.h
|
| similarity index 67%
|
| copy from third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h
|
| copy to third_party/protobuf/src/google/protobuf/proto_cast.h
|
| index 787706629bd10fc72eb7811d9498f19dd0524d11..e25c219ffece24b132fa9f9f6280186efba50cf2 100644
|
| --- a/third_party/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h
|
| +++ b/third_party/protobuf/src/google/protobuf/proto_cast.h
|
| @@ -1,6 +1,6 @@
|
| // Protocol Buffers - Google's data interchange format
|
| // Copyright 2008 Google Inc. All rights reserved.
|
| -// http://code.google.com/p/protobuf/
|
| +// https://developers.google.com/protocol-buffers/
|
| //
|
| // Redistribution and use in source and binary forms, with or without
|
| // modification, are permitted provided that the following conditions are
|
| @@ -28,31 +28,31 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -// Author: rennie@google.com (Jeffrey Rennie)
|
| -
|
| -#ifndef GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
|
| -#define GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
|
| +#ifndef GOOGLE_PROTOBUF_UTIL_PROTO_CAST_H__
|
| +#define GOOGLE_PROTOBUF_UTIL_PROTO_CAST_H__
|
|
|
| #include <string>
|
|
|
| #include <google/protobuf/stubs/common.h>
|
| -namespace google {
|
| -namespace protobuf {
|
| -namespace compiler {
|
| -namespace cpp {
|
| -
|
| -// Generator options:
|
| -struct Options {
|
| - Options() : safe_boundary_check(false) {
|
| - }
|
| - string dllexport_decl;
|
| - bool safe_boundary_check;
|
| -};
|
|
|
| -} // namespace cpp
|
| -} // namespace compiler
|
| -} // namespace protobuf
|
| +// proto_cast<> is used to simulate over-the-wire conversion of one
|
| +// proto message into another. This is primarily useful for unit tests
|
| +// which validate the version-compatibility semantics of protobufs.
|
| +// Usage is similar to C++-style typecasts:
|
| +//
|
| +// OldMessage old_message = /*...*/;
|
| +// NewMessage new_message = proto_cast<NewMessage>(old_message);
|
| +namespace google {
|
| +template<typename NewProto,
|
| + typename OldProto>
|
| +NewProto proto_cast(const OldProto& old_proto) {
|
| + string wire_format;
|
| + GOOGLE_CHECK(old_proto.SerializeToString(&wire_format));
|
|
|
| + NewProto new_proto;
|
| + GOOGLE_CHECK(new_proto.ParseFromString(wire_format));
|
| + return new_proto;
|
| +}
|
|
|
| } // namespace google
|
| -#endif // GOOGLE_PROTOBUF_COMPILER_CPP_OPTIONS_H__
|
| +#endif // GOOGLE_PROTOBUF_UTIL_PROTO_CAST_H__
|
|
|