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 
32 
33 #include <unordered_map>
34 #include <utility>
35 
52 
53 
56 
57 
58 #include <google/protobuf/port_def.inc>
59 
60 namespace google {
61 namespace protobuf {
62 namespace util {
63 using util::Status;
64 using util::StatusOr;
65 namespace error {
66 using util::error::Code;
68 } // namespace error
69 namespace converter {
70 using ::PROTOBUF_NAMESPACE_ID::internal::WireFormat;
71 using ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite;
72 using util::Status;
73 using util::StatusOr;
74 
75 namespace {
76 
77 static int kDefaultMaxRecursionDepth = 64;
78 
79 // Finds a field with the given number. nullptr if none found.
80 const google::protobuf::Field* FindFieldByNumber(
81  const google::protobuf::Type& type, int number);
82 
83 // Returns true if the field is packable.
84 bool IsPackable(const google::protobuf::Field& field);
85 
86 // Finds an enum value with the given number. nullptr if none found.
87 const google::protobuf::EnumValue* FindEnumValueByNumber(
88  const google::protobuf::Enum& tech_enum, int number);
89 
90 // Utility function to format nanos.
91 const std::string FormatNanos(uint32 nanos, bool with_trailing_zeros);
92 
93 StatusOr<std::string> MapKeyDefaultValueAsString(
95  switch (field.kind()) {
97  return std::string("false");
108  return std::string("0");
110  return std::string();
111  default:
112  return Status(util::error::INTERNAL, "Invalid map key type.");
113  }
114 }
115 } // namespace
116 
117 
121  : stream_(stream),
122  typeinfo_(TypeInfo::NewTypeInfo(type_resolver)),
123  own_typeinfo_(true),
124  type_(type),
125  use_lower_camel_for_enums_(false),
126  use_ints_for_enums_(false),
127  preserve_proto_field_names_(false),
128  recursion_depth_(0),
129  max_recursion_depth_(kDefaultMaxRecursionDepth),
130  render_unknown_fields_(false),
131  render_unknown_enum_values_(true),
132  add_trailing_zeros_for_timestamp_and_duration_(false),
133  suppress_empty_object_(false) {
134  GOOGLE_LOG_IF(DFATAL, stream == nullptr) << "Input stream is nullptr.";
135 }
136 
138  io::CodedInputStream* stream, const TypeInfo* typeinfo,
140  : stream_(stream),
141  typeinfo_(typeinfo),
142  own_typeinfo_(false),
143  type_(type),
144  use_lower_camel_for_enums_(false),
145  use_ints_for_enums_(false),
146  preserve_proto_field_names_(false),
147  recursion_depth_(0),
148  max_recursion_depth_(kDefaultMaxRecursionDepth),
149  render_unknown_fields_(false),
150  render_unknown_enum_values_(true),
151  add_trailing_zeros_for_timestamp_and_duration_(false),
152  suppress_empty_object_(false) {
153  GOOGLE_LOG_IF(DFATAL, stream == nullptr) << "Input stream is nullptr.";
154 }
155 
157  if (own_typeinfo_) {
158  delete typeinfo_;
159  }
160 }
161 
163  ObjectWriter* ow) const {
164  return WriteMessage(type_, name, 0, true, ow);
165 }
166 
168  const google::protobuf::Type& type, uint32 tag) const {
169  // Lookup the new field in the type by tag number.
170  const google::protobuf::Field* field = FindFieldByNumber(type, tag >> 3);
171  // Verify if the field corresponds to the wire type in tag.
172  // If there is any discrepancy, mark the field as not found.
173  if (field != nullptr) {
174  WireFormatLite::WireType expected_type =
176  static_cast<WireFormatLite::FieldType>(field->kind()));
178  if (actual_type != expected_type &&
179  (!IsPackable(*field) ||
181  field = nullptr;
182  }
183  }
184  return field;
185 }
186 
189  const uint32 end_tag,
190  bool include_start_and_end,
191  ObjectWriter* ow) const {
192 
193  const TypeRenderer* type_renderer = FindTypeRenderer(type.name());
194  if (type_renderer != nullptr) {
195  return (*type_renderer)(this, type, name, ow);
196  }
197 
198  const google::protobuf::Field* field = nullptr;
199  std::string field_name;
200  // last_tag set to dummy value that is different from tag.
201  uint32 tag = stream_->ReadTag(), last_tag = tag + 1;
202  UnknownFieldSet unknown_fields;
203 
204  if (tag == end_tag && suppress_empty_object_) {
205  return util::Status();
206  }
207 
208  if (include_start_and_end) {
209  ow->StartObject(name);
210  }
211  while (tag != end_tag) {
212  if (tag != last_tag) { // Update field only if tag is changed.
213  last_tag = tag;
214  field = FindAndVerifyField(type, tag);
215  if (field != nullptr) {
217  field_name = field->name();
218  } else {
219  field_name = field->json_name();
220  }
221  }
222  }
223  if (field == nullptr) {
224  // If we didn't find a field, skip this unknown tag.
225  // TODO(wpoon): Check return boolean value.
227  render_unknown_fields_ ? &unknown_fields : nullptr);
228  tag = stream_->ReadTag();
229  continue;
230  }
231 
232  if (field->cardinality() ==
234  if (IsMap(*field)) {
235  ow->StartObject(field_name);
236  ASSIGN_OR_RETURN(tag, RenderMap(field, field_name, tag, ow));
237  ow->EndObject();
238  } else {
239  ASSIGN_OR_RETURN(tag, RenderList(field, field_name, tag, ow));
240  }
241  } else {
242  // Render the field.
243  RETURN_IF_ERROR(RenderField(field, field_name, ow));
244  tag = stream_->ReadTag();
245  }
246  }
247 
248 
249  if (include_start_and_end) {
250  ow->EndObject();
251  }
252  return util::Status();
253 }
254 
257  uint32 list_tag, ObjectWriter* ow) const {
258  uint32 tag_to_return = 0;
259  ow->StartList(name);
260  if (IsPackable(*field) &&
261  list_tag ==
262  WireFormatLite::MakeTag(field->number(),
265  // Since packed fields have a single tag, read another tag from stream to
266  // return.
267  tag_to_return = stream_->ReadTag();
268  } else {
269  do {
271  } while ((tag_to_return = stream_->ReadTag()) == list_tag);
272  }
273  ow->EndList();
274  return tag_to_return;
275 }
276 
279  uint32 list_tag, ObjectWriter* ow) const {
281  typeinfo_->GetTypeByTypeUrl(field->type_url());
282  uint32 tag_to_return = 0;
283  do {
284  // Render map entry message type.
285  uint32 buffer32;
286  stream_->ReadVarint32(&buffer32); // message length
287  int old_limit = stream_->PushLimit(buffer32);
288  std::string map_key;
289  for (uint32 tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) {
292  if (field == nullptr) {
293  WireFormat::SkipField(stream_, tag, nullptr);
294  continue;
295  }
296  // Map field numbers are key = 1 and value = 2
297  if (field->number() == 1) {
298  map_key = ReadFieldValueAsString(*field);
299  } else if (field->number() == 2) {
300  if (map_key.empty()) {
301  // An absent map key is treated as the default.
302  const google::protobuf::Field* key_field =
303  FindFieldByNumber(*field_type, 1);
304  if (key_field == nullptr) {
305  // The Type info for this map entry is incorrect. It should always
306  // have a field named "key" and with field number 1.
307  return Status(util::error::INTERNAL, "Invalid map entry.");
308  }
309  ASSIGN_OR_RETURN(map_key, MapKeyDefaultValueAsString(*key_field));
310  }
311  RETURN_IF_ERROR(RenderField(field, map_key, ow));
312  } else {
313  // The Type info for this map entry is incorrect. It should contain
314  // exactly two fields with field number 1 and 2.
315  return Status(util::error::INTERNAL, "Invalid map entry.");
316  }
317  }
318  stream_->PopLimit(old_limit);
319  } while ((tag_to_return = stream_->ReadTag()) == list_tag);
320  return tag_to_return;
321 }
322 
324  const google::protobuf::Field* field, ObjectWriter* ow) const {
325  uint32 length;
327  int old_limit = stream_->PushLimit(length);
328  while (stream_->BytesUntilLimit() > 0) {
330  }
331  stream_->PopLimit(old_limit);
332  return util::Status();
333 }
334 
335 
338  StringPiece field_name, ObjectWriter* ow) {
339  std::pair<int64, int32> p = os->ReadSecondsAndNanos(type);
340  int64 seconds = p.first;
341  int32 nanos = p.second;
342  if (seconds > kTimestampMaxSeconds || seconds < kTimestampMinSeconds) {
344  StrCat("Timestamp seconds exceeds limit for field: ",
345  field_name));
346  }
347 
348  if (nanos < 0 || nanos >= kNanosPerSecond) {
349  return Status(
351  StrCat("Timestamp nanos exceeds limit for field: ", field_name));
352  }
353 
354  ow->RenderString(field_name,
355  ::google::protobuf::internal::FormatTime(seconds, nanos));
356 
357  return util::Status();
358 }
359 
362  StringPiece field_name, ObjectWriter* ow) {
363  std::pair<int64, int32> p = os->ReadSecondsAndNanos(type);
364  int64 seconds = p.first;
365  int32 nanos = p.second;
366  if (seconds > kDurationMaxSeconds || seconds < kDurationMinSeconds) {
367  return Status(
369  StrCat("Duration seconds exceeds limit for field: ", field_name));
370  }
371 
372  if (nanos <= -kNanosPerSecond || nanos >= kNanosPerSecond) {
373  return Status(
375  StrCat("Duration nanos exceeds limit for field: ", field_name));
376  }
377 
378  std::string sign = "";
379  if (seconds < 0) {
380  if (nanos > 0) {
381  return Status(
383  StrCat("Duration nanos is non-negative, but seconds is "
384  "negative for field: ",
385  field_name));
386  }
387  sign = "-";
388  seconds = -seconds;
389  nanos = -nanos;
390  } else if (seconds == 0 && nanos < 0) {
391  sign = "-";
392  nanos = -nanos;
393  }
394  std::string formatted_duration = StringPrintf(
395  "%s%lld%ss", sign.c_str(), static_cast<long long>(seconds), // NOLINT
396  FormatNanos(nanos, os->add_trailing_zeros_for_timestamp_and_duration_)
397  .c_str());
398  ow->RenderString(field_name, formatted_duration);
399  return util::Status();
400 }
401 
404  StringPiece field_name,
405  ObjectWriter* ow) {
406  uint32 tag = os->stream_->ReadTag();
407  uint64 buffer64 = 0; // default value of Double wrapper value
408  if (tag != 0) {
409  os->stream_->ReadLittleEndian64(&buffer64);
410  os->stream_->ReadTag();
411  }
412  ow->RenderDouble(field_name, bit_cast<double>(buffer64));
413  return util::Status();
414 }
415 
418  StringPiece field_name,
419  ObjectWriter* ow) {
420  uint32 tag = os->stream_->ReadTag();
421  uint32 buffer32 = 0; // default value of Float wrapper value
422  if (tag != 0) {
423  os->stream_->ReadLittleEndian32(&buffer32);
424  os->stream_->ReadTag();
425  }
426  ow->RenderFloat(field_name, bit_cast<float>(buffer32));
427  return util::Status();
428 }
429 
432  StringPiece field_name,
433  ObjectWriter* ow) {
434  uint32 tag = os->stream_->ReadTag();
435  uint64 buffer64 = 0; // default value of Int64 wrapper value
436  if (tag != 0) {
437  os->stream_->ReadVarint64(&buffer64);
438  os->stream_->ReadTag();
439  }
440  ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
441  return util::Status();
442 }
443 
446  StringPiece field_name,
447  ObjectWriter* ow) {
448  uint32 tag = os->stream_->ReadTag();
449  uint64 buffer64 = 0; // default value of UInt64 wrapper value
450  if (tag != 0) {
451  os->stream_->ReadVarint64(&buffer64);
452  os->stream_->ReadTag();
453  }
454  ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
455  return util::Status();
456 }
457 
460  StringPiece field_name,
461  ObjectWriter* ow) {
462  uint32 tag = os->stream_->ReadTag();
463  uint32 buffer32 = 0; // default value of Int32 wrapper value
464  if (tag != 0) {
465  os->stream_->ReadVarint32(&buffer32);
466  os->stream_->ReadTag();
467  }
468  ow->RenderInt32(field_name, bit_cast<int32>(buffer32));
469  return util::Status();
470 }
471 
474  StringPiece field_name,
475  ObjectWriter* ow) {
476  uint32 tag = os->stream_->ReadTag();
477  uint32 buffer32 = 0; // default value of UInt32 wrapper value
478  if (tag != 0) {
479  os->stream_->ReadVarint32(&buffer32);
480  os->stream_->ReadTag();
481  }
482  ow->RenderUint32(field_name, bit_cast<uint32>(buffer32));
483  return util::Status();
484 }
485 
488  StringPiece field_name,
489  ObjectWriter* ow) {
490  uint32 tag = os->stream_->ReadTag();
491  uint64 buffer64 = 0; // results in 'false' value as default, which is the
492  // default value of Bool wrapper
493  if (tag != 0) {
494  os->stream_->ReadVarint64(&buffer64);
495  os->stream_->ReadTag();
496  }
497  ow->RenderBool(field_name, buffer64 != 0);
498  return util::Status();
499 }
500 
503  StringPiece field_name,
504  ObjectWriter* ow) {
505  uint32 tag = os->stream_->ReadTag();
506  uint32 buffer32;
507  std::string str; // default value of empty for String wrapper
508  if (tag != 0) {
509  os->stream_->ReadVarint32(&buffer32); // string size.
510  os->stream_->ReadString(&str, buffer32);
511  os->stream_->ReadTag();
512  }
513  ow->RenderString(field_name, str);
514  return util::Status();
515 }
516 
519  StringPiece field_name,
520  ObjectWriter* ow) {
521  uint32 tag = os->stream_->ReadTag();
522  uint32 buffer32;
524  if (tag != 0) {
525  os->stream_->ReadVarint32(&buffer32);
526  os->stream_->ReadString(&str, buffer32);
527  os->stream_->ReadTag();
528  }
529  ow->RenderBytes(field_name, str);
530  return util::Status();
531 }
532 
535  StringPiece field_name,
536  ObjectWriter* ow) {
537  const google::protobuf::Field* field = nullptr;
538  uint32 tag = os->stream_->ReadTag();
539  ow->StartObject(field_name);
540  while (tag != 0) {
541  field = os->FindAndVerifyField(type, tag);
542  // google.protobuf.Struct has only one field that is a map. Hence we use
543  // RenderMap to render that field.
544  if (os->IsMap(*field)) {
545  ASSIGN_OR_RETURN(tag, os->RenderMap(field, field_name, tag, ow));
546  }
547  }
548  ow->EndObject();
549  return util::Status();
550 }
551 
554  StringPiece field_name, ObjectWriter* ow) {
555  const google::protobuf::Field* field = nullptr;
556  for (uint32 tag = os->stream_->ReadTag(); tag != 0;
557  tag = os->stream_->ReadTag()) {
558  field = os->FindAndVerifyField(type, tag);
559  if (field == nullptr) {
560  WireFormat::SkipField(os->stream_, tag, nullptr);
561  continue;
562  }
563  RETURN_IF_ERROR(os->RenderField(field, field_name, ow));
564  }
565  return util::Status();
566 }
567 
568 // TODO(skarvaje): Avoid code duplication of for loops and SkipField logic.
571  StringPiece field_name, ObjectWriter* ow) {
572  uint32 tag = os->stream_->ReadTag();
573 
574  // Render empty list when we find empty ListValue message.
575  if (tag == 0) {
576  ow->StartList(field_name);
577  ow->EndList();
578  return util::Status();
579  }
580 
581  while (tag != 0) {
583  if (field == nullptr) {
584  WireFormat::SkipField(os->stream_, tag, nullptr);
585  tag = os->stream_->ReadTag();
586  continue;
587  }
588  ASSIGN_OR_RETURN(tag, os->RenderList(field, field_name, tag, ow));
589  }
590  return util::Status();
591 }
592 
595  StringPiece field_name,
596  ObjectWriter* ow) {
597  // An Any is of the form { string type_url = 1; bytes value = 2; }
598  uint32 tag;
601 
602  // First read out the type_url and value from the proto stream
603  for (tag = os->stream_->ReadTag(); tag != 0; tag = os->stream_->ReadTag()) {
605  if (field == nullptr) {
606  WireFormat::SkipField(os->stream_, tag, nullptr);
607  continue;
608  }
609  // 'type_url' has field number of 1 and 'value' has field number 2
610  // //google/protobuf/any.proto
611  if (field->number() == 1) {
612  // read type_url
613  uint32 type_url_size;
614  os->stream_->ReadVarint32(&type_url_size);
615  os->stream_->ReadString(&type_url, type_url_size);
616  } else if (field->number() == 2) {
617  // read value
618  uint32 value_size;
619  os->stream_->ReadVarint32(&value_size);
620  os->stream_->ReadString(&value, value_size);
621  }
622  }
623 
624  // If there is no value, we don't lookup the type, we just output it (if
625  // present). If both type and value are empty we output an empty object.
626  if (value.empty()) {
627  ow->StartObject(field_name);
628  if (!type_url.empty()) {
629  ow->RenderString("@type", type_url);
630  }
631  ow->EndObject();
632  return util::Status();
633  }
634 
635  // If there is a value but no type, we cannot render it, so report an error.
636  if (type_url.empty()) {
637  // TODO(sven): Add an external message once those are ready.
639  "Invalid Any, the type_url is missing.");
640  }
641 
644 
645  if (!resolved_type.ok()) {
646  // Convert into an internal error, since this means the backend gave us
647  // an invalid response (missing or invalid type information).
649  resolved_type.status().message());
650  }
651  // nested_type cannot be null at this time.
652  const google::protobuf::Type* nested_type = resolved_type.ValueOrDie();
653 
654  io::ArrayInputStream zero_copy_stream(value.data(), value.size());
655  io::CodedInputStream in_stream(&zero_copy_stream);
656  // We know the type so we can render it. Recursively parse the nested stream
657  // using a nested ProtoStreamObjectSource using our nested type information.
658  ProtoStreamObjectSource nested_os(&in_stream, os->typeinfo_, *nested_type);
659 
660  // TODO(htuch): This is somewhat fragile, since new options may be omitted.
661  // We should probably do this via the constructor or some object grouping
662  // options.
666 
667  // We manually call start and end object here so we can inject the @type.
668  ow->StartObject(field_name);
669  ow->RenderString("@type", type_url);
670  util::Status result =
671  nested_os.WriteMessage(nested_os.type_, "value", 0, false, ow);
672  ow->EndObject();
673  return result;
674 }
675 
678  StringPiece field_name, ObjectWriter* ow) {
679  std::string combined;
680  uint32 buffer32;
681  uint32 paths_field_tag = 0;
682  for (uint32 tag = os->stream_->ReadTag(); tag != 0;
683  tag = os->stream_->ReadTag()) {
684  if (paths_field_tag == 0) {
686  if (field != nullptr && field->number() == 1 &&
687  field->name() == "paths") {
688  paths_field_tag = tag;
689  }
690  }
691  if (paths_field_tag != tag) {
693  "Invalid FieldMask, unexpected field.");
694  }
696  os->stream_->ReadVarint32(&buffer32); // string size.
697  os->stream_->ReadString(&str, buffer32);
698  if (!combined.empty()) {
699  combined.append(",");
700  }
701  combined.append(ConvertFieldMaskPath(str, &ToCamelCase));
702  }
703  ow->RenderString(field_name, combined);
704  return util::Status();
705 }
706 
707 
708 std::unordered_map<std::string, ProtoStreamObjectSource::TypeRenderer>*
711 
712 
714  renderers_ = new std::unordered_map<std::string,
716  (*renderers_)["google.protobuf.Timestamp"] =
718  (*renderers_)["google.protobuf.Duration"] =
720  (*renderers_)["google.protobuf.DoubleValue"] =
722  (*renderers_)["google.protobuf.FloatValue"] =
724  (*renderers_)["google.protobuf.Int64Value"] =
726  (*renderers_)["google.protobuf.UInt64Value"] =
728  (*renderers_)["google.protobuf.Int32Value"] =
730  (*renderers_)["google.protobuf.UInt32Value"] =
732  (*renderers_)["google.protobuf.BoolValue"] =
734  (*renderers_)["google.protobuf.StringValue"] =
736  (*renderers_)["google.protobuf.BytesValue"] =
738  (*renderers_)["google.protobuf.Any"] = &ProtoStreamObjectSource::RenderAny;
739  (*renderers_)["google.protobuf.Struct"] =
741  (*renderers_)["google.protobuf.Value"] =
743  (*renderers_)["google.protobuf.ListValue"] =
745  (*renderers_)["google.protobuf.FieldMask"] =
748 }
749 
750 
753  renderers_ = NULL;
754 }
755 
756 // static
761  return FindOrNull(*renderers_, type_url);
762 }
763 
765  const google::protobuf::Field* field, StringPiece field_name,
766  ObjectWriter* ow) const {
767  // Short-circuit message types as it tends to call WriteMessage recursively
768  // and ends up using a lot of stack space. Keep the stack usage of this
769  // message small in order to preserve stack space and not crash.
771  uint32 buffer32;
772  stream_->ReadVarint32(&buffer32); // message length
773  int old_limit = stream_->PushLimit(buffer32);
774  // Get the nested message type for this field.
776  typeinfo_->GetTypeByTypeUrl(field->type_url());
777  if (type == nullptr) {
778  return Status(
780  StrCat("Invalid configuration. Could not find the type: ",
781  field->type_url()));
782  }
783 
784  // Short-circuit any special type rendering to save call-stack space.
785  const TypeRenderer* type_renderer = FindTypeRenderer(type->name());
786 
787  RETURN_IF_ERROR(IncrementRecursionDepth(type->name(), field_name));
788  if (type_renderer != nullptr) {
789  RETURN_IF_ERROR((*type_renderer)(this, *type, field_name, ow));
790  } else {
791  RETURN_IF_ERROR(WriteMessage(*type, field_name, 0, true, ow));
792  }
794 
795  if (!stream_->ConsumedEntireMessage()) {
797  "Nested protocol message not parsed in its entirety.");
798  }
799  stream_->PopLimit(old_limit);
800  } else {
801  // Render all other non-message types.
802  return RenderNonMessageField(field, field_name, ow);
803  }
804  return util::Status();
805 }
806 
807 
809  const google::protobuf::Field* field, StringPiece field_name,
810  ObjectWriter* ow) const {
811  // Temporary buffers of different types.
812  uint32 buffer32;
813  uint64 buffer64;
814  std::string strbuffer;
815  switch (field->kind()) {
817  stream_->ReadVarint64(&buffer64);
818  ow->RenderBool(field_name, buffer64 != 0);
819  break;
820  }
822  stream_->ReadVarint32(&buffer32);
823  ow->RenderInt32(field_name, bit_cast<int32>(buffer32));
824  break;
825  }
827  stream_->ReadVarint64(&buffer64);
828  ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
829  break;
830  }
832  stream_->ReadVarint32(&buffer32);
833  ow->RenderUint32(field_name, bit_cast<uint32>(buffer32));
834  break;
835  }
837  stream_->ReadVarint64(&buffer64);
838  ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
839  break;
840  }
842  stream_->ReadVarint32(&buffer32);
843  ow->RenderInt32(field_name, WireFormatLite::ZigZagDecode32(buffer32));
844  break;
845  }
847  stream_->ReadVarint64(&buffer64);
848  ow->RenderInt64(field_name, WireFormatLite::ZigZagDecode64(buffer64));
849  break;
850  }
852  stream_->ReadLittleEndian32(&buffer32);
853  ow->RenderInt32(field_name, bit_cast<int32>(buffer32));
854  break;
855  }
857  stream_->ReadLittleEndian64(&buffer64);
858  ow->RenderInt64(field_name, bit_cast<int64>(buffer64));
859  break;
860  }
862  stream_->ReadLittleEndian32(&buffer32);
863  ow->RenderUint32(field_name, bit_cast<uint32>(buffer32));
864  break;
865  }
867  stream_->ReadLittleEndian64(&buffer64);
868  ow->RenderUint64(field_name, bit_cast<uint64>(buffer64));
869  break;
870  }
872  stream_->ReadLittleEndian32(&buffer32);
873  ow->RenderFloat(field_name, bit_cast<float>(buffer32));
874  break;
875  }
877  stream_->ReadLittleEndian64(&buffer64);
878  ow->RenderDouble(field_name, bit_cast<double>(buffer64));
879  break;
880  }
882  stream_->ReadVarint32(&buffer32);
883 
884  // If the field represents an explicit NULL value, render null.
885  if (field->type_url() == kStructNullValueTypeUrl) {
886  ow->RenderNull(field_name);
887  break;
888  }
889 
890  // Get the nested enum type for this field.
891  // TODO(skarvaje): Avoid string manipulation. Find ways to speed this
892  // up.
893  const google::protobuf::Enum* en =
894  typeinfo_->GetEnumByTypeUrl(field->type_url());
895  // Lookup the name of the enum, and render that. Unknown enum values
896  // are printed as integers.
897  if (en != nullptr) {
898  const google::protobuf::EnumValue* enum_value =
899  FindEnumValueByNumber(*en, buffer32);
900  if (enum_value != nullptr) {
901  if (use_ints_for_enums_) {
902  ow->RenderInt32(field_name, buffer32);
903  } else if (use_lower_camel_for_enums_) {
904  ow->RenderString(field_name,
905  EnumValueNameToLowerCamelCase(enum_value->name()));
906  } else {
907  ow->RenderString(field_name, enum_value->name());
908  }
909  } else if (render_unknown_enum_values_) {
910  ow->RenderInt32(field_name, buffer32);
911  }
912  } else if (render_unknown_enum_values_) {
913  ow->RenderInt32(field_name, buffer32);
914  }
915  break;
916  }
918  stream_->ReadVarint32(&buffer32); // string size.
919  stream_->ReadString(&strbuffer, buffer32);
920  ow->RenderString(field_name, strbuffer);
921  break;
922  }
924  stream_->ReadVarint32(&buffer32); // bytes size.
925  stream_->ReadString(&strbuffer, buffer32);
926  ow->RenderBytes(field_name, strbuffer);
927  break;
928  }
929  default:
930  break;
931  }
932  return util::Status();
933 }
934 
935 // TODO(skarvaje): Fix this to avoid code duplication.
937  const google::protobuf::Field& field) const {
938  std::string result;
939  switch (field.kind()) {
941  uint64 buffer64;
942  stream_->ReadVarint64(&buffer64);
943  result = buffer64 != 0 ? "true" : "false";
944  break;
945  }
947  uint32 buffer32;
948  stream_->ReadVarint32(&buffer32);
949  result = StrCat(bit_cast<int32>(buffer32));
950  break;
951  }
953  uint64 buffer64;
954  stream_->ReadVarint64(&buffer64);
955  result = StrCat(bit_cast<int64>(buffer64));
956  break;
957  }
959  uint32 buffer32;
960  stream_->ReadVarint32(&buffer32);
961  result = StrCat(bit_cast<uint32>(buffer32));
962  break;
963  }
965  uint64 buffer64;
966  stream_->ReadVarint64(&buffer64);
967  result = StrCat(bit_cast<uint64>(buffer64));
968  break;
969  }
971  uint32 buffer32;
972  stream_->ReadVarint32(&buffer32);
973  result = StrCat(WireFormatLite::ZigZagDecode32(buffer32));
974  break;
975  }
977  uint64 buffer64;
978  stream_->ReadVarint64(&buffer64);
979  result = StrCat(WireFormatLite::ZigZagDecode64(buffer64));
980  break;
981  }
983  uint32 buffer32;
984  stream_->ReadLittleEndian32(&buffer32);
985  result = StrCat(bit_cast<int32>(buffer32));
986  break;
987  }
989  uint64 buffer64;
990  stream_->ReadLittleEndian64(&buffer64);
991  result = StrCat(bit_cast<int64>(buffer64));
992  break;
993  }
995  uint32 buffer32;
996  stream_->ReadLittleEndian32(&buffer32);
997  result = StrCat(bit_cast<uint32>(buffer32));
998  break;
999  }
1001  uint64 buffer64;
1002  stream_->ReadLittleEndian64(&buffer64);
1003  result = StrCat(bit_cast<uint64>(buffer64));
1004  break;
1005  }
1007  uint32 buffer32;
1008  stream_->ReadLittleEndian32(&buffer32);
1009  result = SimpleFtoa(bit_cast<float>(buffer32));
1010  break;
1011  }
1013  uint64 buffer64;
1014  stream_->ReadLittleEndian64(&buffer64);
1015  result = SimpleDtoa(bit_cast<double>(buffer64));
1016  break;
1017  }
1019  uint32 buffer32;
1020  stream_->ReadVarint32(&buffer32);
1021  // Get the nested enum type for this field.
1022  // TODO(skarvaje): Avoid string manipulation. Find ways to speed this
1023  // up.
1024  const google::protobuf::Enum* en =
1025  typeinfo_->GetEnumByTypeUrl(field.type_url());
1026  // Lookup the name of the enum, and render that. Skips unknown enums.
1027  if (en != nullptr) {
1028  const google::protobuf::EnumValue* enum_value =
1029  FindEnumValueByNumber(*en, buffer32);
1030  if (enum_value != nullptr) {
1031  result = enum_value->name();
1032  }
1033  }
1034  break;
1035  }
1037  uint32 buffer32;
1038  stream_->ReadVarint32(&buffer32); // string size.
1039  stream_->ReadString(&result, buffer32);
1040  break;
1041  }
1043  uint32 buffer32;
1044  stream_->ReadVarint32(&buffer32); // bytes size.
1045  stream_->ReadString(&result, buffer32);
1046  break;
1047  }
1048  default:
1049  break;
1050  }
1051  return result;
1052 }
1053 
1054 // Field is a map if it is a repeated message and it has an option "map_type".
1055 // TODO(skarvaje): Consider pre-computing the IsMap() into Field directly.
1057  const google::protobuf::Field& field) const {
1059  typeinfo_->GetTypeByTypeUrl(field.type_url());
1062 }
1063 
1065  const google::protobuf::Type& type) const {
1066  uint64 seconds = 0;
1067  uint32 nanos = 0;
1068  uint32 tag = 0;
1069  int64 signed_seconds = 0;
1070  int32 signed_nanos = 0;
1071 
1072  for (tag = stream_->ReadTag(); tag != 0; tag = stream_->ReadTag()) {
1074  if (field == nullptr) {
1075  WireFormat::SkipField(stream_, tag, nullptr);
1076  continue;
1077  }
1078  // 'seconds' has field number of 1 and 'nanos' has field number 2
1079  // //google/protobuf/timestamp.proto & duration.proto
1080  if (field->number() == 1) {
1081  // read seconds
1082  stream_->ReadVarint64(&seconds);
1083  signed_seconds = bit_cast<int64>(seconds);
1084  } else if (field->number() == 2) {
1085  // read nanos
1086  stream_->ReadVarint32(&nanos);
1087  signed_nanos = bit_cast<int32>(nanos);
1088  }
1089  }
1090  return std::pair<int64, int32>(signed_seconds, signed_nanos);
1091 }
1092 
1094  StringPiece type_name, StringPiece field_name) const {
1096  return Status(
1098  StrCat("Message too deep. Max recursion depth reached for type '",
1099  type_name, "', field '", field_name, "'"));
1100  }
1101  return util::Status();
1102 }
1103 
1104 namespace {
1105 // TODO(skarvaje): Speed this up by not doing a linear scan.
1106 const google::protobuf::Field* FindFieldByNumber(
1107  const google::protobuf::Type& type, int number) {
1108  for (int i = 0; i < type.fields_size(); ++i) {
1109  if (type.fields(i).number() == number) {
1110  return &type.fields(i);
1111  }
1112  }
1113  return nullptr;
1114 }
1115 
1116 // TODO(skarvaje): Replace FieldDescriptor by implementing IsTypePackable()
1117 // using tech Field.
1118 bool IsPackable(const google::protobuf::Field& field) {
1119  return field.cardinality() ==
1122  static_cast<FieldDescriptor::Type>(field.kind()));
1123 }
1124 
1125 // TODO(skarvaje): Speed this up by not doing a linear scan.
1126 const google::protobuf::EnumValue* FindEnumValueByNumber(
1127  const google::protobuf::Enum& tech_enum, int number) {
1128  for (int i = 0; i < tech_enum.enumvalue_size(); ++i) {
1129  const google::protobuf::EnumValue& ev = tech_enum.enumvalue(i);
1130  if (ev.number() == number) {
1131  return &ev;
1132  }
1133  }
1134  return nullptr;
1135 }
1136 
1137 // TODO(skarvaje): Look into optimizing this by not doing computation on
1138 // double.
1139 const std::string FormatNanos(uint32 nanos, bool with_trailing_zeros) {
1140  if (nanos == 0) {
1141  return with_trailing_zeros ? ".000" : "";
1142  }
1143 
1144  const char* format =
1145  (nanos % 1000 != 0) ? "%.9f" : (nanos % 1000000 != 0) ? "%.6f" : "%.3f";
1146  std::string formatted =
1147  StringPrintf(format, static_cast<double>(nanos) / kNanosPerSecond);
1148  // remove the leading 0 before decimal.
1149  return formatted.substr(1);
1150 }
1151 } // namespace
1152 
1153 } // namespace converter
1154 } // namespace util
1155 } // namespace protobuf
1156 } // namespace google
google::protobuf::FieldDescriptor::Type
Type
Definition: src/google/protobuf/descriptor.h:521
name
GLuint const GLchar * name
Definition: glcorearb.h:3055
google::protobuf.internal::WireFormatLite::WireTypeForFieldType
static WireFormatLite::WireType WireTypeForFieldType(WireFormatLite::FieldType type)
Definition: wire_format_lite.h:152
google::protobuf::value
const Descriptor::ReservedRange value
Definition: src/google/protobuf/descriptor.h:1954
google::protobuf::util::converter::ProtoStreamObjectSource::RenderUInt32
static util::Status RenderUInt32(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:472
map_util.h
google::protobuf::util::converter::ObjectWriter::StartList
virtual ObjectWriter * StartList(StringPiece name)=0
google::protobuf::io::CodedInputStream::PopLimit
void PopLimit(Limit limit)
Definition: coded_stream.cc:136
google::protobuf::SimpleDtoa
string SimpleDtoa(double value)
Definition: strutil.cc:1219
Field_Kind_TYPE_SFIXED64
@ Field_Kind_TYPE_SFIXED64
Definition: type.pb.h:103
wire_format_lite.h
zero_copy_stream_impl.h
google::protobuf::util::converter::ToCamelCase
std::string ToCamelCase(const StringPiece input)
Definition: utility.cc:250
google::protobuf::Enum
google::protobuf::util::converter::ProtoStreamObjectSource::RenderFieldMask
static util::Status RenderFieldMask(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:676
stream
GLuint GLuint stream
Definition: glcorearb.h:3946
NULL
NULL
Definition: test_security_zap.cpp:405
google::protobuf::util::StatusOr::ValueOrDie
const T & ValueOrDie() const
Definition: statusor.h:251
google::protobuf::int64
int64_t int64
Definition: protobuf/src/google/protobuf/stubs/port.h:151
field_type
zend_class_entry * field_type
Definition: php/ext/google/protobuf/message.c:2028
google::protobuf::util::converter::ProtoStreamObjectSource::RenderInt32
static util::Status RenderInt32(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:458
google::protobuf::StrCat
string StrCat(const AlphaNum &a, const AlphaNum &b)
Definition: strutil.cc:1480
google::protobuf::util::converter::TypeInfo::GetEnumByTypeUrl
virtual const google::protobuf::Enum * GetEnumByTypeUrl(StringPiece type_url) const =0
length
GLenum GLuint GLenum GLsizei length
Definition: glcorearb.h:2695
google::protobuf::util::converter::ProtoStreamObjectSource::RenderInt64
static util::Status RenderInt64(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:430
google::protobuf::util::converter::ProtoStreamObjectSource::use_lower_camel_for_enums_
bool use_lower_camel_for_enums_
Definition: protostream_objectsource.h:300
google::protobuf::util::error::Code
Code
Definition: status.h:46
google::protobuf::util::converter::ProtoStreamObjectSource::use_ints_for_enums_
bool use_ints_for_enums_
Definition: protostream_objectsource.h:303
Field_Kind_TYPE_FIXED32
@ Field_Kind_TYPE_FIXED32
Definition: type.pb.h:94
google::protobuf::util::converter::ProtoStreamObjectSource::RenderPacked
util::Status RenderPacked(const google::protobuf::Field *field, ObjectWriter *ow) const
Definition: protostream_objectsource.cc:323
Field_Kind_TYPE_SFIXED32
@ Field_Kind_TYPE_SFIXED32
Definition: type.pb.h:102
google::protobuf::util::converter::ObjectWriter::RenderUint64
virtual ObjectWriter * RenderUint64(StringPiece name, uint64 value)=0
google::protobuf::util::converter::ProtoStreamObjectSource::~ProtoStreamObjectSource
~ProtoStreamObjectSource() override
Definition: protostream_objectsource.cc:156
google::protobuf::util::converter::ProtoStreamObjectSource::RenderUInt64
static util::Status RenderUInt64(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:444
google::protobuf::util::converter::ProtoStreamObjectSource::own_typeinfo_
bool own_typeinfo_
Definition: protostream_objectsource.h:293
google::protobuf::util::StatusOr::status
const Status & status() const
Definition: statusor.h:241
google::protobuf::util::converter::ProtoStreamObjectSource::RenderBytes
static util::Status RenderBytes(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:517
google::protobuf::util::converter::ProtoStreamObjectSource::FindTypeRenderer
static TypeRenderer * FindTypeRenderer(const std::string &type_url)
Definition: protostream_objectsource.cc:758
google::protobuf::util::converter::ProtoStreamObjectSource::RenderFloat
static util::Status RenderFloat(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:416
google::protobuf::uint32
uint32_t uint32
Definition: protobuf/src/google/protobuf/stubs/port.h:155
google::protobuf::util::converter::kTimestampMaxSeconds
const int64 kTimestampMaxSeconds
Definition: constants.h:56
Field_Kind_TYPE_MESSAGE
@ Field_Kind_TYPE_MESSAGE
Definition: type.pb.h:98
google::protobuf::util::converter::ProtoStreamObjectSource::set_preserve_proto_field_names
void set_preserve_proto_field_names(bool value)
Definition: protostream_objectsource.h:116
Field_Kind_TYPE_UINT32
@ Field_Kind_TYPE_UINT32
Definition: type.pb.h:100
google::protobuf.internal::call_once
void call_once(Args &&... args)
Definition: once.h:45
google::protobuf::util::converter::ObjectWriter
Definition: object_writer.h:60
ASSIGN_OR_RETURN
#define ASSIGN_OR_RETURN(lhs, rexpr)
Definition: status_macros.h:81
google::protobuf::util::converter::ProtoStreamObjectSource::RenderDuration
static util::Status RenderDuration(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:360
string
GLsizei const GLchar *const * string
Definition: glcorearb.h:3083
Field_Kind_TYPE_DOUBLE
@ Field_Kind_TYPE_DOUBLE
Definition: type.pb.h:88
google::protobuf::util::converter::ProtoStreamObjectSource::renderers_
static std::unordered_map< std::string, TypeRenderer > * renderers_
Definition: protostream_objectsource.h:258
google::protobuf::util::converter::ProtoStreamObjectSource::add_trailing_zeros_for_timestamp_and_duration_
bool add_trailing_zeros_for_timestamp_and_duration_
Definition: protostream_objectsource.h:321
google::protobuf::util::converter::ProtoStreamObjectSource::IncrementRecursionDepth
util::Status IncrementRecursionDepth(StringPiece type_name, StringPiece field_name) const
Definition: protostream_objectsource.cc:1093
utility.h
google::protobuf::util::converter::kDurationMaxSeconds
const int64 kDurationMaxSeconds
Definition: constants.h:62
google::protobuf::util::converter::ProtoStreamObjectSource::set_use_ints_for_enums
void set_use_ints_for_enums(bool value)
Definition: protostream_objectsource.h:113
google::protobuf::EnumValue
error
Definition: cJSON.c:88
google::protobuf::util::converter::kDurationMinSeconds
const int64 kDurationMinSeconds
Definition: constants.h:59
google::protobuf::util::converter::TypeInfo::ResolveTypeUrl
virtual util::StatusOr< const google::protobuf::Type * > ResolveTypeUrl(StringPiece type_url) const =0
google::protobuf::util::converter::ProtoStreamObjectSource::TypeRenderer
util::Status(* TypeRenderer)(const ProtoStreamObjectSource *, const google::protobuf::Type &, StringPiece, ObjectWriter *)
Definition: 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: common.cc:344
protostream_objectsource.h
google::protobuf::util::converter::ObjectWriter::RenderDouble
virtual ObjectWriter * RenderDouble(StringPiece name, double value)=0
Field_Kind_TYPE_SINT64
@ Field_Kind_TYPE_SINT64
Definition: type.pb.h:105
google::protobuf::util::converter::ProtoStreamObjectSource::IsMap
bool IsMap(const google::protobuf::Field &field) const
Definition: protostream_objectsource.cc:1056
google::protobuf::io::CodedInputStream::BytesUntilLimit
int BytesUntilLimit() const
Definition: coded_stream.cc:171
google::protobuf::util::converter::ObjectWriter::RenderBool
virtual ObjectWriter * RenderBool(StringPiece name, bool value)=0
google::protobuf::int32
int32_t int32
Definition: protobuf/src/google/protobuf/stubs/port.h:150
Field_Kind_TYPE_SINT32
@ Field_Kind_TYPE_SINT32
Definition: type.pb.h:104
google::protobuf::util::converter::ObjectWriter::RenderInt32
virtual ObjectWriter * RenderInt32(StringPiece name, int32 value)=0
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: protostream_objectsource.cc:187
google::protobuf::FindOrNull
const Collection::value_type::second_type * FindOrNull(const Collection &collection, const typename Collection::value_type::first_type &key)
Definition: map_util.h:137
google::protobuf::io::CodedInputStream::ReadLittleEndian64
bool ReadLittleEndian64(uint64 *value)
Definition: coded_stream.h:1002
Field_Kind_TYPE_INT64
@ Field_Kind_TYPE_INT64
Definition: type.pb.h:90
strutil.h
unknown_field_set.h
google::protobuf::util::converter::ObjectWriter::StartObject
virtual ObjectWriter * StartObject(StringPiece name)=0
google::protobuf.internal::once_flag
std::once_flag once_flag
Definition: once.h:43
google::protobuf::util::TypeResolver
Definition: type_resolver.h:52
google::protobuf::util::converter::ProtoStreamObjectSource::InitRendererMap
static void InitRendererMap()
Definition: protostream_objectsource.cc:713
google::protobuf::io::CodedInputStream::ConsumedEntireMessage
bool ConsumedEntireMessage()
Definition: coded_stream.h:1072
coded_stream.h
google::protobuf::util::converter::ProtoStreamObjectSource::RenderString
static util::Status RenderString(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:501
google::protobuf::io::CodedInputStream::ReadVarint32
bool ReadVarint32(uint32 *value)
Definition: coded_stream.h:916
google::protobuf::StringPiece
Definition: stringpiece.h:180
google::protobuf::FieldDescriptor::IsTypePackable
static bool IsTypePackable(Type field_type)
Definition: src/google/protobuf/descriptor.h:2159
format
GLint GLint GLsizei GLint GLenum format
Definition: glcorearb.h:2773
google::protobuf::util::converter::ProtoStreamObjectSource::recursion_depth_
int recursion_depth_
Definition: protostream_objectsource.h:309
google::protobuf::util::converter::ProtoStreamObjectSource::RenderTimestamp
static util::Status RenderTimestamp(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:336
update_failure_list.str
str
Definition: update_failure_list.py:41
google::protobuf::util::converter::ProtoStreamObjectSource::RenderStructValue
static util::Status RenderStructValue(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:552
Field_Kind_TYPE_INT32
@ Field_Kind_TYPE_INT32
Definition: type.pb.h:92
google::protobuf::util::converter::IsMap
bool IsMap(const google::protobuf::Field &field, const google::protobuf::Type &type)
Definition: utility.cc:360
Field_Kind_TYPE_BOOL
@ Field_Kind_TYPE_BOOL
Definition: type.pb.h:95
p
const char * p
Definition: gmock-matchers_test.cc:3863
time.h
google::protobuf::util::converter::ObjectWriter::EndList
virtual ObjectWriter * EndList()=0
google::protobuf::io::ArrayInputStream
Definition: zero_copy_stream_impl_lite.h:65
google::protobuf::util::converter::TypeInfo
Definition: type_info.h:49
google::protobuf::uint64
uint64_t uint64
Definition: protobuf/src/google/protobuf/stubs/port.h:156
field_mask_utility.h
Field_Kind_TYPE_FIXED64
@ Field_Kind_TYPE_FIXED64
Definition: type.pb.h:93
Field_Cardinality_CARDINALITY_REPEATED
@ Field_Cardinality_CARDINALITY_REPEATED
Definition: type.pb.h:132
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: protostream_objectsource.cc:255
google::protobuf::util::converter::ProtoStreamObjectSource::render_unknown_enum_values_
bool render_unknown_enum_values_
Definition: protostream_objectsource.h:318
google::protobuf.internal::WireFormatLite::FieldType
FieldType
Definition: wire_format_lite.h:111
google::protobuf::util::converter::ProtoStreamObjectSource
Definition: protostream_objectsource.h:72
google::protobuf::util::converter::ProtoStreamObjectSource::RenderBool
static util::Status RenderBool(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:486
google::protobuf.internal::WireFormatLite::MakeTag
constexpr static uint32 MakeTag(int field_number, WireType type)
Definition: wire_format_lite.h:768
google::protobuf::util::converter::ProtoStreamObjectSource::NamedWriteTo
util::Status NamedWriteTo(StringPiece name, ObjectWriter *ow) const override
Definition: protostream_objectsource.cc:162
status_macros.h
google::protobuf::io::CodedInputStream::ReadLittleEndian32
bool ReadLittleEndian32(uint32 *value)
Definition: coded_stream.h:989
google::protobuf::StringPrintf
string StringPrintf(const char *format,...)
Definition: stringprintf.cc:109
google::protobuf::util::converter::EnumValueNameToLowerCamelCase
std::string EnumValueNameToLowerCamelCase(const StringPiece input)
Definition: utility.cc:243
google::protobuf::SimpleFtoa
string SimpleFtoa(float value)
Definition: strutil.cc:1224
casts.h
field
const FieldDescriptor * field
Definition: parser_unittest.cc:2694
google::protobuf::util::converter::ProtoStreamObjectSource::DeleteRendererMap
static void DeleteRendererMap()
Definition: protostream_objectsource.cc:751
google::protobuf.internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED
@ WIRETYPE_LENGTH_DELIMITED
Definition: wire_format_lite.h:104
google::protobuf::util::error::INVALID_ARGUMENT
@ INVALID_ARGUMENT
Definition: status.h:50
google::protobuf::io::CodedInputStream::PushLimit
Limit PushLimit(int byte_limit)
Definition: coded_stream.cc:117
google::protobuf::util::converter::kDefaultMaxRecursionDepth
static const int kDefaultMaxRecursionDepth
Definition: json_stream_parser.cc:67
google::protobuf::io::CodedInputStream::ReadString
bool ReadString(std::string *buffer, int size)
Definition: coded_stream.cc:243
google::protobuf::util::StatusOr
Definition: statusor.h:99
google::protobuf::util::converter::ProtoStreamObjectSource::ReadFieldValueAsString
const std::string ReadFieldValueAsString(const google::protobuf::Field &field) const
Definition: protostream_objectsource.cc:936
aditof::Status
Status
Status of any operation that the TOF sdk performs.
Definition: status_definitions.h:48
google::protobuf::util::converter::ProtoStreamObjectSource::suppress_empty_object_
bool suppress_empty_object_
Definition: protostream_objectsource.h:326
Field_Kind_TYPE_UINT64
@ Field_Kind_TYPE_UINT64
Definition: type.pb.h:91
google::protobuf::util::error::INTERNAL
@ INTERNAL
Definition: status.h:61
google::protobuf::util::converter::ObjectWriter::RenderBytes
virtual ObjectWriter * RenderBytes(StringPiece name, StringPiece value)=0
i
int i
Definition: gmock-matchers_test.cc:764
google::protobuf::util::converter::ProtoStreamObjectSource::ReadSecondsAndNanos
std::pair< int64, int32 > ReadSecondsAndNanos(const google::protobuf::Type &type) const
Definition: protostream_objectsource.cc:1064
Field
struct Field Field
Definition: php/ext/google/protobuf/protobuf.h:638
google::protobuf.internal::WireFormatLite::GetTagWireType
static WireType GetTagWireType(uint32 tag)
Definition: wire_format_lite.h:773
type
GLenum type
Definition: glcorearb.h:2695
google::protobuf::util::converter::ObjectWriter::RenderNull
virtual ObjectWriter * RenderNull(StringPiece name)=0
google::protobuf::util::converter::ObjectWriter::RenderString
virtual ObjectWriter * RenderString(StringPiece name, StringPiece value)=0
google::protobuf::util::converter::ProtoStreamObjectSource::type_
const google::protobuf::Type & type_
Definition: protostream_objectsource.h:296
common.h
google::protobuf::io::CodedInputStream::ReadTag
PROTOBUF_ALWAYS_INLINE uint32 ReadTag()
Definition: coded_stream.h:268
google::protobuf::util::converter::ProtoStreamObjectSource::RenderDouble
static util::Status RenderDouble(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:402
constants.h
google::protobuf::UnknownFieldSet
Definition: unknown_field_set.h:86
google::protobuf::util::converter::ProtoStreamObjectSource::FindAndVerifyField
const google::protobuf::Field * FindAndVerifyField(const google::protobuf::Type &type, uint32 tag) const
Definition: protostream_objectsource.cc:167
Field_Kind_TYPE_STRING
@ Field_Kind_TYPE_STRING
Definition: type.pb.h:96
google::protobuf::io::CodedInputStream
Definition: coded_stream.h:173
stringprintf.h
google::protobuf::util::converter::kTimestampMinSeconds
const int64 kTimestampMinSeconds
Definition: constants.h:53
wire_format.h
once.h
GOOGLE_LOG_IF
#define GOOGLE_LOG_IF(LEVEL, CONDITION)
Definition: logging.h:150
logging.h
descriptor.h
google::protobuf::util::converter::ConvertFieldMaskPath
std::string ConvertFieldMaskPath(const StringPiece path, ConverterCallback converter)
Definition: field_mask_utility.cc:64
google::protobuf::util::Status
Definition: status.h:67
google::protobuf::util::converter::ProtoStreamObjectSource::RenderMap
util::StatusOr< uint32 > RenderMap(const google::protobuf::Field *field, StringPiece name, uint32 list_tag, ObjectWriter *ow) const
Definition: protostream_objectsource.cc:277
type_resolver
TypeResolver * type_resolver
Definition: conformance_cpp.cc:97
Field_Kind_TYPE_FLOAT
@ Field_Kind_TYPE_FLOAT
Definition: type.pb.h:89
google::protobuf.internal::WireFormatLite::WireType
WireType
Definition: wire_format_lite.h:101
google::protobuf::util::converter::ProtoStreamObjectSource::RenderNonMessageField
util::Status RenderNonMessageField(const google::protobuf::Field *field, StringPiece field_name, ObjectWriter *ow) const
Definition: protostream_objectsource.cc:808
google::protobuf::util::converter::ProtoStreamObjectSource::RenderField
virtual util::Status RenderField(const google::protobuf::Field *field, StringPiece field_name, ObjectWriter *ow) const
Definition: protostream_objectsource.cc:764
Type
struct Type Type
Definition: php/ext/google/protobuf/protobuf.h:664
google::protobuf::util::StatusOr::ok
bool ok() const
Definition: statusor.h:246
google::protobuf::util::converter::ProtoStreamObjectSource::RenderStruct
static util::Status RenderStruct(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:533
google::protobuf::util::converter::ProtoStreamObjectSource::preserve_proto_field_names_
bool preserve_proto_field_names_
Definition: protostream_objectsource.h:306
google::protobuf::util::converter::ProtoStreamObjectSource::render_unknown_fields_
bool render_unknown_fields_
Definition: protostream_objectsource.h:315
google::protobuf.internal::WireFormatLite::ZigZagDecode64
static int64 ZigZagDecode64(uint64 n)
Definition: wire_format_lite.h:870
google::protobuf::util::converter::ObjectWriter::RenderUint32
virtual ObjectWriter * RenderUint32(StringPiece name, uint32 value)=0
true
#define true
Definition: cJSON.c:65
google::protobuf.internal::FormatTime
string FormatTime(int64 seconds, int32 nanos)
Definition: time.cc:271
google::protobuf::util::converter::kNanosPerSecond
const int32 kNanosPerSecond
Definition: constants.h:65
google::protobuf::util::converter::ProtoStreamObjectSource::typeinfo_
const TypeInfo * typeinfo_
Definition: protostream_objectsource.h:289
type_url
string * type_url
Definition: conformance_cpp.cc:98
Field_Kind_TYPE_ENUM
@ Field_Kind_TYPE_ENUM
Definition: type.pb.h:101
value
GLsizei const GLfloat * value
Definition: glcorearb.h:3093
google::protobuf::util::converter::ProtoStreamObjectSource::RenderAny
static util::Status RenderAny(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:593
RETURN_IF_ERROR
#define RETURN_IF_ERROR(expr)
Definition: status_macros.h:49
false
#define false
Definition: cJSON.c:70
Field_Kind_TYPE_BYTES
@ Field_Kind_TYPE_BYTES
Definition: type.pb.h:99
google::protobuf::util::converter::ProtoStreamObjectSource::RenderStructListValue
static util::Status RenderStructListValue(const ProtoStreamObjectSource *os, const google::protobuf::Type &type, StringPiece name, ObjectWriter *ow)
Definition: protostream_objectsource.cc:569
google::protobuf::util::converter::ProtoStreamObjectSource::set_use_lower_camel_for_enums
void set_use_lower_camel_for_enums(bool value)
Definition: protostream_objectsource.h:107
google::protobuf::util::converter::ProtoStreamObjectSource::ProtoStreamObjectSource
ProtoStreamObjectSource(io::CodedInputStream *stream, TypeResolver *type_resolver, const google::protobuf::Type &type)
Definition: protostream_objectsource.cc:118
google::protobuf::util::converter::kStructNullValueTypeUrl
const char kStructNullValueTypeUrl[]
Definition: constants.h:68
number
double number
Definition: cJSON.h:326
google
Definition: data_proto2_to_proto3_util.h:11
google::protobuf.internal::WireFormatLite::ZigZagDecode32
static int32 ZigZagDecode32(uint32 n)
Definition: wire_format_lite.h:859
google::protobuf::util::converter::ProtoStreamObjectSource::stream_
io::CodedInputStream * stream_
Definition: protostream_objectsource.h:285
google::protobuf::util::converter::ObjectWriter::RenderFloat
virtual ObjectWriter * RenderFloat(StringPiece name, float value)=0
google::protobuf::util::converter::source_renderers_init_
PROTOBUF_NAMESPACE_ID::internal::once_flag source_renderers_init_
Definition: protostream_objectsource.cc:710
google::protobuf::util::converter::ObjectWriter::EndObject
virtual ObjectWriter * EndObject()=0
google::protobuf::util::converter::ObjectWriter::RenderInt64
virtual ObjectWriter * RenderInt64(StringPiece name, int64 value)=0
google::protobuf::util::converter::ProtoStreamObjectSource::max_recursion_depth_
int max_recursion_depth_
Definition: protostream_objectsource.h:312
google::protobuf.internal::WireFormat::SkipField
static bool SkipField(io::CodedInputStream *input, uint32 tag, UnknownFieldSet *unknown_fields)
Definition: wire_format.cc:84
google::protobuf::io::CodedInputStream::ReadVarint64
bool ReadVarint64(uint64 *value)
Definition: coded_stream.h:931


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:06:58