struct.nanopb.cc 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. /*
  2. * Copyright 2022 Google LLC
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* Automatically generated nanopb constant definitions */
  17. /* Generated by nanopb-0.3.9.8 */
  18. #include "struct.nanopb.h"
  19. #include "Firestore/core/src/nanopb/pretty_printing.h"
  20. namespace firebase {
  21. namespace firestore {
  22. using nanopb::PrintEnumField;
  23. using nanopb::PrintHeader;
  24. using nanopb::PrintMessageField;
  25. using nanopb::PrintPrimitiveField;
  26. using nanopb::PrintTail;
  27. /* @@protoc_insertion_point(includes) */
  28. #if PB_PROTO_HEADER_VERSION != 30
  29. #error Regenerate this file with the current version of nanopb generator.
  30. #endif
  31. const pb_field_t google_protobuf_Struct_fields[2] = {
  32. PB_FIELD( 1, MESSAGE , REPEATED, POINTER , FIRST, google_protobuf_Struct, fields, fields, &google_protobuf_Struct_FieldsEntry_fields),
  33. PB_LAST_FIELD
  34. };
  35. const pb_field_t google_protobuf_Struct_FieldsEntry_fields[3] = {
  36. PB_FIELD( 1, BYTES , SINGULAR, POINTER , FIRST, google_protobuf_Struct_FieldsEntry, key, key, 0),
  37. PB_FIELD( 2, MESSAGE , SINGULAR, STATIC , OTHER, google_protobuf_Struct_FieldsEntry, value, key, &google_protobuf_Value_fields),
  38. PB_LAST_FIELD
  39. };
  40. const pb_field_t google_protobuf_Value_fields[7] = {
  41. PB_ANONYMOUS_ONEOF_FIELD(kind, 1, UENUM , ONEOF, STATIC , FIRST, google_protobuf_Value, null_value, null_value, 0),
  42. PB_ANONYMOUS_ONEOF_FIELD(kind, 2, DOUBLE , ONEOF, STATIC , UNION, google_protobuf_Value, number_value, number_value, 0),
  43. PB_ANONYMOUS_ONEOF_FIELD(kind, 3, BYTES , ONEOF, POINTER , UNION, google_protobuf_Value, string_value, string_value, 0),
  44. PB_ANONYMOUS_ONEOF_FIELD(kind, 4, BOOL , ONEOF, STATIC , UNION, google_protobuf_Value, bool_value, bool_value, 0),
  45. PB_ANONYMOUS_ONEOF_FIELD(kind, 5, MESSAGE , ONEOF, STATIC , UNION, google_protobuf_Value, struct_value, struct_value, &google_protobuf_Struct_fields),
  46. PB_ANONYMOUS_ONEOF_FIELD(kind, 6, MESSAGE , ONEOF, STATIC , UNION, google_protobuf_Value, list_value, list_value, &google_protobuf_ListValue_fields),
  47. PB_LAST_FIELD
  48. };
  49. const pb_field_t google_protobuf_ListValue_fields[2] = {
  50. PB_FIELD( 1, MESSAGE , REPEATED, POINTER , FIRST, google_protobuf_ListValue, values, values, &google_protobuf_Value_fields),
  51. PB_LAST_FIELD
  52. };
  53. /* Check that field information fits in pb_field_t */
  54. #if !defined(PB_FIELD_32BIT)
  55. /* If you get an error here, it means that you need to define PB_FIELD_32BIT
  56. * compile-time option. You can do that in pb.h or on compiler command line.
  57. *
  58. * The reason you need to do this is that some of your messages contain tag
  59. * numbers or field sizes that are larger than what can fit in 8 or 16 bit
  60. * field descriptors.
  61. */
  62. PB_STATIC_ASSERT((pb_membersize(google_protobuf_Struct_FieldsEntry, value) < 65536 && pb_membersize(google_protobuf_Value, struct_value) < 65536 && pb_membersize(google_protobuf_Value, list_value) < 65536), YOU_MUST_DEFINE_PB_FIELD_32BIT_FOR_MESSAGES_google_protobuf_Struct_google_protobuf_Struct_FieldsEntry_google_protobuf_Value_google_protobuf_ListValue)
  63. #endif
  64. #if !defined(PB_FIELD_16BIT) && !defined(PB_FIELD_32BIT)
  65. /* If you get an error here, it means that you need to define PB_FIELD_16BIT
  66. * compile-time option. You can do that in pb.h or on compiler command line.
  67. *
  68. * The reason you need to do this is that some of your messages contain tag
  69. * numbers or field sizes that are larger than what can fit in the default
  70. * 8 bit descriptors.
  71. */
  72. PB_STATIC_ASSERT((pb_membersize(google_protobuf_Struct_FieldsEntry, value) < 256 && pb_membersize(google_protobuf_Value, struct_value) < 256 && pb_membersize(google_protobuf_Value, list_value) < 256), YOU_MUST_DEFINE_PB_FIELD_16BIT_FOR_MESSAGES_google_protobuf_Struct_google_protobuf_Struct_FieldsEntry_google_protobuf_Value_google_protobuf_ListValue)
  73. #endif
  74. /* On some platforms (such as AVR), double is really float.
  75. * These are not directly supported by nanopb, but see example_avr_double.
  76. * To get rid of this error, remove any double fields from your .proto.
  77. */
  78. PB_STATIC_ASSERT(sizeof(double) == 8, DOUBLE_MUST_BE_8_BYTES)
  79. const char* EnumToString(
  80. google_protobuf_NullValue value) {
  81. switch (value) {
  82. case google_protobuf_NullValue_NULL_VALUE:
  83. return "NULL_VALUE";
  84. }
  85. return "<unknown enum value>";
  86. }
  87. std::string google_protobuf_Struct::ToString(int indent) const {
  88. std::string header = PrintHeader(indent, "Struct", this);
  89. std::string result;
  90. for (pb_size_t i = 0; i != fields_count; ++i) {
  91. result += PrintMessageField("fields ", fields[i], indent + 1, true);
  92. }
  93. bool is_root = indent == 0;
  94. if (!result.empty() || is_root) {
  95. std::string tail = PrintTail(indent);
  96. return header + result + tail;
  97. } else {
  98. return "";
  99. }
  100. }
  101. std::string google_protobuf_Struct_FieldsEntry::ToString(int indent) const {
  102. std::string header = PrintHeader(indent, "FieldsEntry", this);
  103. std::string result;
  104. result += PrintPrimitiveField("key: ", key, indent + 1, false);
  105. result += PrintMessageField("value ", value, indent + 1, false);
  106. std::string tail = PrintTail(indent);
  107. return header + result + tail;
  108. }
  109. std::string google_protobuf_Value::ToString(int indent) const {
  110. std::string header = PrintHeader(indent, "Value", this);
  111. std::string result;
  112. switch (which_kind) {
  113. case google_protobuf_Value_null_value_tag:
  114. result += PrintEnumField("null_value: ", null_value, indent + 1, true);
  115. break;
  116. case google_protobuf_Value_number_value_tag:
  117. result += PrintPrimitiveField("number_value: ",
  118. number_value, indent + 1, true);
  119. break;
  120. case google_protobuf_Value_string_value_tag:
  121. result += PrintPrimitiveField("string_value: ",
  122. string_value, indent + 1, true);
  123. break;
  124. case google_protobuf_Value_bool_value_tag:
  125. result += PrintPrimitiveField("bool_value: ",
  126. bool_value, indent + 1, true);
  127. break;
  128. case google_protobuf_Value_struct_value_tag:
  129. result += PrintMessageField("struct_value ",
  130. struct_value, indent + 1, true);
  131. break;
  132. case google_protobuf_Value_list_value_tag:
  133. result += PrintMessageField("list_value ",
  134. list_value, indent + 1, true);
  135. break;
  136. }
  137. bool is_root = indent == 0;
  138. if (!result.empty() || is_root) {
  139. std::string tail = PrintTail(indent);
  140. return header + result + tail;
  141. } else {
  142. return "";
  143. }
  144. }
  145. std::string google_protobuf_ListValue::ToString(int indent) const {
  146. std::string header = PrintHeader(indent, "ListValue", this);
  147. std::string result;
  148. for (pb_size_t i = 0; i != values_count; ++i) {
  149. result += PrintMessageField("values ", values[i], indent + 1, true);
  150. }
  151. bool is_root = indent == 0;
  152. if (!result.empty() || is_root) {
  153. std::string tail = PrintTail(indent);
  154. return header + result + tail;
  155. } else {
  156. return "";
  157. }
  158. }
  159. } // namespace firestore
  160. } // namespace firebase
  161. /* @@protoc_insertion_point(eof) */