protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc
Go to the documentation of this file.
1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved.
3 // https://developers.google.com/protocol-buffers/
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 // * Redistributions in binary form must reproduce the above
12 // copyright notice, this list of conditions and the following disclaimer
13 // in the documentation and/or other materials provided with the
14 // distribution.
15 // * Neither the name of Google Inc. nor the names of its
16 // contributors may be used to endorse or promote products derived from
17 // this software without specific prior written permission.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 #include <google/protobuf/util/internal/protostream_objectsource.h>
32 
33 #include <cstdint>
34 #include <unordered_map>
35 #include <utility>
36 
37 #include <google/protobuf/stubs/logging.h>
38 #include <google/protobuf/stubs/common.h>
39 #include <google/protobuf/stubs/stringprintf.h>
40 #include <google/protobuf/io/coded_stream.h>
41 #include <google/protobuf/io/zero_copy_stream_impl.h>
42 #include <google/protobuf/descriptor.h>
43 #include <google/protobuf/stubs/once.h>
44 #include <google/protobuf/unknown_field_set.h>
45 #include <google/protobuf/wire_format.h>
46 #include <google/protobuf/wire_format_lite.h>
47 #include <google/protobuf/util/internal/field_mask_utility.h>
48 #include <google/protobuf/util/internal/constants.h>
49 #include <google/protobuf/util/internal/utility.h>
50 #include <google/protobuf/stubs/strutil.h>
51 #include <google/protobuf/stubs/casts.h>
52 #include <google/protobuf/stubs/status.h>
53 #include <google/protobuf/stubs/time.h>
54 #include <google/protobuf/stubs/map_util.h>
55 #include <google/protobuf/stubs/status_macros.h>
56 
57 
58 #include <google/protobuf/port_def.inc>
59 
60 namespace google {
61 namespace protobuf {
62 namespace util {
63 namespace converter {
64 
65 using ::PROTOBUF_NAMESPACE_ID::internal::WireFormat;
66 using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
67 
68 namespace {
69 
70 static int kDefaultMaxRecursionDepth = 64;
71 
72 // Finds a field with the given number. nullptr if none found.
73 const google::protobuf::Field* FindFieldByNumber(
74  const google::protobuf::Type& type, int number);
75 
76 // Returns true if the field is packable.
77 bool IsPackable(const google::protobuf::Field& field);
78 
79 // Finds an enum value with the given number. nullptr if none found.
80 const google::protobuf::EnumValue* FindEnumValueByNumber(
81  const google::protobuf::Enum& tech_enum, int number);
82 
83 // Utility function to format nanos.
84 const std::string FormatNanos(uint32_t nanos, bool with_trailing_zeros);
85 
86 util::StatusOr<std::string> MapKeyDefaultValueAsString(
88  switch (field.kind()) {
89  case google::protobuf::Field::TYPE_BOOL:
90  return std::string("false");
91  case google::protobuf::Field::TYPE_INT32:
92  case google::protobuf::Field::TYPE_INT64:
93  case google::protobuf::Field::TYPE_UINT32:
94  case google::protobuf::Field::TYPE_UINT64:
95  case google::protobuf::Field::TYPE_SINT32:
96  case google::protobuf::Field::TYPE_SINT64:
97  case google::protobuf::Field::TYPE_SFIXED32:
98  case google::protobuf::Field::TYPE_SFIXED64:
99  case google::protobuf::Field::TYPE_FIXED32:
100  case google::protobuf::Field::TYPE_FIXED64:
101  return std::string("0");
102  case google::protobuf::Field::TYPE_STRING:
103  return std::string();
104  default:
105  return util::InternalError("Invalid map key type.");
106  }
107 }
108 } // namespace
109 
110 
113  const google::protobuf::Type& type, const RenderOptions& render_options)
114  : stream_(stream),
115  typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),
116  own_typeinfo_(true),
117  type_(type),
118  render_options_(render_options),
119  recursion_depth_(0),
120  max_recursion_depth_(kDefaultMaxRecursionDepth) {
121  GOOGLE_LOG_IF(DFATAL, stream == nullptr) << "Input stream is nullptr.";
122 }
123 
125  io::CodedInputStream* stream, const TypeInfo* typeinfo,
126  const google::protobuf::Type& type, const RenderOptions& render_options)
127  : stream_(stream),
128  typeinfo_(typeinfo),
129  own_typeinfo_(false),
130  type_(type),
131  render_options_(render_options),
132  recursion_depth_(0),
133  max_recursion_depth_(kDefaultMaxRecursionDepth) {
134  GOOGLE_LOG_IF(DFATAL, stream == nullptr) << "Input stream is nullptr.";
135 }
136 
138  if (own_typeinfo_) {
139  delete typeinfo_;
140  }
141 }
142 
144  ObjectWriter* ow) const {
145  return WriteMessage(type_, name, 0, true, ow);
146 }
147 
149  const google::protobuf::Type& type, uint32_t tag) const {
150  // Lookup the new field in the type by tag number.
151  const google::protobuf::Field* field = FindFieldByNumber(type, tag >> 3);
152  // Verify if the field corresponds to the wire type in tag.
153  // If there is any discrepancy, mark the field as not found.
154  if (field != nullptr) {
155  WireFormatLite::WireType expected_type =
157  static_cast<WireFormatLite::FieldType>(field->kind()));
159  if (actual_type != expected_type &&
160  (!IsPackable(*field) ||
162  field = nullptr;
163  }
164  }
165  return field;
166 }
167 
169  const google::protobuf::Type& type, StringPiece name,
170  const uint32_t end_tag, bool include_start_and_end,
171  ObjectWriter* ow) const {
172 
173  const TypeRenderer* type_renderer = FindTypeRenderer(type.name());
174  if (type_renderer != nullptr) {
175  return (*type_renderer)(this, type, name, ow);
176  }
177 
178  const google::protobuf::Field* field = nullptr;
179  std::string field_name;
180  // last_tag set to dummy value that is different from tag.
181  uint32_t tag = stream_->ReadTag(), last_tag = tag + 1;
182  UnknownFieldSet unknown_fields;
183 
184 
185  if (include_start_and_end) {
186  ow->StartObject(name);
187  }
188  while (tag != end_tag && tag != 0) {
189  if (tag != last_tag) { // Update field only if tag is changed.
190  last_tag = tag;
192  if (field != nullptr) {
194  field_name = field->name();
195  } else {
196  field_name = field->json_name();
197  }
198  }
199  }
200  if (field == nullptr) {
201  // If we didn't find a field, skip this unknown tag.
202  // TODO(wpoon): Check return boolean value.
204  stream_, tag,
205  nullptr);
206  tag = stream_->ReadTag();
207  continue;
208  }
209 
210  if (field->cardinality() == google::protobuf::Field::CARDINALITY_REPEATED) {
211  if (IsMap(*field)) {
212  ow->StartObject(field_name);
213  ASSIGN_OR_RETURN(tag, RenderMap(field, field_name, tag, ow));
214  ow->EndObject();
215  } else {
216  ASSIGN_OR_RETURN(tag, RenderList(field, field_name, tag, ow));
217  }
218  } else {
219  // Render the field.
220  RETURN_IF_ERROR(RenderField(field, field_name, ow));
221  tag = stream_->ReadTag();
222  }
223  }
224 
225 
226  if (include_start_and_end) {
227  ow->EndObject();
228  }
229  return util::Status();
230 }
231 
232 util::StatusOr<uint32_t> ProtoStreamObjectSource::RenderList(
233  const google::protobuf::Field* field, StringPiece name,
234  uint32_t list_tag, ObjectWriter* ow) const {
235  uint32_t tag_to_return = 0;
236  ow->StartList(name);
237  if (IsPackable(*field) &&
238  list_tag ==
239  WireFormatLite::MakeTag(field->number(),
242  // Since packed fields have a single tag, read another tag from stream to
243  // return.
244  tag_to_return = stream_->ReadTag();
245  } else {
246  do {
248  } while ((tag_to_return = stream_->ReadTag()) == list_tag);
249  }
250  ow->EndList();
251  return tag_to_return;
252 }
253 
254 util::StatusOr<uint32_t> ProtoStreamObjectSource::RenderMap(
255  const google::protobuf::Field* field, StringPiece /* name */,
256  uint32_t list_tag, ObjectWriter* ow) const {
258  typeinfo_->GetTypeByTypeUrl(field->type_url());
259  uint32_t tag_to_return = 0;
260  do {
261  // Render map entry message type.
262  uint32_t buffer32;
263  stream_->ReadVarint32(&buffer32); // message length
264  int old_limit = stream_->PushLimit(buffer32);
265  std::string map_key;
266  for (uint32_t tag = stream_->ReadTag(); tag != 0;
267  tag = stream_->ReadTag()) {
268  const google::protobuf::Field* map_entry_field =
270  if (map_entry_field == nullptr) {
271  WireFormat::SkipField(stream_, tag, nullptr);
272  continue;
273  }
274  // Map field numbers are key = 1 and value = 2
275  if (map_entry_field->number() == 1) {
276  map_key = ReadFieldValueAsString(*map_entry_field);
277  } else if (map_entry_field->number() == 2) {
278  if (map_key.empty()) {
279  // An absent map key is treated as the default.
280  const google::protobuf::Field* key_field =
281  FindFieldByNumber(*field_type, 1);
282  if (key_field == nullptr) {
283  // The Type info for this map entry is incorrect. It should always
284  // have a field named "key" and with field number 1.
285  return util::InternalError("Invalid map entry.");
286  }
287  ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field));
288  }
289  RETURN_IF_ERROR(RenderField(map_entry_field, map_key, ow));
290  } else {
291  // The Type info for this map entry is incorrect. It should contain
292  // exactly two fields with field number 1 and 2.
293  return util::InternalError("Invalid map entry.");
294  }
295  }
296  stream_->PopLimit(old_limit);
297  } while ((tag_to_return = stream_->ReadTag()) == list_tag);
298  return tag_to_return;
299 }
300 
302  const google::protobuf::Field* field, ObjectWriter* ow) const {
305  int old_limit = stream_->PushLimit(length);
306  while (stream_->BytesUntilLimit() > 0) {
307  RETURN_IF_ERROR(RenderField(field, StringPiece(), ow));
308  }
309  stream_->PopLimit(old_limit);
310  return util::Status();
311 }
312 
314  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
315  StringPiece field_name, ObjectWriter* ow) {
316  std::pair<int64_t, int32_t> p = os->ReadSecondsAndNanos(type);
317  int64_t seconds = p.first;
318  int32_t nanos = p.second;
321  "Timestamp seconds exceeds limit for field: ", field_name));
322  }
323 
324  if (nanos < 0 || nanos >= kNanosPerSecond) {
325  return util::InternalError(
326  StrCat("Timestamp nanos exceeds limit for field: ", field_name));
327  }
328 
329  ow->RenderString(field_name,
331 
332  return util::Status();
333 }
334 
336  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
337  StringPiece field_name, ObjectWriter* ow) {
338  std::pair<int64_t, int32_t> p = os->ReadSecondsAndNanos(type);
339  int64_t seconds = p.first;
340  int32_t nanos = p.second;
342  return util::InternalError(
343  StrCat("Duration seconds exceeds limit for field: ", field_name));
344  }
345 
346  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
347  return util::InternalError(
348  StrCat("Duration nanos exceeds limit for field: ", field_name));
349  }
350 
351  std::string sign = "";
352  if (seconds < 0) {
353  if (nanos > 0) {
354  return util::InternalError(
355  StrCat("Duration nanos is non-negative, but seconds is "
356  "negative for field: ",
357  field_name));
358  }
359  sign = "-";
360  seconds = -seconds;
361  nanos = -nanos;
362  } else if (seconds == 0 && nanos < 0) {
363  sign = "-";
364  nanos = -nanos;
365  }
366  std::string formatted_duration = StringPrintf(
367  "%s%lld%ss", sign.c_str(), static_cast<long long>(seconds), // NOLINT
368  FormatNanos(
369  nanos,
370  false
371  )
372  .c_str());
373  ow->RenderString(field_name, formatted_duration);
374  return util::Status();
375 }
376 
378  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
379  StringPiece field_name, ObjectWriter* ow) {
380  uint32_t tag = os->stream_->ReadTag();
381  uint64_t buffer64 = 0; // default value of Double wrapper value
382  if (tag != 0) {
383  os->stream_->ReadLittleEndian64(&buffer64);
384  os->stream_->ReadTag();
385  }
386  ow->RenderDouble(field_name, bit_cast<double>(buffer64));
387  return util::Status();
388 }
389 
391  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
392  StringPiece field_name, ObjectWriter* ow) {
393  uint32_t tag = os->stream_->ReadTag();
394  uint32_t buffer32 = 0; // default value of Float wrapper value
395  if (tag != 0) {
396  os->stream_->ReadLittleEndian32(&buffer32);
397  os->stream_->ReadTag();
398  }
399  ow->RenderFloat(field_name, bit_cast<float>(buffer32));
400  return util::Status();
401 }
402 
404  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
405  StringPiece field_name, ObjectWriter* ow) {
406  uint32_t tag = os->stream_->ReadTag();
407  uint64_t buffer64 = 0; // default value of Int64 wrapper value
408  if (tag != 0) {
409  os->stream_->ReadVarint64(&buffer64);
410  os->stream_->ReadTag();
411  }
412  ow->RenderInt64(field_name, bit_cast<int64_t>(buffer64));
413  return util::Status();
414 }
415 
417  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
418  StringPiece field_name, ObjectWriter* ow) {
419  uint32_t tag = os->stream_->ReadTag();
420  uint64_t buffer64 = 0; // default value of UInt64 wrapper value
421  if (tag != 0) {
422  os->stream_->ReadVarint64(&buffer64);
423  os->stream_->ReadTag();
424  }
425  ow->RenderUint64(field_name, bit_cast<uint64_t>(buffer64));
426  return util::Status();
427 }
428 
430  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
431  StringPiece field_name, ObjectWriter* ow) {
432  uint32_t tag = os->stream_->ReadTag();
433  uint32_t buffer32 = 0; // default value of Int32 wrapper value
434  if (tag != 0) {
435  os->stream_->ReadVarint32(&buffer32);
436  os->stream_->ReadTag();
437  }
438  ow->RenderInt32(field_name, bit_cast<int32_t>(buffer32));
439  return util::Status();
440 }
441 
443  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
444  StringPiece field_name, ObjectWriter* ow) {
445  uint32_t tag = os->stream_->ReadTag();
446  uint32_t buffer32 = 0; // default value of UInt32 wrapper value
447  if (tag != 0) {
448  os->stream_->ReadVarint32(&buffer32);
449  os->stream_->ReadTag();
450  }
451  ow->RenderUint32(field_name, bit_cast<uint32_t>(buffer32));
452  return util::Status();
453 }
454 
456  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
457  StringPiece field_name, ObjectWriter* ow) {
458  uint32_t tag = os->stream_->ReadTag();
459  uint64_t buffer64 = 0; // results in 'false' value as default, which is the
460  // default value of Bool wrapper
461  if (tag != 0) {
462  os->stream_->ReadVarint64(&buffer64);
463  os->stream_->ReadTag();
464  }
465  ow->RenderBool(field_name, buffer64 != 0);
466  return util::Status();
467 }
468 
470  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
471  StringPiece field_name, ObjectWriter* ow) {
472  uint32_t tag = os->stream_->ReadTag();
473  uint32_t buffer32;
474  std::string str; // default value of empty for String wrapper
475  if (tag != 0) {
476  os->stream_->ReadVarint32(&buffer32); // string size.
477  os->stream_->ReadString(&str, buffer32);
478  os->stream_->ReadTag();
479  }
480  ow->RenderString(field_name, str);
481  return util::Status();
482 }
483 
485  const ProtoStreamObjectSource* os, const google::protobuf::Type& /*type*/,
486  StringPiece field_name, ObjectWriter* ow) {
487  uint32_t tag = os->stream_->ReadTag();
488  uint32_t buffer32;
490  if (tag != 0) {
491  os->stream_->ReadVarint32(&buffer32);
492  os->stream_->ReadString(&str, buffer32);
493  os->stream_->ReadTag();
494  }
495  ow->RenderBytes(field_name, str);
496  return util::Status();
497 }
498 
500  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
501  StringPiece field_name, ObjectWriter* ow) {
502  const google::protobuf::Field* field = nullptr;
503  uint32_t tag = os->stream_->ReadTag();
504  ow->StartObject(field_name);
505  while (tag != 0) {
506  field = os->FindAndVerifyField(type, tag);
507  if (field == nullptr) {
508  WireFormat::SkipField(os->stream_, tag, nullptr);
509  tag = os->stream_->ReadTag();
510  continue;
511  }
512  // google.protobuf.Struct has only one field that is a map. Hence we use
513  // RenderMap to render that field.
514  if (os->IsMap(*field)) {
515  ASSIGN_OR_RETURN(tag, os->RenderMap(field, field_name, tag, ow));
516  }
517  }
518  ow->EndObject();
519  return util::Status();
520 }
521 
523  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
524  StringPiece field_name, ObjectWriter* ow) {
525  const google::protobuf::Field* field = nullptr;
526  for (uint32_t tag = os->stream_->ReadTag(); tag != 0;
527  tag = os->stream_->ReadTag()) {
528  field = os->FindAndVerifyField(type, tag);
529  if (field == nullptr) {
530  WireFormat::SkipField(os->stream_, tag, nullptr);
531  continue;
532  }
533  RETURN_IF_ERROR(os->RenderField(field, field_name, ow));
534  }
535  return util::Status();
536 }
537 
538 // TODO(skarvaje): Avoid code duplication of for loops and SkipField logic.
540  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
541  StringPiece field_name, ObjectWriter* ow) {
542  uint32_t tag = os->stream_->ReadTag();
543 
544  // Render empty list when we find empty ListValue message.
545  if (tag == 0) {
546  ow->StartList(field_name);
547  ow->EndList();
548  return util::Status();
549  }
550 
551  while (tag != 0) {
552  const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);
553  if (field == nullptr) {
554  WireFormat::SkipField(os->stream_, tag, nullptr);
555  tag = os->stream_->ReadTag();
556  continue;
557  }
558  ASSIGN_OR_RETURN(tag, os->RenderList(field, field_name, tag, ow));
559  }
560  return util::Status();
561 }
562 
564  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
565  StringPiece field_name, ObjectWriter* ow) {
566  // An Any is of the form { string type_url = 1; bytes value = 2; }
567  uint32_t tag;
570 
571  // First read out the type_url and value from the proto stream
572  for (tag = os->stream_->ReadTag(); tag != 0; tag = os->stream_->ReadTag()) {
573  const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);
574  if (field == nullptr) {
575  WireFormat::SkipField(os->stream_, tag, nullptr);
576  continue;
577  }
578  // 'type_url' has field number of 1 and 'value' has field number 2
579  // //google/protobuf/any.proto
580  if (field->number() == 1) {
581  // read type_url
582  uint32_t type_url_size;
583  os->stream_->ReadVarint32(&type_url_size);
584  os->stream_->ReadString(&type_url, type_url_size);
585  } else if (field->number() == 2) {
586  // read value
587  uint32_t value_size;
588  os->stream_->ReadVarint32(&value_size);
589  os->stream_->ReadString(&value, value_size);
590  }
591  }
592 
593  // If there is no value, we don't lookup the type, we just output it (if
594  // present). If both type and value are empty we output an empty object.
595  if (value.empty()) {
596  ow->StartObject(field_name);
597  if (!type_url.empty()) {
598  ow->RenderString("@type", type_url);
599  }
600  ow->EndObject();
601  return util::Status();
602  }
603 
604  // If there is a value but no type, we cannot render it, so report an error.
605  if (type_url.empty()) {
606  // TODO(sven): Add an external message once those are ready.
607  return util::InternalError("Invalid Any, the type_url is missing.");
608  }
609 
610  util::StatusOr<const google::protobuf::Type*> resolved_type =
611  os->typeinfo_->ResolveTypeUrl(type_url);
612 
613  if (!resolved_type.ok()) {
614  // Convert into an internal error, since this means the backend gave us
615  // an invalid response (missing or invalid type information).
616  return util::InternalError(resolved_type.status().message());
617  }
618  // nested_type cannot be null at this time.
619  const google::protobuf::Type* nested_type = resolved_type.value();
620 
621  io::ArrayInputStream zero_copy_stream(value.data(), value.size());
622  io::CodedInputStream in_stream(&zero_copy_stream);
623  // We know the type so we can render it. Recursively parse the nested stream
624  // using a nested ProtoStreamObjectSource using our nested type information.
625  ProtoStreamObjectSource nested_os(&in_stream, os->typeinfo_, *nested_type,
626  os->render_options_);
627 
628  // We manually call start and end object here so we can inject the @type.
629  ow->StartObject(field_name);
630  ow->RenderString("@type", type_url);
632  nested_os.WriteMessage(nested_os.type_, "value", 0, false, ow);
633  ow->EndObject();
634  return result;
635 }
636 
638  const ProtoStreamObjectSource* os, const google::protobuf::Type& type,
639  StringPiece field_name, ObjectWriter* ow) {
640  std::string combined;
641  uint32_t buffer32;
642  uint32_t paths_field_tag = 0;
643  for (uint32_t tag = os->stream_->ReadTag(); tag != 0;
644  tag = os->stream_->ReadTag()) {
645  if (paths_field_tag == 0) {
646  const google::protobuf::Field* field = os->FindAndVerifyField(type, tag);
647  if (field != nullptr && field->number() == 1 &&
648  field->name() == "paths") {
649  paths_field_tag = tag;
650  }
651  }
652  if (paths_field_tag != tag) {
653  return util::InternalError("Invalid FieldMask, unexpected field.");
654  }
656  os->stream_->ReadVarint32(&buffer32); // string size.
657  os->stream_->ReadString(&str, buffer32);
658  if (!combined.empty()) {
659  combined.append(",");
660  }
661  combined.append(ConvertFieldMaskPath(str, &ToCamelCase));
662  }
663  ow->RenderString(field_name, combined);
664  return util::Status();
665 }
666 
667 
668 std::unordered_map<std::string, ProtoStreamObjectSource::TypeRenderer>*
671 
672 
674  renderers_ = new std::unordered_map<std::string,
676  (*renderers_)["google.protobuf.Timestamp"] =
678  (*renderers_)["google.protobuf.Duration"] =
680  (*renderers_)["google.protobuf.DoubleValue"] =
682  (*renderers_)["google.protobuf.FloatValue"] =
684  (*renderers_)["google.protobuf.Int64Value"] =
686  (*renderers_)["google.protobuf.UInt64Value"] =
688  (*renderers_)["google.protobuf.Int32Value"] =
690  (*renderers_)["google.protobuf.UInt32Value"] =
692  (*renderers_)["google.protobuf.BoolValue"] =
694  (*renderers_)["google.protobuf.StringValue"] =
696  (*renderers_)["google.protobuf.BytesValue"] =
698  (*renderers_)["google.protobuf.Any"] = &ProtoStreamObjectSource::RenderAny;
699  (*renderers_)["google.protobuf.Struct"] =
701  (*renderers_)["google.protobuf.Value"] =
703  (*renderers_)["google.protobuf.ListValue"] =
705  (*renderers_)["google.protobuf.FieldMask"] =
708 }
709 
712  renderers_ = nullptr;
713 }
714 
715 // static
720  return FindOrNull(*renderers_, type_url);
721 }
722 
724  const google::protobuf::Field* field, StringPiece field_name,
725  ObjectWriter* ow) const {
726  // Short-circuit message types as it tends to call WriteMessage recursively
727  // and ends up using a lot of stack space. Keep the stack usage of this
728  // message small in order to preserve stack space and not crash.
729  if (field->kind() == google::protobuf::Field::TYPE_MESSAGE) {
730  uint32_t buffer32;
731  stream_->ReadVarint32(&buffer32); // message length
732  int old_limit = stream_->PushLimit(buffer32);
733  // Get the nested message type for this field.
735  typeinfo_->GetTypeByTypeUrl(field->type_url());
736  if (type == nullptr) {
737  return util::InternalError(
738  StrCat("Invalid configuration. Could not find the type: ",
739  field->type_url()));
740  }
741 
742  // Short-circuit any special type rendering to save call-stack space.
743  const TypeRenderer* type_renderer = FindTypeRenderer(type->name());
744 
745  RETURN_IF_ERROR(IncrementRecursionDepth(type->name(), field_name));
746  if (type_renderer != nullptr) {
747  RETURN_IF_ERROR((*type_renderer)(this, *type, field_name, ow));
748  } else {
749  RETURN_IF_ERROR(WriteMessage(*type, field_name, 0, true, ow));
750  }
752 
753  if (!stream_->ConsumedEntireMessage()) {
755  "Nested protocol message not parsed in its entirety.");
756  }
757  stream_->PopLimit(old_limit);
758  } else {
759  // Render all other non-message types.
760  return RenderNonMessageField(field, field_name, ow);
761  }
762  return util::Status();
763 }
764 
766  const google::protobuf::Field* field, StringPiece field_name,
767  ObjectWriter* ow) const {
768  // Temporary buffers of different types.
769  uint32_t buffer32 = 0;
770  uint64_t buffer64 = 0;
771  std::string strbuffer;
772  switch (field->kind()) {
773  case google::protobuf::Field::TYPE_BOOL: {
774  stream_->ReadVarint64(&buffer64);
775  ow->RenderBool(field_name, buffer64 != 0);
776  break;
777  }
778  case google::protobuf::Field::TYPE_INT32: {
779  stream_->ReadVarint32(&buffer32);
780  ow->RenderInt32(field_name, bit_cast<int32_t>(buffer32));
781  break;
782  }
783  case google::protobuf::Field::TYPE_INT64: {
784  stream_->ReadVarint64(&buffer64);
785  ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
786  break;
787  }
788  case google::protobuf::Field::TYPE_UINT32: {
789  stream_->ReadVarint32(&buffer32);
790  ow->RenderUint32(field_name, bit_cast<uint32_t>(buffer32));
791  break;
792  }
793  case google::protobuf::Field::TYPE_UINT64: {
794  stream_->ReadVarint64(&buffer64);
795  ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
796  break;
797  }
798  case google::protobuf::Field::TYPE_SINT32: {
799  stream_->ReadVarint32(&buffer32);
800  ow->RenderInt32(field_name, WireFormatLite::ZigZagDecode32(buffer32));
801  break;
802  }
803  case google::protobuf::Field::TYPE_SINT64: {
804  stream_->ReadVarint64(&buffer64);
805  ow->RenderInt64(field_name, WireFormatLite::ZigZagDecode64(buffer64));
806  break;
807  }
808  case google::protobuf::Field::TYPE_SFIXED32: {
809  stream_->ReadLittleEndian32(&buffer32);
810  ow->RenderInt32(field_name, bit_cast<int32_t>(buffer32));
811  break;
812  }
813  case google::protobuf::Field::TYPE_SFIXED64: {
814  stream_->ReadLittleEndian64(&buffer64);
815  ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
816  break;
817  }
818  case google::protobuf::Field::TYPE_FIXED32: {
819  stream_->ReadLittleEndian32(&buffer32);
820  ow->RenderUint32(field_name, bit_cast<uint32_t>(buffer32));
821  break;
822  }
823  case google::protobuf::Field::TYPE_FIXED64: {
824  stream_->ReadLittleEndian64(&buffer64);
825  ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
826  break;
827  }
828  case google::protobuf::Field::TYPE_FLOAT: {
829  stream_->ReadLittleEndian32(&buffer32);
830  ow->RenderFloat(field_name, bit_cast<float>(buffer32));
831  break;
832  }
833  case google::protobuf::Field::TYPE_DOUBLE: {
834  stream_->ReadLittleEndian64(&buffer64);
835  ow->RenderDouble(field_name, bit_cast<double>(buffer64));
836  break;
837  }
838  case google::protobuf::Field::TYPE_ENUM: {
839  stream_->ReadVarint32(&buffer32);
840 
841  // If the field represents an explicit NULL value, render null.
842  if (field->type_url() == kStructNullValueTypeUrl) {
843  ow->RenderNull(field_name);
844  break;
845  }
846 
847  // Get the nested enum type for this field.
848  // TODO(skarvaje): Avoid string manipulation. Find ways to speed this
849  // up.
850  const google::protobuf::Enum* en =
851  typeinfo_->GetEnumByTypeUrl(field->type_url());
852  // Lookup the name of the enum, and render that. Unknown enum values
853  // are printed as integers.
854  if (en != nullptr) {
855  const google::protobuf::EnumValue* enum_value =
856  FindEnumValueByNumber(*en, buffer32);
857  if (enum_value != nullptr) {
859  ow->RenderInt32(field_name, buffer32);
861  ow->RenderString(field_name,
862  EnumValueNameToLowerCamelCase(enum_value->name()));
863  } else {
864  ow->RenderString(field_name, enum_value->name());
865  }
866  } else {
867  ow->RenderInt32(field_name, buffer32);
868  }
869  } else {
870  ow->RenderInt32(field_name, buffer32);
871  }
872  break;
873  }
874  case google::protobuf::Field::TYPE_STRING: {
875  stream_->ReadVarint32(&buffer32); // string size.
876  stream_->ReadString(&strbuffer, buffer32);
877  ow->RenderString(field_name, strbuffer);
878  break;
879  }
880  case google::protobuf::Field::TYPE_BYTES: {
881  stream_->ReadVarint32(&buffer32); // bytes size.
882  stream_->ReadString(&strbuffer, buffer32);
883  ow->RenderBytes(field_name, strbuffer);
884  break;
885  }
886  default:
887  break;
888  }
889  return util::Status();
890 }
891 
892 // TODO(skarvaje): Fix this to avoid code duplication.
894  const google::protobuf::Field& field) const {
896  switch (field.kind()) {
897  case google::protobuf::Field::TYPE_BOOL: {
898  uint64_t buffer64;
899  stream_->ReadVarint64(&buffer64);
900  result = buffer64 != 0 ? "true" : "false";
901  break;
902  }
903  case google::protobuf::Field::TYPE_INT32: {
904  uint32_t buffer32;
905  stream_->ReadVarint32(&buffer32);
906  result = StrCat(bit_cast<int32_t>(buffer32));
907  break;
908  }
909  case google::protobuf::Field::TYPE_INT64: {
910  uint64_t buffer64;
911  stream_->ReadVarint64(&buffer64);
912  result = StrCat(bit_cast<int64_t>(buffer64));
913  break;
914  }
915  case google::protobuf::Field::TYPE_UINT32: {
916  uint32_t buffer32;
917  stream_->ReadVarint32(&buffer32);
918  result = StrCat(bit_cast<uint32_t>(buffer32));
919  break;
920  }
921  case google::protobuf::Field::TYPE_UINT64: {
922  uint64_t buffer64;
923  stream_->ReadVarint64(&buffer64);
924  result = StrCat(bit_cast<uint64_t>(buffer64));
925  break;
926  }
927  case google::protobuf::Field::TYPE_SINT32: {
928  uint32_t buffer32;
929  stream_->ReadVarint32(&buffer32);
931  break;
932  }
933  case google::protobuf::Field::TYPE_SINT64: {
934  uint64_t buffer64;
935  stream_->ReadVarint64(&buffer64);
937  break;
938  }
939  case google::protobuf::Field::TYPE_SFIXED32: {
940  uint32_t buffer32;
941  stream_->ReadLittleEndian32(&buffer32);
942  result = StrCat(bit_cast<int32_t>(buffer32));
943  break;
944  }
945  case google::protobuf::Field::TYPE_SFIXED64: {
946  uint64_t buffer64;
947  stream_->ReadLittleEndian64(&buffer64);
948  result = StrCat(bit_cast<int64_t>(buffer64));
949  break;
950  }
951  case google::protobuf::Field::TYPE_FIXED32: {
952  uint32_t buffer32;
953  stream_->ReadLittleEndian32(&buffer32);
954  result = StrCat(bit_cast<uint32_t>(buffer32));
955  break;
956  }
957  case google::protobuf::Field::TYPE_FIXED64: {
958  uint64_t buffer64;
959  stream_->ReadLittleEndian64(&buffer64);
960  result = StrCat(bit_cast<uint64_t>(buffer64));
961  break;
962  }
963  case google::protobuf::Field::TYPE_FLOAT: {
964  uint32_t buffer32;
965  stream_->ReadLittleEndian32(&buffer32);
966  result = SimpleFtoa(bit_cast<float>(buffer32));
967  break;
968  }
969  case google::protobuf::Field::TYPE_DOUBLE: {
970  uint64_t buffer64;
971  stream_->ReadLittleEndian64(&buffer64);
972  result = SimpleDtoa(bit_cast<double>(buffer64));
973  break;
974  }
975  case google::protobuf::Field::TYPE_ENUM: {
976  uint32_t buffer32;
977  stream_->ReadVarint32(&buffer32);
978  // Get the nested enum type for this field.
979  // TODO(skarvaje): Avoid string manipulation. Find ways to speed this
980  // up.
981  const google::protobuf::Enum* en =
982  typeinfo_->GetEnumByTypeUrl(field.type_url());
983  // Lookup the name of the enum, and render that. Skips unknown enums.
984  if (en != nullptr) {
985  const google::protobuf::EnumValue* enum_value =
986  FindEnumValueByNumber(*en, buffer32);
987  if (enum_value != nullptr) {
988  result = enum_value->name();
989  }
990  }
991  break;
992  }
993  case google::protobuf::Field::TYPE_STRING: {
994  uint32_t buffer32;
995  stream_->ReadVarint32(&buffer32); // string size.
996  stream_->ReadString(&result, buffer32);
997  break;
998  }
999  case google::protobuf::Field::TYPE_BYTES: {
1000  uint32_t buffer32;
1001  stream_->ReadVarint32(&buffer32); // bytes size.
1002  stream_->ReadString(&result, buffer32);
1003  break;
1004  }
1005  default:
1006  break;
1007  }
1008  return result;
1009 }
1010 
1011 // Field is a map if it is a repeated message and it has an option "map_type".
1012 // TODO(skarvaje): Consider pre-computing the IsMap() into Field directly.
1014  const google::protobuf::Field& field) const {
1016  typeinfo_->GetTypeByTypeUrl(field.type_url());
1017  return field.kind() == google::protobuf::Field::TYPE_MESSAGE &&
1019 }
1020 
1021 std::pair<int64_t, int32_t> ProtoStreamObjectSource::ReadSecondsAndNanos(
1022  const google::protobuf::Type& type) const {
1023  uint64_t seconds = 0;
1024  uint32_t nanos = 0;
1025  uint32_t tag = 0;
1026  int64_t signed_seconds = 0;
1027  int32_t signed_nanos = 0;
1028 
1029  for (tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) {
1031  if (field == nullptr) {
1032  WireFormat::SkipField(stream_, tag, nullptr);
1033  continue;
1034  }
1035  // 'seconds' has field number of 1 and 'nanos' has field number 2
1036  // //google/protobuf/timestamp.proto & duration.proto
1037  if (field->number() == 1) {
1038  // read seconds
1040  signed_seconds = bit_cast<int64_t>(seconds);
1041  } else if (field->number() == 2) {
1042  // read nanos
1043  stream_->ReadVarint32(&nanos);
1044  signed_nanos = bit_cast<int32_t>(nanos);
1045  }
1046  }
1047  return std::pair<int64_t, int32_t>(signed_seconds, signed_nanos);
1048 }
1049 
1051  StringPiece type_name, StringPiece field_name) const {
1054  StrCat("Message too deep. Max recursion depth reached for type '",
1055  type_name, "', field '", field_name, "'"));
1056  }
1057  return util::Status();
1058 }
1059 
1060 namespace {
1061 // TODO(skarvaje): Speed this up by not doing a linear scan.
1062 const google::protobuf::Field* FindFieldByNumber(
1063  const google::protobuf::Type& type, int number) {
1064  for (int i = 0; i < type.fields_size(); ++i) {
1065  if (type.fields(i).number() == number) {
1066  return &type.fields(i);
1067  }
1068  }
1069  return nullptr;
1070 }
1071 
1072 // TODO(skarvaje): Replace FieldDescriptor by implementing IsTypePackable()
1073 // using tech Field.
1074 bool IsPackable(const google::protobuf::Field& field) {
1075  return field.cardinality() == google::protobuf::Field::CARDINALITY_REPEATED &&
1077  static_cast<FieldDescriptor::Type>(field.kind()));
1078 }
1079 
1080 // TODO(skarvaje): Speed this up by not doing a linear scan.
1081 const google::protobuf::EnumValue* FindEnumValueByNumber(
1082  const google::protobuf::Enum& tech_enum, int number) {
1083  for (int i = 0; i < tech_enum.enumvalue_size(); ++i) {
1084  const google::protobuf::EnumValue& ev = tech_enum.enumvalue(i);
1085  if (ev.number() == number) {
1086  return &ev;
1087  }
1088  }
1089  return nullptr;
1090 }
1091 
1092 // TODO(skarvaje): Look into optimizing this by not doing computation on
1093 // double.
1094 const std::string FormatNanos(uint32_t nanos, bool with_trailing_zeros) {
1095  if (nanos == 0) {
1096  return with_trailing_zeros ? ".000" : "";
1097  }
1098 
1099  const char* format = (nanos % 1000 != 0) ? "%.9f"
1100  : (nanos % 1000000 != 0) ? "%.6f"
1101  : "%.3f";
1102  std::string formatted =
1103  StringPrintf(format, static_cast<double>(nanos) / kNanosPerSecond);
1104  // remove the leading 0 before decimal.
1105  return formatted.substr(1);
1106 }
1107 } // namespace
1108 
1109 } // namespace converter
1110 } // namespace util
1111 } // namespace protobuf
1112 } // namespace google
google::protobuf::FieldDescriptor::Type
Type
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:521
xds_interop_client.str
str
Definition: xds_interop_client.py:487
absl::InvalidArgumentError
Status InvalidArgumentError(absl::string_view message)
Definition: third_party/abseil-cpp/absl/status/status.cc:351
absl::time_internal::cctz::seconds
std::chrono::duration< std::int_fast64_t > seconds
Definition: abseil-cpp/absl/time/internal/cctz/include/cctz/time_zone.h:40
_gevent_test_main.result
result
Definition: _gevent_test_main.py:96
Type
struct Type Type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:673
google::protobuf.internal::WireFormatLite::WireTypeForFieldType
static WireFormatLite::WireType WireTypeForFieldType(WireFormatLite::FieldType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:152
http2_test_server.format
format
Definition: http2_test_server.py:118
google::protobuf::value
const Descriptor::ReservedRange value
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:1954
google::protobuf::util::converter::ProtoStreamObjectSource::RenderOptions::use_lower_camel_for_enums
bool use_lower_camel_for_enums
Definition: protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:106
google::protobuf::io::CodedInputStream::PopLimit
void PopLimit(Limit limit)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:137
google::protobuf::util::converter::ProtoStreamObjectSource::RenderOptions::preserve_proto_field_names
bool preserve_proto_field_names
Definition: protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:113
google::protobuf::util::converter::ToCamelCase
std::string ToCamelCase(const StringPiece input)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/utility.cc:250
google::protobuf::Enum
stream_
std::unique_ptr< grpc::ClientReaderInterface< OrcaLoadReport > > stream_
Definition: orca_service_end2end_test.cc:89
google::protobuf::util::converter::ProtoStreamObjectSource::typeinfo_
const TypeInfo * typeinfo_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:288
false
#define false
Definition: setup_once.h:323
google::protobuf::util::converter::TypeInfo::GetEnumByTypeUrl
virtual const google::protobuf::Enum * GetEnumByTypeUrl(StringPiece type_url) const =0
google::protobuf::util::converter::ProtoStreamObjectSource::RenderField
virtual util::Status RenderField(const google::protobuf::Field *field, StringPiece field_name, ObjectWriter *ow) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:760
google::protobuf.internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED
@ WIRETYPE_LENGTH_DELIMITED
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:104
google::protobuf::util::converter::ProtoStreamObjectSource::~ProtoStreamObjectSource
~ProtoStreamObjectSource() override
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:154
google::protobuf::util::converter::ProtoStreamObjectSource::own_typeinfo_
bool own_typeinfo_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:292
testing::internal::string
::std::string string
Definition: bloaty/third_party/protobuf/third_party/googletest/googletest/include/gtest/internal/gtest-port.h:881
type_
std::string type_
Definition: client_channel_stress_test.cc:212
google::protobuf::util::converter::ProtoStreamObjectSource::FindTypeRenderer
static TypeRenderer * FindTypeRenderer(const std::string &type_url)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:754
google::protobuf::util::converter::ProtoStreamObjectSource::RenderStructValue
static util::Status RenderStructValue(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:549
google::protobuf
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:12
make_cmakelists.converter
converter
Definition: make_cmakelists.py:317
setup.name
name
Definition: setup.py:542
absl::InternalError
Status InternalError(absl::string_view message)
Definition: third_party/abseil-cpp/absl/status/status.cc:347
xds_manager.p
p
Definition: xds_manager.py:60
type_resolver
TypeResolver * type_resolver
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:71
google::protobuf::util::converter::ProtoStreamObjectSource::RenderDouble
static util::Status RenderDouble(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:399
google::protobuf::util::converter::ProtoStreamObjectSource::ReadSecondsAndNanos
std::pair< int64, int32 > ReadSecondsAndNanos(const google::protobuf::Type &type) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:1060
google::protobuf::python::cmessage::UnknownFieldSet
static PyObject * UnknownFieldSet(CMessage *self)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/message.cc:2512
google::protobuf::util::converter::ProtoStreamObjectSource::RenderBytes
static util::Status RenderBytes(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:514
google::protobuf::EnumValue
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1482
true
#define true
Definition: setup_once.h:324
google::protobuf::util::converter::ProtoStreamObjectSource::TypeRenderer
util::Status(* TypeRenderer)(const ProtoStreamObjectSource *, const google::protobuf::Type &, StringPiece, ObjectWriter *)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:168
google::protobuf::util::converter::TypeInfo::GetTypeByTypeUrl
virtual const google::protobuf::Type * GetTypeByTypeUrl(StringPiece type_url) const =0
google::protobuf.internal::OnShutdown
void OnShutdown(void(*func)())
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/common.cc:344
google::protobuf::util::converter::kTimestampMaxSeconds
const int64 kTimestampMaxSeconds
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/internal/constants.h:56
google::protobuf.internal::WireFormatLite::MakeTag
constexpr static uint32 MakeTag(int field_number, WireType type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:783
google::protobuf::util::converter::ProtoStreamObjectSource::IsMap
bool IsMap(const google::protobuf::Field &field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:1052
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
absl::call_once
void call_once(absl::once_flag &flag, Callable &&fn, Args &&... args)
Definition: abseil-cpp/absl/base/call_once.h:206
google::protobuf::io::CodedInputStream::BytesUntilLimit
int BytesUntilLimit() const
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:172
google::protobuf::io::CodedInputStream::ReadLittleEndian64
bool ReadLittleEndian64(uint64 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1354
google::protobuf.internal::once_flag
std::once_flag once_flag
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/once.h:43
google::protobuf::util::converter::ProtoStreamObjectSource::RenderOptions
Definition: protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:78
int64_t
signed __int64 int64_t
Definition: stdint-msvc2008.h:89
gen_stats_data.c_str
def c_str(s, encoding='ascii')
Definition: gen_stats_data.py:38
tag
static void * tag(intptr_t t)
Definition: bad_client.cc:318
google::protobuf::util::converter::ProtoStreamObjectSource::render_options_
const RenderOptions render_options_
Definition: protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:310
google::protobuf::util::TypeResolver
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/type_resolver.h:52
google::protobuf::util::converter::ProtoStreamObjectSource::InitRendererMap
static void InitRendererMap()
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:710
google::protobuf::util::converter::ProtoStreamObjectSource::RenderAny
static util::Status RenderAny(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:590
google::protobuf::io::CodedInputStream::ConsumedEntireMessage
bool ConsumedEntireMessage()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1424
google::protobuf::io::CodedInputStream::ReadVarint32
bool ReadVarint32(uint32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1268
google::protobuf::StringPiece
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringpiece.h:180
google::protobuf::FieldDescriptor::IsTypePackable
static bool IsTypePackable(Type field_type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.h:2159
google::protobuf::util::converter::ProtoStreamObjectSource::RenderDuration
static util::Status RenderDuration(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:357
google::protobuf::util::converter::ProtoStreamObjectSource::recursion_depth_
int recursion_depth_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:308
google::protobuf::SimpleFtoa
string SimpleFtoa(float value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1226
uint64_t
unsigned __int64 uint64_t
Definition: stdint-msvc2008.h:90
google::protobuf::util::converter::ProtoStreamObjectSource::renderers_
static std::unordered_map< std::string, TypeRenderer > * renderers_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:257
grpc::protobuf::io::CodedInputStream
GRPC_CUSTOM_CODEDINPUTSTREAM CodedInputStream
Definition: include/grpcpp/impl/codegen/config_protobuf.h:102
google::protobuf::StringPrintf
string StringPrintf(const char *format,...)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/stringprintf.cc:109
google::protobuf::util::converter::IsMap
bool IsMap(const google::protobuf::Field &field, const google::protobuf::Type &type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/utility.cc:360
google::protobuf::util::converter::ProtoStreamObjectSource::WriteMessage
virtual util::Status WriteMessage(const google::protobuf::Type &descriptor, StringPiece name, const uint32 end_tag, bool include_start_and_end, ObjectWriter *ow) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:185
google::protobuf::util::converter::ProtoStreamObjectSource::RenderOptions::use_ints_for_enums
bool use_ints_for_enums
Definition: protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:110
number
int32_t number
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:850
google::protobuf::util::converter::TypeInfo
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/type_info.h:50
google::protobuf::util::converter::ProtoStreamObjectSource::RenderMap
util::StatusOr< uint32 > RenderMap(const google::protobuf::Field *field, StringPiece name, uint32 list_tag, ObjectWriter *ow) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:275
google::protobuf.internal::WireFormatLite::FieldType
FieldType
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:111
google::protobuf::util::converter::ProtoStreamObjectSource::RenderStructListValue
static util::Status RenderStructListValue(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:566
google::protobuf::util::converter::ProtoStreamObjectSource::type_
const google::protobuf::Type & type_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:295
google::protobuf::io::CodedInputStream::ReadLittleEndian32
bool ReadLittleEndian32(uint32 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1341
google::protobuf::util::converter::kDurationMinSeconds
const int64 kDurationMinSeconds
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/internal/constants.h:59
google::protobuf::util::converter::EnumValueNameToLowerCamelCase
std::string EnumValueNameToLowerCamelCase(const StringPiece input)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/utility.cc:243
RETURN_IF_ERROR
#define RETURN_IF_ERROR(expr)
Definition: wire_reader_impl.cc:36
google::protobuf::util::converter::ProtoStreamObjectSource::DeleteRendererMap
static void DeleteRendererMap()
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:747
google::protobuf::io::CodedInputStream::PushLimit
Limit PushLimit(int byte_limit)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:118
google::protobuf::util::converter::kDefaultMaxRecursionDepth
static const int kDefaultMaxRecursionDepth
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/json_stream_parser.cc:66
google::protobuf::io::CodedInputStream::ReadString
bool ReadString(std::string *buffer, int size)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.cc:258
google::protobuf::util::converter::ProtoStreamObjectSource::ReadFieldValueAsString
const std::string ReadFieldValueAsString(const google::protobuf::Field &field) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:932
google::protobuf::util::converter::ProtoStreamObjectSource::RenderTimestamp
static util::Status RenderTimestamp(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:333
Field
struct Field Field
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:647
google::protobuf.internal::WireFormatLite::GetTagWireType
static WireType GetTagWireType(uint32 tag)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:788
google::protobuf::SimpleDtoa
string SimpleDtoa(double value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/strutil.cc:1221
google::protobuf::util::converter::ProtoStreamObjectSource::NamedWriteTo
util::Status NamedWriteTo(StringPiece name, ObjectWriter *ow) const override
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:160
field
const FieldDescriptor * field
Definition: bloaty/third_party/protobuf/src/google/protobuf/compiler/parser_unittest.cc:2692
google::protobuf::util::converter::ProtoStreamObjectSource::stream_
io::CodedInputStream * stream_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:284
google::protobuf::util::converter::ProtoStreamObjectSource::RenderPacked
util::Status RenderPacked(const google::protobuf::Field *field, ObjectWriter *ow) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:321
google::protobuf::util::converter::ProtoStreamObjectSource::RenderInt64
static util::Status RenderInt64(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:427
ASSIGN_OR_RETURN
#define ASSIGN_OR_RETURN(lhs, rexpr)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/status_macros.h:81
google::protobuf::util::converter::ProtoStreamObjectSource::RenderStruct
static util::Status RenderStruct(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:530
google::protobuf::io::CodedInputStream::ReadTag
PROTOBUF_ALWAYS_INLINE uint32 ReadTag()
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:266
google::protobuf.internal::FormatTime
string FormatTime(int64 seconds, int32 nanos)
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/time.cc:271
google::protobuf::util::converter::ProtoStreamObjectSource::RenderUInt64
static util::Status RenderUInt64(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:441
google::protobuf::util::converter::ProtoStreamObjectSource::RenderFloat
static util::Status RenderFloat(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:413
google::protobuf::util::converter::ProtoStreamObjectSource::FindAndVerifyField
const google::protobuf::Field * FindAndVerifyField(const google::protobuf::Type &type, uint32 tag) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:165
google::protobuf::io::CodedInputStream
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:180
field_type
zend_class_entry * field_type
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/message.c:2030
grpc::protobuf::util::Status
GRPC_CUSTOM_UTIL_STATUS Status
Definition: include/grpcpp/impl/codegen/config_protobuf.h:93
type_url
string * type_url
Definition: bloaty/third_party/protobuf/conformance/conformance_cpp.cc:72
GOOGLE_LOG_IF
#define GOOGLE_LOG_IF(LEVEL, CONDITION)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/logging.h:150
google::protobuf::util::converter::ConvertFieldMaskPath
std::string ConvertFieldMaskPath(const StringPiece path, ConverterCallback converter)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/field_mask_utility.cc:65
google::protobuf::util::converter::kTimestampMinSeconds
const int64 kTimestampMinSeconds
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/internal/constants.h:53
google::protobuf::util::Status
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/stubs/status.h:67
google::protobuf.internal::WireFormatLite::WireType
WireType
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:101
google::protobuf::util::converter::ProtoStreamObjectSource::RenderUInt32
static util::Status RenderUInt32(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:469
google::protobuf::util::converter::ProtoStreamObjectSource::IncrementRecursionDepth
util::Status IncrementRecursionDepth(StringPiece type_name, StringPiece field_name) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:1089
google::protobuf::util::converter::ProtoStreamObjectSource::RenderBool
static util::Status RenderBool(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:483
google::protobuf::util::converter::ProtoStreamObjectSource::RenderNonMessageField
util::Status RenderNonMessageField(const google::protobuf::Field *field, StringPiece field_name, ObjectWriter *ow) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:804
google::protobuf::util::converter::ProtoStreamObjectSource::RenderString
static util::Status RenderString(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:498
google::protobuf::util::converter::ProtoStreamObjectSource::RenderList
virtual util::StatusOr< uint32 > RenderList(const google::protobuf::Field *field, StringPiece name, uint32 list_tag, ObjectWriter *ow) const
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:253
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
google::protobuf.internal::WireFormatLite::ZigZagDecode64
static int64 ZigZagDecode64(uint64 n)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:885
length
std::size_t length
Definition: abseil-cpp/absl/time/internal/test_util.cc:57
int32_t
signed int int32_t
Definition: stdint-msvc2008.h:77
google::protobuf::util::converter::ProtoStreamObjectSource::RenderFieldMask
static util::Status RenderFieldMask(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:673
google::protobuf.internal::WireFormatLite::ZigZagDecode32
static int32 ZigZagDecode32(uint32 n)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format_lite.h:874
google::protobuf::FindOrNull
const Collection::value_type::second_type * FindOrNull(const Collection &collection, const typename Collection::value_type::first_type &key)
Definition: bloaty/third_party/protobuf/src/google/protobuf/stubs/map_util.h:137
google::protobuf::util::converter::ProtoStreamObjectSource::ProtoStreamObjectSource
ProtoStreamObjectSource(io::CodedInputStream *stream, TypeResolver *type_resolver, const google::protobuf::Type &type)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:116
google::protobuf::util::converter::kDurationMaxSeconds
const int64 kDurationMaxSeconds
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/internal/constants.h:62
google
Definition: bloaty/third_party/protobuf/benchmarks/util/data_proto2_to_proto3_util.h:11
google::protobuf::util::converter::kNanosPerSecond
const int32 kNanosPerSecond
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/internal/constants.h:65
i
uint64_t i
Definition: abseil-cpp/absl/container/btree_benchmark.cc:230
google::protobuf::util::converter::source_renderers_init_
PROTOBUF_NAMESPACE_ID::internal::once_flag source_renderers_init_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:707
type_name
static const char * type_name(int type)
Definition: adig.c:889
google::protobuf::util::converter::ProtoStreamObjectSource::max_recursion_depth_
int max_recursion_depth_
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.h:311
google::protobuf::util::converter::kStructNullValueTypeUrl
const char kStructNullValueTypeUrl[]
Definition: third_party/bloaty/third_party/protobuf/src/google/protobuf/util/internal/constants.h:68
google::protobuf.internal::WireFormat::SkipField
static bool SkipField(io::CodedInputStream *input, uint32 tag, UnknownFieldSet *unknown_fields)
Definition: bloaty/third_party/protobuf/src/google/protobuf/wire_format.cc:85
google::protobuf::util::converter::ProtoStreamObjectSource::RenderInt32
static util::Status RenderInt32(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: bloaty/third_party/protobuf/src/google/protobuf/util/internal/protostream_objectsource.cc:455
google::protobuf::io::CodedInputStream::ReadVarint64
bool ReadVarint64(uint64 *value)
Definition: bloaty/third_party/protobuf/src/google/protobuf/io/coded_stream.h:1283
stream
voidpf stream
Definition: bloaty/third_party/zlib/contrib/minizip/ioapi.h:136


grpc
Author(s):
autogenerated on Fri May 16 2025 02:59:48