struct.nanopb.cc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. /*
  2. * Copyright 2023 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 tostring_header = PrintHeader(indent, "Struct", this);
  89. std::string tostring_result;
  90. for (pb_size_t i = 0; i != fields_count; ++i) {
  91. tostring_result += PrintMessageField("fields ",
  92. fields[i], indent + 1, true);
  93. }
  94. bool is_root = indent == 0;
  95. if (!tostring_result.empty() || is_root) {
  96. std::string tostring_tail = PrintTail(indent);
  97. return tostring_header + tostring_result + tostring_tail;
  98. } else {
  99. return "";
  100. }
  101. }
  102. std::string google_protobuf_Struct_FieldsEntry::ToString(int indent) const {
  103. std::string tostring_header = PrintHeader(indent, "FieldsEntry", this);
  104. std::string tostring_result;
  105. tostring_result += PrintPrimitiveField("key: ", key, indent + 1, false);
  106. tostring_result += PrintMessageField("value ", value, indent + 1, false);
  107. std::string tostring_tail = PrintTail(indent);
  108. return tostring_header + tostring_result + tostring_tail;
  109. }
  110. std::string google_protobuf_Value::ToString(int indent) const {
  111. std::string tostring_header = PrintHeader(indent, "Value", this);
  112. std::string tostring_result;
  113. switch (which_kind) {
  114. case google_protobuf_Value_null_value_tag:
  115. tostring_result += PrintEnumField("null_value: ",
  116. null_value, indent + 1, true);
  117. break;
  118. case google_protobuf_Value_number_value_tag:
  119. tostring_result += PrintPrimitiveField("number_value: ",
  120. number_value, indent + 1, true);
  121. break;
  122. case google_protobuf_Value_string_value_tag:
  123. tostring_result += PrintPrimitiveField("string_value: ",
  124. string_value, indent + 1, true);
  125. break;
  126. case google_protobuf_Value_bool_value_tag:
  127. tostring_result += PrintPrimitiveField("bool_value: ",
  128. bool_value, indent + 1, true);
  129. break;
  130. case google_protobuf_Value_struct_value_tag:
  131. tostring_result += PrintMessageField("struct_value ",
  132. struct_value, indent + 1, true);
  133. break;
  134. case google_protobuf_Value_list_value_tag:
  135. tostring_result += PrintMessageField("list_value ",
  136. list_value, indent + 1, true);
  137. break;
  138. }
  139. bool is_root = indent == 0;
  140. if (!tostring_result.empty() || is_root) {
  141. std::string tostring_tail = PrintTail(indent);
  142. return tostring_header + tostring_result + tostring_tail;
  143. } else {
  144. return "";
  145. }
  146. }
  147. std::string google_protobuf_ListValue::ToString(int indent) const {
  148. std::string tostring_header = PrintHeader(indent, "ListValue", this);
  149. std::string tostring_result;
  150. for (pb_size_t i = 0; i != values_count; ++i) {
  151. tostring_result += PrintMessageField("values ",
  152. values[i], indent + 1, true);
  153. }
  154. bool is_root = indent == 0;
  155. if (!tostring_result.empty() || is_root) {
  156. std::string tostring_tail = PrintTail(indent);
  157. return tostring_header + tostring_result + tostring_tail;
  158. } else {
  159. return "";
  160. }
  161. }
  162. } // namespace firestore
  163. } // namespace firebase
  164. /* @@protoc_insertion_point(eof) */