12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- --- a/src/google/protobuf/message.cc (index)
- +++ b/src/google/protobuf/message.cc (working tree)
- @@ -146,6 +146,52 @@ uint8* Message::_InternalSerialize(uint8* target,
- return WireFormat::_InternalSerialize(*this, target, stream);
- }
-
- +// Yandex-specific
- +void Message::PrintJSON(IOutputStream& out) const {
- + out << "(Something went wrong: no PrintJSON() override provided - are you using a non-styleguided .pb.h?)";
- +}
- +
- +bool Message::ParseFromArcadiaStream(IInputStream* input) {
- + bool res = false;
- + io::TInputStreamProxy proxy(input);
- + {
- + io::CopyingInputStreamAdaptor stream(&proxy);
- + res = ParseFromZeroCopyStream(&stream);
- + }
- + return res && !proxy.HasError();
- +}
- +
- +bool Message::ParsePartialFromArcadiaStream(IInputStream* input) {
- + bool res = false;
- + io::TInputStreamProxy proxy(input);
- + {
- + io::CopyingInputStreamAdaptor stream(&proxy);
- + res = ParsePartialFromZeroCopyStream(&stream);
- + }
- + return res && !proxy.HasError();
- +}
- +
- +bool Message::SerializeToArcadiaStream(IOutputStream* output) const {
- + bool res = false;
- + io::TOutputStreamProxy proxy(output);
- + {
- + io::CopyingOutputStreamAdaptor stream(&proxy);
- + res = SerializeToZeroCopyStream(&stream);
- + }
- + return res && !proxy.HasError();
- +}
- +
- +bool Message::SerializePartialToArcadiaStream(IOutputStream* output) const {
- + bool res = false;
- + io::TOutputStreamProxy proxy(output);
- + {
- + io::CopyingOutputStreamAdaptor stream(&proxy);
- + res = SerializePartialToZeroCopyStream(&stream);
- + }
- + return res && !proxy.HasError();
- +}
- +// End of Yandex-specific
- +
- size_t Message::ByteSizeLong() const {
- size_t size = WireFormat::ByteSize(*this);
- SetCachedSize(internal::ToCachedSize(size));
- --- a/src/google/protobuf/message.h (index)
- +++ b/src/google/protobuf/message.h (working tree)
- @@ -126,6 +126,8 @@
- #include "google/protobuf/generated_message_reflection.h"
- #include "google/protobuf/generated_message_tctable_decl.h"
- #include "google/protobuf/generated_message_util.h"
- +#include <google/protobuf/json_util.h>
- +#include <google/protobuf/messagext.h>
- #include "google/protobuf/map.h" // TODO(b/211442718): cleanup
- #include "google/protobuf/message_lite.h"
- #include "google/protobuf/port.h"
- @@ -341,6 +341,27 @@ class PROTOBUF_EXPORT Message : public MessageLite {
- uint8_t* _InternalSerialize(uint8_t* target,
- io::EpsCopyOutputStream* stream) const override;
- + // Yandex-specific
- + bool ParseFromArcadiaStream(IInputStream* input);
- + bool ParsePartialFromArcadiaStream(IInputStream* input);
- + bool SerializeToArcadiaStream(IOutputStream* output) const;
- + bool SerializePartialToArcadiaStream(IOutputStream* output) const;
- +
- + virtual void PrintJSON(IOutputStream&) const;
- +
- + io::TAsJSON<Message> AsJSON() const {
- + return io::TAsJSON<Message>(*this);
- + }
- +
- + internal::TAsBinary AsBinary() const {
- + return internal::TAsBinary{*this};
- + }
- +
- + internal::TAsStreamSeq AsStreamSeq() const {
- + return internal::TAsStreamSeq{*this};
- + }
- + // End of Yandex-specific
- +
- private:
- // This is called only by the default implementation of ByteSize(), to
- // update the cached size. If you override ByteSize(), you do not need
|