1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
--- 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
|